Nginx User Guide

Source: Internet
Author: User

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.pngThen, nginx returns the example.png image under/data/images/in the file directory to the client.

If I accesshttp://localhost/some/example.htmlNginx 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/nginxThe following log filesaccess.logAnderror.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.htmL The accessed resources are actuallyhttp://localhost/some/example.htmlResources obtained, which are transparent to the client.

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.