Nginx多域

前端之家收集整理的这篇文章主要介绍了Nginx多域前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

我正在尝试向Nginx添加第二个虚拟主机.当我转到新域时,它会重定向到旧域.我试过重启Nginx,重启服务器.@H_301_2@

有没有人遇到这个,关心分享?@H_301_2@

文件Nginx.conf ###@H_301_2@

@H_301_2@

  1. user www-data www-data;
  2. worker_processes 4;
  3. events {
  4. worker_connections 1024;
  5. }
  6. http {
  7. include mime.types;
  8. default_type application/octet-stream;
  9. sendfile on;
  10. tcp_nopush on;
  11. tcp_nodelay off;
  12. keepalive_timeout 5;
  13. gzip on;
  14. gzip_comp_level 2;
  15. gzip_proxied any;
  16. gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+RSS text/javascript;
  17. include /usr/local/Nginx/sites-enabled/*;
  18. }

文件:../ sites-enabled / domain1.co.uk@H_301_2@

@H_301_2@

  1. server {
  2. listen 80;
  3. server_name www.domain1.co.uk;
  4. rewrite ^/(.*) http://domain1.co.uk/$1 permanent;
  5. }
  6. server {
  7. listen 80;
  8. server_name domain1.co.uk;
  9. access_log /home/me/public_html/domain1.co.uk/log/access.log;
  10. error_log /home/me/public_html/domain1.co.uk/log/error.log;
  11. location / {
  12. root /home/me/public_html/domain1.co.uk/public/;
  13. index index.PHP index.html;
  14. # wordpress supercache & permalinks.
  15. include /usr/local/Nginx/conf/wordpress_params.super_cache;
  16. }
  17. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  18. location ~ \.PHP$
  19. {
  20. fastcgi_pass 127.0.0.1:9000;
  21. fastcgi_index index.PHP;
  22. include /usr/local/Nginx/conf/fastcgi_params;
  23. fastcgi_param SCRIPT_FILENAME /home/me/public_html/domain1.co.uk/public/$fastcgi_script_name;
  24. }
  25. }

文件:../ sites-enabled / domain2.co.uk@H_301_2@

@H_301_2@

  1. server {
  2. listen 80;
  3. server_name www.domain2.co.uk;
  4. rewrite ^/(.*) http://domain2.co.uk/$1 permanent;
  5. }
  6. server {
  7. listen 80;
  8. server_name domain2.co.uk;
  9. access_log /home/me/public_html/domain2.co.uk/log/access.log;
  10. error_log /home/me/public_html/domain2.co.uk/log/error.log;
  11. location /
  12. {
  13. root /home/me/public_html/domain2.co.uk/public/;
  14. index index.PHP index.html;
  15. # Basic version of wordpress parameters,supporting nice permalinks.
  16. # include /usr/local/Nginx/conf/wordpress_params.regular;
  17. # Advanced version of wordpress parameters supporting nice permalinks and WP Super Cache plugin
  18. include /usr/local/Nginx/conf/wordpress_params.super_cache;
  19. }
  20. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  21. #
  22. location ~ \.PHP${
  23. fastcgi_pass 127.0.0.1:9000;
  24. fastcgi_index index.PHP;
  25. include /usr/local/Nginx/conf/fastcgi_params;
  26. fastcgi_param SCRIPT_FILENAME /home/me/public_html/domain2/public/$fastcgi_script_name;
  27. }
  28. }
最佳答案
尝试从fastcgi_param SCRIPT_FILENAME中删除额外的斜杠,所以该行将是:@H_301_2@

@H_301_2@

  1. /home/me/public_html/domain2/public$fastcgi_script_name;

猜你在找的Nginx相关文章