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;
}
}