例如:
server {
listen 80;
server_name www.xxx1.com;
index index.html index.htm index.php;
root /www/data1;
access_log off;
}
server {
listen 80;
server_name www.xxx2.com;
index index.html index.htm index.php;
root /www/data2;
access_log off;
}
server {
listen 80;
server_name www.xxx3.com;
index index.html index.htm index.php;
root /www/data3;
access_log off;
}
这样的话就启动不了,难道只支持2个?
不会的,只凭上面的我也看不出问题才哪,应该是小问题,仔细检查一下。
请看LEMP第三版,建立的时候就是建立vhost目录,仍后你可以配置N多虚拟主机.
贴个整个的配置文件给你看看 有什么问题不? 当没有第3个的时候,一切正常,如下面就不正常
user www www;
#Nginx……10M~12M……….Nginx……..
worker_processes 1;
error_log /web/logs/nginx_error.log crit;
pid /usr/local/nginx/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
}
http
{
include mime.types;
default_type application/octet-stream;
#charset gb2312;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
#……CSS.JS.XML…gzip………………
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
#limit_zone crawler $binary_remote_addr 10m;
server
{
listen 80;
server_name www.xxx1.com;
index index.html index.htm index.php;
root /web/www;
#limit_conn crawler 20;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
location ~ .*.(php|php5)?$
{
#.Nginx.FastCGI……TCP..Unix Socket.TCP……..Unix Socket….Unix Socket….TCP..
fastcgi_pass unix:/tmp/php-cgi.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ /read.php
{
#.Nginx.FastCGI……TCP..Unix Socket.TCP……..Unix Socket….Unix Socket….TCP..
fastcgi_pass unix:/tmp/php-cgi.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
#……………………15…………………
location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 15d;
}
#…….JavaScript.CSS…………1………………………………………JavaScript.CSS………..
location ~ .*.(js|css)?$
{
expires 1d;
}
log_format access ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” $http_x_forwarded_for’;
access_log /web/logs/access.log access;
}
server
{
listen 80;
server_name www.xxx2.com;
index index.html index.htm index.php;
root /web/www1;
#limit_conn crawler 20;
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?q=$1 last;
}
location ~ .*.(php|php5)?$
{
fastcgi_pass unix:/tmp/php-cgi.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fcgi.conf;
}
log_format wwwlogs ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” $http_x_forwarded_for’;
access_log /web/logs/wwwlogs.log wwwlogs;
}
server
{
listen 80;
server_name www.xxx3.com;
index index.html Index.html index.htm index.php;
root /web/www2;
#设定本虚拟主机的访问日志
access_log web/logs/www.cn.access.log main;
location ~ .*.php?$
{
include fcgi.conf;
fastcgi_pass unix:/tmp/php-cgi.sock;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
}
#如果访问 /img/*, /js/*, /css/* 资源,则直接取本地文件,不通过squid
#如果这些文件较多,不推荐这种方式,因为通过squid的缓存效果更好
location ~ ^/(img|js|css)/ {
root /var/htdocs/52crack;
expires 24h;
}
}
声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。