我正在尝试向Nginx添加第二个虚拟主机.当我转到新域时,它会重定向到旧域.我试过重启Nginx,重启服务器.
有没有人遇到这个,关心分享?
user www-data www-data;
worker_processes 4;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
keepalive_timeout 5;
gzip on;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+RSS text/javascript;
include /usr/local/Nginx/sites-enabled/*;
}
文件:../ sites-enabled / domain1.co.uk
server {
listen 80;
server_name www.domain1.co.uk;
rewrite ^/(.*) http://domain1.co.uk/$1 permanent;
}
server {
listen 80;
server_name domain1.co.uk;
access_log /home/me/public_html/domain1.co.uk/log/access.log;
error_log /home/me/public_html/domain1.co.uk/log/error.log;
location / {
root /home/me/public_html/domain1.co.uk/public/;
index index.PHP index.html;
# wordpress supercache & permalinks.
include /usr/local/Nginx/conf/wordpress_params.super_cache;
}
# 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;
include /usr/local/Nginx/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /home/me/public_html/domain1.co.uk/public/$fastcgi_script_name;
}
}
文件:../ sites-enabled / domain2.co.uk
server {
listen 80;
server_name www.domain2.co.uk;
rewrite ^/(.*) http://domain2.co.uk/$1 permanent;
}
server {
listen 80;
server_name domain2.co.uk;
access_log /home/me/public_html/domain2.co.uk/log/access.log;
error_log /home/me/public_html/domain2.co.uk/log/error.log;
location /
{
root /home/me/public_html/domain2.co.uk/public/;
index index.PHP index.html;
# Basic version of wordpress parameters,supporting nice permalinks.
# include /usr/local/Nginx/conf/wordpress_params.regular;
# Advanced version of wordpress parameters supporting nice permalinks and WP Super Cache plugin
include /usr/local/Nginx/conf/wordpress_params.super_cache;
}
# 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;
include /usr/local/Nginx/conf/fastcgi_params;
fastcgi_param SCRIPT_FILENAME /home/me/public_html/domain2/public/$fastcgi_script_name;
}
}
最佳答案
尝试从fastcgi_param SCRIPT_FILENAME中删除额外的斜杠,所以该行将是:
原文链接:https://www.f2er.com/nginx/435570.html /home/me/public_html/domain2/public$fastcgi_script_name;