EC2上的Fedora + Nginx + WordPress虚拟主机生成与实际主机名的链接

我目前正在尝试在Nginx中设置一个虚拟主机,这样我就可以运行一个wordpress服务器,就像它在不同的域上一样。 我现在遇到的问题是,wordpress服务器,当我去“ http://example-domain.com/blog/ ”时,显示每个链接指向亚马逊主机,“ec2 – – * .compute-1.amazonaws.com”。 我想所有这些链接来解决使用“example-domain.com”主机。

我的主要Nginx的conf文件(nginx.conf)是:

http { include /etc/nginx/mime.types; default_type application/octet-stream; server_names_hash_bucket_size 64; log_format main '$remote_addr - $remote_user [$time_local] $request ' '"$status" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 2; #gzip on; # Load config files from the /etc/nginx/conf.d directory include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; # # The default server # server { listen 80; server_name _; #charset koi8-r; #access_log logs/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } error_page 404 /404.html; location = /404.html { root /usr/share/nginx/html; } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } } } 

虚拟主机设置为以下conf:

 server { listen 80; server_name example-domain.com; root /var/www/example-domain.com/html; index index.html index.htm index.php; # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } } 

wordpress文件夹位于/var/www/example-domain.com/html/blog/。 有没有人有任何想法,为什么在首页上的所有WordPress的链接使用EC2的主机名,而不是在虚拟主机configuration定义的? 如果是这样,请帮助我。

提前致谢!

这是因为wordpress保持URL /域名在数据库设置。 你需要login到WordPress的WP – pipe理和更新网站的url或直接在数据库中直接更新。