nginx同一iP多域名配置方法

时间:2023-12-16 17:25:14

文章转自:http://blog.itblood.com/nginx-same-ip-multi-domain-configuration.html

下面的是我本机的配置:

server {
listen ;
server_name localhost; #绑定域名
index index.htm index.html index.php; #默认文件
root /data/webroot; #网站根目录
location ~ \.php$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
include fastcgi_params;
}
access_log /data/logs/access.log;
error_log /data/logs/error.log;
}
server {
listen ;
server_name test.localhost; #绑定域名
index index.htm index.html index.php; #默认文件
root /data/webroot/testRoot; #网站根目录
location ~ \.php$ {
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
include fastcgi_params;
}
access_log /data/logs/test_access.log;
error_log /data/logs/test_error.log;
}