Hide version numberThe version number is not hidden. To improve security, the version number needs to be hidden. Hiding version number experiment cd /usr/local/nginx/ ### Edit the configuration file vim conf/nginx.conf Modify User GroupThe main process uses root, and the subprocess uses the nginx user vim conf/nginx.conf ### Specify user group user nginx nginx; Set cache time ### Modified configuration file vim conf/nginx.conf Log cuttingBelow is the log splitting script #!/bin/bash day=$(date -d "-1 day" "+%Y%m%d") logs_path="/var/log/nginx" pid_path="/usr/local/nginx/logs/nginx.pid" [ -d $logs_path ] || mkdir -p $logs_path mv /usr/local/nginx/logs/access.log ${logs_path}/access.log-$day kill -USR1 $(cat $pid_path) find $logs_path -mtime +30 -exec rm -rf {} \; #### Use the log segmentation script to automatically segment the log every day chmod +x /opt/jiaoben.sh crontab -e 0 1 * * * /opt/jiaoben.sh Achieving high concurrency by changing the number of CPU cores ### Check the number of CPUs cat /proc/cpuinfo | grep -c "physical id" ### Change the configuration file. The number of cores needs to correspond to your computer. vim conf/nginx.conf ### After setting, you need to restart the service. Configure web page compression Configuring hotlink protection ~* \.(jpg|gif|swf)$ : This regular expression matches case-insensitive image formats. walid_referers: specifies the trusted domain name. optimizationThis can be optimized by the following code vim /usr/local/php/etc/php-fpm.d/www.conf --96 lines-- pm = dynamic #fpm process startup mode, dynamic --107 lines-- pm.max_children=20 #The maximum number of processes started by the fpm process--112 lines-- pm.start_servers = 5 #The default number of processes started when starting in dynamic mode is between the minimum and maximum --117 lines-- pm.min_spare_servers = 2 #Minimum number of idle processes in dynamic mode --122 lines-- pm.max_spare_servers = 8 #Maximum number of idle processes in dynamic mode kill -USR2 `cat /usr/local/php/var/run/php-fpm.pid` #Restart php-fpm netstat -anpt | grep 9000 The above is the details of Nginx anti-hotlink and optimization in Linux. For more information about Nginx anti-hotlink and optimization, please pay attention to other related articles on 123WORDPRESS.COM! You may also be interested in:
|
<<: When MySQL is upgraded to 5.7, WordPress reports error 1067 when importing data
>>: Essential tools for web design: Firefox Web Developer plugin CSS tool set tutorial
Normally, when a deadlock occurs, the connection ...
Part 1: Basics 1. Unlike pseudo-classes such as :...
1. Introduction pt-query-digest is a tool for ana...
The Linux command line provides many commands to ...
1. All tags must have a corresponding end tag Prev...
Install zip decompression function under Linux Th...
Table of contents Features Advantages Installatio...
Table of contents Preface text parameter example ...
In fact, it is not difficult to build an Apache c...
<br />Original text: http://andymao.com/andy...
In front-end projects, attachment uploading is a ...
This is a very simple pure CSS3 white cloud float...
Preface Here are the steps to install and configu...
Table of contents Common array methods concat() M...
Detailed Analysis of Iframe Usage <iframe frame...