我是Nginx的新手,我试图让子域名工作。nginx - 两个子域配置
我想要做的就是把我的域(姑且称之为example.com
),并添加:
sub1.example.com
,sub2.example.com
,并且也有www.example.com
可用。
我知道如何使用Apache来做到这一点,但Nginx是一个真正的头部划痕。
我运行Debian 6
我目前/etc/nginx/sites-enabled/example.com:
server {
server_name www.example.com example.com;
access_log /srv/www/www.example.com/logs/access.log;
error_log /srv/www/www.example.com/logs/error.log;
root /srv/www/www.example.com/public_html;
location/{
index index.html index.htm;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/www.example.com/public_html$fastcgi_script_name;
}
}
它正在努力成为example.com和www.example。 COM。
我试图在同一文件中添加第二个服务器模块,如:
server {
server_name www.example.com example.com;
access_log /srv/www/www.example.com/logs/access.log;
error_log /srv/www/www.example.com/logs/error.log;
root /srv/www/www.example.com/public_html;
server {
server_name sub1.example.com;
access_log /srv/www/example.com/logs/sub1-access.log;
error_log /srv/www/example.com/logs/sub1-error.log;
root /srv/www/example.com/sub1;
}
location/{
index index.html index.htm;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /srv/www/www.example.com/public_html$fastcgi_script_name;
}
}
没有运气。有任何想法吗?我非常感谢任何反馈。
我应该提到:sub1.example.com的最终目标是转到example.com/sub1和sub2.example.com转到example.com/sub2。我希望这是有道理的。 – boredemt