Nginx installation Configuration

Source: Internet
Author: User
Nginx: 0.8.151. Install the pcre Library required by Nginx: Export cdusrlocalsrctarbag#tarzxvfpcre-7.9.tar.gz-C .. software # cd .. softwarepcre-7.9 #. configure # makemakeinstall # cdhttp: restart

Nginx: 0.8.15

1, InstallationNginxRequiredPcreLibrary:

  1. #Cd/Usr/local/src/tarbag
  2. # Tar zxvf pcre-7.9.tar.gz-C ../software
  3. # Cd ../software/pcre-7.9/
  4. #./Configure
  5. # Make & make install
  6. # Cd http://www.linuxIdC.com/tarbag

2, InstallationNginx

  1. # Tar zxvf nginx-0.8.15.tar.gz-C ../software
  2. # Cd ../software/nginx-0.8.15/
  3. #./Configure -- user = nobody -- group = nobody -- prefix =/usr/local/nginx -- with-http_stub _StatUs_moDuLe -- with-http_ssl_module
  4. # Make & make install
  5. # Cd http://www.linuxidc.com/tarbag

3, CreateNginxLog directory

  1. Mkdir-P/opt/www/nginx/logs
  2. Chmod+ W/www/nginx/logs
  3. Chown-R nobody: nobody/www/nginx/logs

4, CreateNginxConfiguration File
In/Usr/local/nginx/conf/CreateNginx. confFile:

  1. Rm-F/usr/local/nginx/conf/nginx. conf
  2. Vi/usr/local/nginx/conf/nginx. conf
  3. User nobody;
  4. Worker_processes 8;
  5. Error_log/opt/www/nginx/logs/nginx_error.log crit;
  6. Pid/usr/local/nginx. pid;
  7. # Specifies the value for maximumFileDescriptors that can be openEdBy this process. worker_rlimit_nofile 65535;
  8. Events
  9. {
  10. Use epoll;
  11. Worker_connections 65535;
  12. }
  13. Http
  14. {
  15. INcLude mime. types;
  16. Default_type appliCatIon/octet-sTrEam;
  17. # CharSetGb2312;
  18. Server_names_hash_bucket_size 128;
  19. Client_header_buffer_size 32 k;
  20. Large_client_header_buffers 4 32 k;
  21. Client_max_body_size 8 m;
  22. SenDfIle on;
  23. TCp_ Nopush on;
  24. Keepalive _TimeOut 60;
  25. Tcp_nodelay on;
  26. GZipOn;
  27. Gzip_ Min_length 1 k;
  28. Gzip_buffers 4 16 k;
  29. Gzip_http_version 1.0;
  30. Gzip_comp_level 2;
  31. Gzip_types tExT/plain application/x-javascript text/css application/xml;
  32. Gzip_vary on;
  33. Log_format access \ '$ remote_aDdR-$ remote_user [$ time_local] \'
  34. \ "$ Request \" $ status $ bytes_sent \'
  35. \ '\ "$ Http_referer \" \ "$ http_user_agent \"\'
  36. \ "$ Gzip_ratio \"\';
  37. Log_format wwwlogs \ '$ remote_addr-$ remote_user [$ time_local] \'
  38. \ '\ "$ Request \" $ status $ bytes_sent \'
  39. \ '\ "$ Http_referer \" \ "$ http_user_agent \"\'
  40. \ '\ "$ Http_range \" \ "$ sent_http_content_range \"\';
  41. Include vhosts. conf
  42. }

In/Usr/local/nginx/conf/CreateVhosts. confFile:

  1. Vi/usr/local/nginx/conf/vhosts. conf
  2. # Limit_zone crawler $ binary_remote_addr 10 m;
  3. Server
  4. {
  5. Listen 80;
  6. Server_name www.hsf.com;
  7. Index index.html index.htm index.Php;
  8. Root/www/blog;
  9. # Limit_conn crawler 20;
  10. Access_log/opt/www/nginx/logs/access. log access;
  11. }
  12. Server
  13. {
  14. Listen 80;
  15. Server_name www.hsf.com;
  16. Index index.html index.htm index. php;
  17. Root/www;
  18. Access_log/www/nginx/wwwlogs. log wwwlogs;
  19. }
  20. Server
  21. {
  22. Listen 80;
  23. Server_name status.www.hsf.com;
  24. Location/
  25. {
  26. Stub_status on;
  27. Access_log off;
  28. }
  29. }

5, StartNginx

  1. Ulimit-SHn 65535
  2. /Usr/local/nginx/sbin/nginx

OptimizationLinuxKernel Parameters

  1. Vi/etc/sysctl. conf

Add the following content at the end:

  1. # Add
  2. Net. ipv4.tcp _ max_syn_backlog = 65536
  3. Net. core. netdev_max_backlog = 32768
  4. Net. core. somaxconn = 32768
  5. Net. core. wmem_default = 8388608

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.