只需一步,快速开始
/root/lnmp stop /etc/init.d/nginx stop /etc/init.d/mysql stop /etc/init.d/redis_6379 stop /usr/local/php/sbin/php-fpm stop killall nginx mysqld redis php-cgi
mkdir -p ~/src && cd ~/src \cp -rf /usr/local/nginx/conf ~/src/conf.bak \cp -rf /etc/init.d/nginx ~/src/nginx.bak
wget http://zlib.net/zlib-1.2.8.tar.gz -O -|tar xz wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.32.tar.gz -O -|tar xz wget http://www.openssl.org/source/openssl-1.0.1e.tar.gz -O -|tar xz wget http://nginx.org/download/nginx-1.2.8.tar.gz -O -|tar xz git clone https://github.com/monadbobo/limit_req2_nginx_module
rm -rf /usr/local/nginx cd nginx-1.2.8/ ./configure --prefix=/usr/local/nginx \ --user=www --group=www \ --with-zlib=../zlib-1.2.8 \ --with-pcre=../pcre-8.32 \ --with-openssl=../openssl-1.0.1e \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-http_realip_module \ --with-http_ssl_module \ --with-ipv6 \ --add-module=../limit_req2_nginx_module \ --with-cc-opt='-O3' make && make install
cd ../ chkconfig nginx on rm -rf /usr/local/nginx/conf \cp -rf ~/src/conf.bak /usr/local/nginx/conf \cp -rf /usr/local/nginx/conf/nginx.conf /usr/local/nginx/conf/nginx.conf.bak
log_format lazyzhu.com '$remote_addr - $remote_user [$time_local] $request ' '$status $body_bytes_sent $http_referer ' '$http_user_agent $http_x_forwarded_for'; limit_req2_zone $request_uri zone=lazyzhu.com.one:2m rate=5r/s; limit_req2_zone $binary_remote_addr zone=lazyzhu.com.two:2m rate=30r/s; server { listen 80; server_name lazyzhu.com; root /home/wwwroot/lazyzhu.com; location / { index index.html index.htm index.php default.html default.htm default.php; } include none.conf; ## folder disable limit location ^~ /(wp-admin|admin)/ { limit_req2 off; try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fcgi.conf; } ## file disable limit location ~ .*(admin|p)\.(php|php5)?$ { limit_req2 off; try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fcgi.conf; } location ~ .*\.(php|php5)?$ { limit_req2 zone=lazyzhu.com.one forbid_action=@444 nodelay; limit_req2 zone=lazyzhu.com.two forbid_action=@444 nodelay; try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fcgi.conf; } location @444 { return 444; } location ~ .*\.(js|css)?$ { expires 12h; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location /status { stub_status on; access_log off; } access_log /home/wwwlogs/lazyzhu.com.log lazyzhu.com; }
/etc/init.d/nginx start /etc/init.d/mysql start /etc/init.d/php-fpm start
举报
本版积分规则 发表回复 回帖后跳转到最后一页
Archiver|手机版|小黑屋|全球主机交流论坛
GMT+8, 2025-9-25 00:10 , Processed in 0.222021 second(s), 12 queries , Gzip On, MemCache On.
Powered by Discuz! X3.4
© 2001-2023 Discuz! Team.