首页 > 系统 > Linux >

Linux下安装Lnmp环境之Nginx Vhosts配置

2017-02-17

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  ]
相关文章
最新文章
热点推荐