Nginx Installation Manual

Source: Internet
Author: User
Wgethttp: // response/

 

 

Wget http://nginx.org/download/nginx-1.0.4.tar.gz

1. install

Install it on/usr/local/nginx by default

 

Tar-zxvf nginx-1.0.4.tar.gz

Cd nginx-1.0.4

./Configure

Make; make install

 

2. run

 

/Usr/local/nginx/sbin/nginx

# Note: nginx uses port 80 by default. if port 80 is occupied, modify

Server {

Listen 80;

 

3. test

 

Echo "test123">/usr/local/nginx/html/index.html

Wget http: // 127.0.0.1

4. basic commands

 

/Usr/local/nginx/sbin/nginx-h # Help

/Usr/local/nginx/sbin/nginx-v # display version

/Usr/local/nginx/sbin/nginx-V # display version and configuration information

/Usr/local/nginx/sbin/nginx-t # test configuration

/Usr/local/nginx/sbin/nginx-q # Only error messages are output during configuration testing.

/Usr/local/nginx/sbin/nginx-s stop # stop the server

/Usr/local/nginx/sbin/nginx-s reload # reload configuration

/Usr/local/nginx/sbin/nginx-s quit # I do not know. it is estimated that it is similar to stop.

/Usr/local/nginx/sbin/nginx-s reopen # unknown. it is estimated that it is similar to reload.

/Usr/local/nginx/sbin/nginx-p/nginx/path # The default value is/usr/local/nginx (nginx installation path). after modification, the log directory and html directory are affected.

/Usr/local/nginx/sbin/nginx-c/configure/file/path # path of the configuration file, conf/nginx by default. conf, which is useful when multiple configuration files exist. you can use this to start multiple different nginx listeners for different ports.

/Usr/local/nginx/sbin/nginx-g # never used

5. configuration

The configuration file is in the installation directory/conf/nginx. conf.

After modification, use/usr/local/nginx/sbin/nginx-s reload to reload

 

# User nobody; # when starting nginx, you must have the permission to execute fastcgi when configuring fastcgi.

Worker_processes 1; # Number of processes started by nginx. one is sufficient.

# Error_log logs/error. log; # compare with/usr/local/nginx/

# Error_log logs/error. log notice; # compare with/usr/local/nginx/, nginx logs can be changed to logs/notice. log

# Error_log logs/error. log info; # compared with/usr/local/nginx/, the nginx record Information log can be changed to logs/info. log.

# Pid logs/nginx. pid; # nginx process file, preferably not modified

Events {

Worker_connections 1024; # the maximum number of nginx connections, preferably smaller than the maximum number of system sockets and the number of opened files

}

Http {

Include mime. types; # see mime. types in the same directory to generate an http header based on the file suffix.

Default_type application/octet-stream;

# Log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request "'

# '$ Status $ body_bytes_sent "$ http_referer "'

# '"$ Http_user_agent" "$ http_x_forwarded_for "';

# Access_log logs/access. log main; # access log

Sendfile on;

# Tcp_nopush on;

# Keepalive_timeout 0;

Keepalive_timeout 65; # Keep connection time, in seconds

# Gzip on;

Server {

Listen 80; # listening port

Server_name localhost; # Server Name

# Charset KOI8-R; # Default Character set

# Access_log logs/host. access. log main; # Generate the corresponding access log based on the access domain name

Location /{

Root html; # root directory, relative to the installation directory

Index index.html index.htm; # default homepage

}

# Error_page 404/404 .html; # Error page

# Redirect server error pages to the static page/50x.html

#

Error_page 500 502 503 x.html;

Location =/50x.html {

Root html;

}

# Proxy the PHP scripts to Apache listening on 127.0.0.1: 80

#

# Location ~ \. Php $ {

# Proxy_pass http: // 127.0.0.1;

#}

# Pass the PHP scripts to FastCGI server listening on Fig: 9000

#

# Location ~ \. Php $ {

# Root html;

# Fastcgi_pass 127.0.0.1: 9000; # forward to Port 9000 for processing

# Fastcgi_index index. php;

# Fastcgi_param SCRIPT_FILENAME/scripts $ fastcgi_script_name;

# Include fastcgi_params;

#}

# Deny access to. htaccess files, if Apache's document root

# Concurs with nginx's one

#

# Location ~ /\. Ht {

# Deny all;

#}

}

# Another virtual host using mix of IP-, name-, and port-based configuration

#

# Server {

# Listen 8000;

# Listen somename: 8080;

# Server_name somename alias another. alias;

# Location /{

# Root html;

# Index index.html index.htm;

#}

#}

# HTTPS server

#

# Server {

# Listen 443;

# Server_name localhost;

# Ssl on;

# Ssl_certificate cert. pem;

# Ssl_certificate_key cert. key;

# Ssl_session_timeout 5 m;

# Ssl_protocols SSLv2 SSLv3 TLSv1;

# Ssl_ciphers ALL :! ADH :! EXPORT56: RC4 + RSA: + HIGH: + MEDIUM: + LOW: + SSLv2: + EXP;

# Ssl_prefer_server_ciphers on;

# Location /{

# Root html;

# Index index.html index.htm;

#}

#}

}

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.