Common configuration of nginx.conf under LNMP environment

Source: Internet
Author: User

A common configuration description of nginx.conf in a LNMP environment

Vim/usr/local/nginx/conf/nginx.conf Use the following configuration

User  nobody nobody;   //nginx user worker_processes 2;    of the child process  //nginx number of child processes error_log /usr/local/nginx/logs/nginx_error.log debug; //error log path and log level   Debug debugging with the most detailed  , general use Critpid /usr/local/nginx/logs/nginx.pid; //nginx process Pidworker_rlimit_nofile  51200;events{    use epoll;    worker_connections 6000 ;} http{    include mime.types;    default_type application/ Octet-stream;    server_names_hash_bucket_size 3526;    server_ names_hash_max_size 4096;    log_format main  ' $proxy _add_x_forwarded_for  -  $remote _user [$time _local]  '                         ' $request '   $status  $ body_bytes_sent  '  &Nbsp;                      ' "$http _referer"   "$http _user_agent";  //Log Save Format     sendfile  on;    tcp_nopush on;    keepalive_timeout 30;     client_header_timeout 3m;    client_body_timeout 3m;     send_timeout 3m;    connection_pool_size 256;     client_header_buffer_size 1k;    large_client_header_buffers 8  4k;    request_pool_size 4k;    output_buffers 4 32k;     postpone_output 1460;    client_max_body_size 10m;     client_body_buffer_size 256k;    client_body_temp_path /usr/ Local/nginx/client_body_temp;&nbsP;   proxy_temp_path /usr/local/nginx/proxy_temp;    fastcgi_temp_path  /usr/local/nginx/fastcgi_temp;    fastcgi_intercept_errors on;     tcp_nodelay on;    gzip on;    gzip_min_length  1k;    gzip_buffers 4 8k;    gzip_comp_level 5;     gzip_http_version 1.1;    gzip_types text/plain  application/x-javascript text/css text/htm application/xml;server{     listen 80;    server_name     --//Domain       index index.html index.htm index.php;    root /usr/local/nginx/ html;  --//the corresponding catalogue     location ~ \.php$ {         include fastcgi_params;        fastcgi_pass unix:/tmp/ The php-fcgi.sock;  --//path can be sock  or ip:port format          Fastcgi_index index.php;        fastcgi_param script_ filename /usr/local/nginx/html$fastcgi_script_name;    }                                             --//This section is PHP parsing settings  }include /usr/local/nginx/conf/vhosts/*.conf;}

Additional virtual machines are required to be added in the/usr/local/nginx/conf/vhosts/directory

I'm using the discuz. The forum is configured as follows

Vim/usr/local/nginx/conf/vhosts/discuz.conf

Add the following content:

server{    listen 80;    server_name www.discuz.com    --//dual domain  discuz   bbc1     if  ($host  !=  ' Www.discuz.com '  )  {        rewrite  ^/(. *) $   http://www.discuz.com/$1  permanent;    }                                           -- Domain Jump point to www.discuz.com    index index.html index.htm index.php;     root /data/www;    location ~ .*rc/w/ {         auth_basic                "Auth";         --//Authentication window name   FREE access to          auth_basic_user_file   /usr/local/nginx/conf/htpasswd;  --//Authentication user name and password save path          include fastcgi_params;                 --//if there is no PHP parsing this part can not          fastcgi_pass unix:/tmp/php-fcgi.sock;         Fastcgi_index index.php;        fastcgi_param script_ filename /data/www$fastcgi_script_name;                       }                          -- A certified   &nbs for the directoryp;  location ~   admin\.php$ {         auth_basic               "Auth";         auth_basic_user_file   /usr/local/nginx/conf/ htpasswd;        include fastcgi_params;         fastcgi_pass unix:/tmp/php-fcgi.sock;         fastcgi_index index.php;        fastcgi_param script_ filename /data/www$fastcgi_script_name;                      }           --//A separate authentication &nbsp for admin.php, which improves background security     location ~ \.php$ {     &nBsp;   include fastcgi_params;        fastcgi_pass  unix:/tmp/php-fcgi.sock;        fastcgi_index index.php;         fastcgi_param script_filename /data/www$fastcgi_ script_name;                       }                     --//php parsing module     location ~ .*\. (jpg|gif|jpeg|png|js|css) $ {        --//file type can be added according to the actual situation                 expires     30d;             --//Set cache time 30 days                 access_log off;              --//do not set logging for the above                 valid_referers none blocked server_names  * .taobao.com *.baidu.com *.google.com *.google.cn *.soso.com *.apelearn.com;     --//set up the anti-theft chain, only these URLs can use the site link                  if  ($invalid _referer)  {                                        return 403;                                  # rewrite ^/ http://www.example.com/nophoto.gif;                                          } --//does not belong to the above website all return 403                      #allow  192.168.205.128;   --//allows a single ip                                             #allow   127.0.0.1                      #allow  10.0.1.0/24;        --//Allow IP segment                       #deny   all;                --//This part is the limitation of IP                        include deny.ip;          --//can also create a DENY.IP in the Conf directory to limit the IP on the inside}

The above is the basic configuration, the other configuration later.

This article is from the "10999243" blog, please be sure to keep this source http://11009243.blog.51cto.com/10999243/1759897

Common configuration of nginx.conf under LNMP environment

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.