异想天开

What's the true meaning of light, Could you tell me why

多个域名共用一台主机

日期:2015-04-09 14:21:05
  
最后更新日期:2015-04-09 14:21:05
【技术】
每个域名绑定不同的目录,这样就可以使用同一台主机共用多个域名。
appache httpd配置:
[code lang="cpp"]
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/test/
ServerName www.test.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/foo/
ServerName www.foo.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
[/code]

nginx下的配置: [code lang="cpp"]
server {
listen 80;
server_name www.test.com;
location ~ \.php$ {
root /var/www/web/test/ ;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 80;
server_name www.foo.com;
location ~ \.php$ {
root /var/www/web/foo/ ;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
[/code]