大佬教程收集整理的这篇文章主要介绍了Nginx多域,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试向Nginx添加第二个虚拟主机.当我转到新域时,它会重定向到旧域.我试过重启Nginx,重启服务器.
有没有人遇到这个,关心分享?
文件:Nginx.conf ###
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;
}
}
/home/me/public_html/domain2/public$fastcgi_script_name;
以上是大佬教程为你收集整理的Nginx多域全部内容,希望文章能够帮你解决Nginx多域所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。