Installation Configuration nginx + clear mounted cache module

After a period of use, found concurrent with nginx load capacity is indeed better than apache, now most of the site from apache to nginx a. The following are some simple installation of nginx configuration. Environment Operating System: CentOS, RedHat IP address: 192.168.1.202 download package # mkdir / usr / local / src / tarbag # mkdir / usr / local / src / software # cd / usr / local / src / tarbag / Nginx # wget http://www.nginx.org/download/nginx-1.0.6.tar.gz the Nginx purge Cache module (optional) # wget http://labs.frickle.com/files/ngx_cache_purge-1.3.tar.gz compile and install # Cd / usr / local / src / tarbag / # tar -xzvf nginx-1.0.6.tar.gz -C / usr / local / src / software # tar -xzvf ngx_cache_purge-1.3.tar.gz -C / usr / local / src / software # cd / usr / local / src / software / # ./configure \ --prefix = / usr / local / nginx-1.0.6 \ # installation path --with-http_stub_status_module \ # enabled state module nginx --with-http_ssl_module \ # enable SSL module --with-http_realip_module \ # enable realip module (IP forwards the user to the backend server) --add-module = .. / ngx_cache_purge -1.3 # add expansion modules # make clear cache # make install   kernel parameter optimization # Vi sysctl.conf following configuration net.ipv4.netfilter.ip_conntrack_tcp_timeout_established = 1800 net.ipv4.ip_conntrack_max = 16777216 # If you use the default parameters, prone to packet loss net.ipv4.netfilter.ip_conntrack_max = 16777216 # If you use the default parameters, prone to network packet loss net.ipv4.tcp_max_syn_backlog = 65536 net.core.netdev_max_backlog = 32768 net.core.somaxconn = 32768 net.core.wmem_default = 8388608 net.core.rmem_default = 8388608 net.core.rmem_max = 16777216 net.core .wmem_max = 16777216 net.ipv4.tcp_timestamps = 0 net.ipv4.tcp_synack_retries = 2 net.ipv4.tcp_syn_retries = net.ipv4.tcp_tw_recycle = 1 net.ipv4.tcp_tw_reuse = 1 net.ipv4.tcp_mem = 94500000 915000000 927000000 net.ipv4 .tcp_max_orphans = 3276800 net.ipv4.ip_local_port_range = 1024 65535 configuration to take effect # sysctl -p modify iptables startup script, the star () function inside with # vi /etc/init.d/iptables / sbin / sysctl -p   configuration example site site No. 1 domain name directory www.heytool.com /www/html/www.heytool.com 2 bbs.heytool.com /www/html/bbs.heytool.com   modify nginx configuration file: # Vi nginx.conf user nobody nobody; owning group, and run nginx owner # of worker_processes 2; # turn two nginx worker processes, usually several CPU cores to write a few error_log logs / error.log notice; # pid error log path logs / nginx.pid; # pid path events {worker_connections 1024; # a process able to handle requests 1024} http {include mime.types; default_type application / octet-stream; log_format main '$ remote_addr - $ remote_user [$ time_local] "$ request" '' $ status $ body_bytes_sent "$ http_referer" '' "$ http_user_agent" "$ http_x_forwarded_for" '; access_log logs / access.log main; # default access log path sendfile on; keepalive_timeout 65; # keepalive time supermarket # start a domain configuration, a configuration section generally correspond to a server domain name server {listen 80; # # 80 listens to all IP in the machine, may be written as 192.168.1.202:80, this is the case, it only listens on the 192.168.1.202 80 server_name   www.heytool.com ; # Domain root /www/html/www.heytool.com; # site root directory (the program directory) index index.html index.htm; # index file location / {# There can be multiple location root / www / html / www .heytool.com; # root site (program catalog)} error_page 500 502 503 504 /50x.html ; # define error page, if the error is 500, 50x.html directory location put back to the user site root = / 50x.html {root /www/html/www.heytool.com;}} # {begin configuring the listen site Server 80 bbs.heytool.com; server_name   bbs.heytool.com ; Root /www/html/bbs.heytool.com; index index.html index.htm; # index file location / {root /www/html/bbs.heytool.com;} error_page 500 502 503 504 /50x.html; location = /50x.html {root /www/html/bbs.heytool.com;} }} Nginx start off # /usr/local/nginx-1.0.6/sbin/nginx // start nginx # / usr / local / accuracy # /usr/local/nginx-1.0.6/sbin/nginx -s reload nginx-1.0.6 / sbin / nginx -t // // test nginx configuration file reload nginx # / usr / local / nginx -1.0.6 / sbin / nginx -s stop // close nginx   test to create a test site # mkdir -p /www/html/www.heytool.com # mkdir -p /www/html/bbs.heytool.com # echo " www.heytool.com "> /www/html/www.heytool.com/index.html # echo" bbs.heytool.com "> /www/html/bbs.heytool.com/index.html   start nginx # /Usr/local/nginx-1.0.6/sbin/nginx -t // see ok and successful, illustrate the configuration file no problem nginx: the configuration file / usr / local / nginx-1.0.6 / conf / nginx. conf syntax is ok nginx: configuration file   / usr / local / nginx-1.0.6 / conf / nginx.conf test is successful # /usr/local/nginx-1.0.6/sbin/nginx bind hosts, test the two domain names point to 192.168.1.202 192.168.1.202 www.heytool.com 192.168.1.202 bbs.heytool.com open www.heytool.com , as shown below: open bbs.heytool.com, as shown below: finished! ! ! ! More Configuration Reference: http://www.docin.com/p-222277825.html reference video tutorial: http://www.kuaipan.cn/index.php?ac=file&oid=29331332391763978 article Recommended: Haproxy + keepalived achieve sphinx high-availability load balancing using sphinx haproxy to achieve load balancing and health monitoring of persistence installation configuration of a storage system ttserver  

Reproduced in: https: //my.oschina.net/766/blog/210902

Guess you like

Origin blog.csdn.net/weixin_33739627/article/details/91546650