centos下Nginx虛擬機器主機配置步驟

來源:互聯網
上載者:User

前期準備工作:

[root@lnmp ~]# mkdir /usr/local/nginx/conf/extra -p    #其中/usr/local/nginx/conf是nginx的預設設定檔

[root@lnmp ~]# mdkir /var/site/www -p    #建立網站目錄
[root@lnmp ~]# mdkir /var/site/bbs    #bbs目錄
[root@lnmp ~]# cd /usr/local/nginx/conf/
[root@lnmp conf]# egrep -v "#|^$"  /usr/local/nginx/conf/nginx.conf >extra/nginx-www.conf   #空行、注釋排除,且放置在/var/local/nginx/conf/extra目錄下的nginx-www.conf
[root@lnmp conf]# egrep -v "#|^$"  /usr/local/nginx/conf/nginx.conf >nginx-default.conf
[root@lnmp conf]# mv nginx.conf nginx.conf.backup
[root@lnmp conf]# mv nginx-default.conf nginx.conf
nginx主nginx.conf:

[root@lnmp conf]# cat nginx.conf
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    include extra/*.conf;    #載入虛擬機器主機設定檔
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
}

虛擬機器主機配置:

[root@lnmp conf]# cat extra/nginx-www.conf
    server {
        listen       80;
        server_name  www.111cn.net;
        location / {
            root   /var/site/www;
            index  index.html index.htm index.php;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /var/site/www;
        }
        error_page   404  /404.html;
        location = /404.html {
            root   /var/site/www;
        }
        location ~ \.php$ {
        root   /var/site/www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /var/site/www$fastcgi_script_name;
            include        fastcgi.conf;
        }
    }

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.