Installation and use of nginx in linux system
Preparation: # yum install gcc gcc-cpp gcc-c++ Install pcre (Let nginx support rewrite) # tar zxvf pcre-8.01.tar.gz # cd pcre-8.01/ # ./configure # make && make install Installation and activation # tar zxvf nginx-1.0.4.tar.gz # cd nginx-1.0.4 # ./configure –prefix=/usr/local/nginx –with-http_gzip_static_module –with-http_flv_module –http-proxy-temp-path=/var/tmp/nginx/proxy/ # make && make install start # /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf stop # kill – QUIT Nginx main process number reboot # kill -HUP Nginx main process ID Common configuration If installed as above, the nginx configuration file is located at /local/usr/nginx/conf/nginx.conf. The configuration file structure of nginx.conf mainly consists of the following parts: …… envents { … } http { … server{ … } server{ … } … } Note: In the following configurations, the position of the modified content will be named with the name before the above curly braces. If the configuration content is modified in the server, it will be described as “what to look for in the server block, why to modify or what to add, etc.”. 1. Set the listening port, domain name and root directory In the server block of the configuration file, make corresponding settings. listen 80; server_name www.domain.com; root /var/www/domain.com; index index.php index.html index.htm Modify listen and server_name to…