Wordpress安装在Vagrant box中,不断重定向回http://localhost

Wordpress安装在Vagrant box中,不断重定向回http://localhost,wordpress,nginx,vagrant,Wordpress,Nginx,Vagrant,我遇到了一个奇怪的问题,当我浏览到浏览器中一个漫游框的端口转发URI(在本例中)时,我被重定向回localhost(默认服务器)。我不知道为什么会发生这种情况,这真的令人沮丧 在我的来宾计算机上,我的根文件夹位于/var/www/wordpress中,这是我的/nginx/sites available/nginx_vhost文件: server { listen 80; listen [::]:80 ipv6only=on; root /var/www/wordpre

我遇到了一个奇怪的问题,当我浏览到浏览器中一个漫游框的端口转发URI(在本例中)时,我被重定向回localhost(默认服务器)。我不知道为什么会发生这种情况,这真的令人沮丧

在我的来宾计算机上,我的根文件夹位于/var/www/wordpress中,这是我的/nginx/sites available/nginx_vhost文件:

server {
    listen 80;
    listen [::]:80 ipv6only=on;

    root /var/www/wordpress;
    index index.php index.html index.htm;

    server_name localhost;

    location / {
            # try_files $uri $uri/ =404;
            try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
            root /usr/share/nginx/html;
    }

    location ~* \.php$ {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            #fastcgi_read_timeout 300;
            #proxy_read_timeout 300;
    }
}

这是我的流浪汉档案:

Vagrant.configure("2") do |config|

# Set Vagrant box to use
config.vm.box = "ubuntu/trusty64"

# Configure port forwarding
config.vm.network :forwarded_port, guest: 80, host: 9001, auto_correct: true

# Set synched folder
config.vm.synced_folder "./", "/var/www/wordpress", create: true, group: "www-data", owner: "www-data"

# Configure the VM
config.vm.provider "virtualbox" do |v|
    v.name = "Pet Vets Vagrant Box"
    v.customize ["modifyvm", :id, "--memory", "1024"]
end

# Set up shell provisioning
config.vm.provision :shell, :path => "bootstrap.sh"
结束

和我的bootstrap.sh文件:

#!/bin/bash

echo "Provisioning virtual machine..."
apt-get update

echo "Installing Tree..."
apt-get install tree

echo "Installing Git"
apt-get install git -y > /dev/null

echo "Installing Nginx"
apt-get install nginx -y >/dev/null

echo "Configuring Nginx"
cp /var/www/wordpress/nginx_vhost /etc/nginx/sites-available/nginx_vhost > /dev/null

ln -s /etc/nginx/sites-available/nginx_vhost /etc/nginx/sites-enabled/nginx_vhost

rm /etc/nginx/sites-available/default

service nginx restart > /dev/null

echo "Updating PHP repository"
apt-get install python-software-properties build-essential -y > /dev/null
add-apt-repository ppa:ondrej/php5 -y > /dev/null
apt-get update > /dev/null

echo "Installing PHP"
apt-get install php5-common php5-dev php5-cli php5-fpm libssh2-php -y > /dev/null

echo "Installing PHP extensions"
apt-get install curl php5-curl php5-gd php5-mcrypt php5-mysql -y > /dev/null
apt-get install libapache2-mod-php5
当我将Wordpress安装在nGinx本地主机上(不使用Vagrant)时,它可以正常工作,但一旦我将它放在一个Vagrant框中,它就不想玩了。有人有什么想法吗


谢谢

所以问题不在于nGinx,而在于Wordpress配置

我将wp_选项表中的siteurl和home都设置为http::localhost,需要将其设置为

希望这对将来的任何人都有帮助

谢谢