Configure Nginx VM in centos

Source: Internet
Author: User
Tags centos egrep

Preparations:

[Root @ lnmp ~] # Mkdir/usr/local/nginx/conf/extra-p # Where/usr/local/nginx/conf is the default configuration file of nginx

[Root @ lnmp ~] # Mdkir/var/site/www-p # Create a website directory
[Root @ lnmp ~] # Mdkir/var/site/bbs # bbs Directory
[Root @ lnmp ~] # Cd/usr/local/nginx/conf/
[Root @ lnmp conf] # egrep-v "# | ^ $"/usr/local/nginx/conf/nginx. conf> extra/nginx-www.conf # empty lines, annotation exclusion, and nginx-www.conf placed under the/var/local/nginx/conf/extra directory
[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] # music nginx-default.conf nginx. conf
Nginx main nginx. conf:

[Root @ lnmp conf] # cat nginx. conf
Worker_processes 1;
Events {
Worker_connections 1024;
}
Http {
Include mime. types;
Include extra/*. conf; # load the VM configuration file
Default_type application/octet-stream;
Sendfile on;
Keepalive_timeout 65;
}

Virtual host configuration:

[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 x.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;
        }
    }

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.