1. 程式人生 > >Linux下安裝Lnmp環境之Nginx Vhosts配置

Linux下安裝Lnmp環境之Nginx Vhosts配置

1、開啟vhosts目錄

mkdir /usr/local/nginx/conf/vhosts
vim /usr/local/nginx/conf/nginx.conf

在server 外邊新增

include vhosts/*.conf

2、配置多站點

server {
    listen       80;
    server_name  www.local.com;
    root   /usr/www/www.local.com/;
    index  index.php index.html;    

    #access_log  /var/log/nginx/www.local.com.log;
#error_log /var/log/nginx/www.local.com.log error; location / { index index.php; # If file not found, redirect to Zend handling, we can remove the (if) here and go directly rewrite if (!-e $request_filename){ rewrite ^/(.*) /index.php last; } } location /index
.html { rewrite ^ /index.html break; } #limit_conn crawler 20; location ~* ^.+\.(js|ico|gif|jpg|jpeg|pdf|png|css)$ { access_log off; #日誌關閉 expires 7d; #快取7天 } location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index
.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param APPLICATION_ENV development; include fastcgi_params; #error_page 404 http://audit.local/error; } }

3、重啟Nginx

重啟nginx,顯示以下內容代表成功。

service nginx restart
Stopping nginx:                                            [  OK  ]
Starting nginx:                                            [  OK  ]