Nginx User Guide
1. Run nginx
You can run the nginx command to enable nginx:
Nginx
If nginx is enabled, run the nginx command and add the-s parameter to control nginx running.
nginx -s signal
Signal Value:
stop
-Close quickly
quit
-Elegant Shutdown
reload
-Reload the configuration file.
reopen
-Reopen the log file.
For example, you can use the following command to disable nginx after nginx finishes processing the current request.
nginx -s quit
After modifying the configuration file, run the following command:
Nginx-s reload
2. Simple nginx Configuration
Open the configuration file, usually in/etc/nginx. cnf, depending on your own installation parameters.
Nginx. conf already contains a server block configuration case, but it is commented out. Below is the basic configuration of a server Block
http { server { }}
Server block, you can configure some locations to specify the local resources corresponding to the request url.
location / { root /data/www;}
The above indicates that all access resources under/are under the/data/www folder.
location /images/ { root /data;}
This indicates that all images accessed by the/images/path are under/data.
The preceding unified configuration is
server {
listen 8080;
location / { root /data/www; }
location /images/ { root /data; }
}
If I accesshttp://localhost/images/example.png
Then, nginx returns the example.png image under/data/images/in the file directory to the client.
If I accesshttp://localhost/some/example.htm
l
Nginx returns the example.html image under/data/www/in the file directory to the client.
Listen can be left unspecified. The default value is 8080.
If the configuration is modified during running
nginx -s reload
If the configuration is verified, but the specified file is not accessed as agreed, you can view/usr/local/nginx/logs
Or/var/log/nginx
The following log filesaccess.log
Anderror.log
-------------------------------------- Split line --------------------------------------
Deployment of Nginx + MySQL + PHP in CentOS 6.2
Build a WEB server using Nginx
Build a Web server based on Linux6.3 + Nginx1.2 + PHP5 + MySQL5.5
Performance Tuning for Nginx in CentOS 6.3
Configure Nginx to load the ngx_pagespeed module in CentOS 6.3
Install and configure Nginx + Pcre + php-fpm in CentOS 6.4
Nginx installation and configuration instructions
Nginx log filtering using ngx_log_if does not record specific logs
-------------------------------------- Split line --------------------------------------
3. Configure reverse proxy
server { location / { proxy_pass http://localhost:8080; } location /images/ { root /data; }}
Proxy_pass specifies the reverse proxy path. All the paths that match the/will go to http: // localhost: 8080 to obtain resources.
For example:http://192.168.1.100/some/example.htm
L The accessed resources are actuallyhttp://localhost/some/example.htm
l
Resources obtained, which are transparent to the client.
For more details, please continue to read the highlights on the next page: