From now on, learn nginx # install pcre [root @ svr3 ~] #Tar-xjfpcre-8.02.tar.bz2-C/usr/src/[root @ svr3 ~] # Cd/usr/src/pcre-8.02/[root@svr3pcre-8.02] #./configure & amp; make
Learn nginx from now on
# Install pcre
[Root @ svr3 ~] # Tar-xjf pcre-8.02.tar.bz2-C/usr/src/
[Root @ svr3 ~] # Cd/usr/src/pcre-8.02/
[Root @ svr3 pcre-8.02] #./configure & make install
# Install nginx
[Root @ svr3 ~] # Useradd-M-s/sbin/nologin nginx
[Root @ svr3 ~] # Tar-xzf nginx-1.0.5.tar.gz-C/usr/src/
[Root @ svr3 ~] # Cd/usr/src/nginx-1.0.5/
[Root @ svr3 nginx-1.0.5] #./configure -- prefix =/usr/local/nginx -- user = nginx -- group = nginx
[Root @ svr3 nginx-1.0.5] # make & make install
[Root @ svr3 ~] # Vim/usr/local/nginx/conf/nginx. conf
++ ++
User nginx; # Use nginx
Worker_processes 1; # Number of processes initialized after the program is started; if there are many kernels, you can set the number of kernels.
# Error_log logs/error. log;
# Error_log logs/error. log notice;
Error_log logs/error. log info; # set the error log record level
Pid logs/nginx. pid; # When restarting and disabling nginx, you need to know the pid file.
Worker_rlimit_nofile 51000;
#
Events {
Worker_connections 50000; # number of connections allowed. I will set 50000 connections here.
}
Http {
Include mime. types;
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;
Sendfile on;
Tcp_nopush on;
# Keepalive_timeout 0;
Keepalive_timeout 30;
Gzip on; # Allow gzip compression.
Gzip_buffers 32 4 k;
Gzip_comp_level 1;
Gzip_min_length 1024;
Gzip_types text/html text/css application/xml;
Server {
Listen 80;
Server_name localhost;
# Charset KOI8-R;
Access_log logs/host. access. log main;
Location /{
Root html; # directory
Index index.html index.htm; # index type
}
# Error_page 404/404 .html;
# Redirect server error pages to the static page/50x.html
#
Error_page 500 502 503 x.html;
Location =/50x.html {
Root html;
}
# Here is the forwarding part.
# Proxy the PHP scripts to Apache listening on 127.0.0.1: 80
#
# Location ~ \. Php $ {
# Proxy_pass http: // 127.0.0.1;
#}
# Fastcgi
# Pass the PHP scripts to FastCGI server listening on Fig: 9000
#
# Location ~ \. Php $ {
# Root html;
# Fastcgi_pass 127.0.0.1: 9000;
# 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
Part of the VM
}
++ ++
Now configure a host and modify the following content:
Server {
Listen 80;
Server_name svr3.labexam.com 10.1.1.30;
# Charset KOI8-R;
Access_log logs/w1.access. log combined;
Location /{
Root/var/www/w1;
Index index.html index.htm;
}
# Read the log
[Root @ svr3 nginx] # tail/usr/local/nginx/logs/w1.access. log
10.1.1.8--[15/Aug/2011: 02: 21: 50 + 0800] "GET/HTTP/1.1" 200 8 "-" "Opera/9.80 (Windows NT 5.1; u; zh-cn) Presto/2.9.168 Version/11.50"
10.1.1.8--[15/Aug/2011: 02: 21: 50 + 0800] "GET/favicon. ico HTTP/1.1 "404 142" http://svr3.labexam.com/"" Opera/9.80 (Windows NT 5.1; U; zh-cn) Presto/2.9.168 Version/11.50"
==> How to Start nginx? <假定nginx安装在 usr local nginx中>
Method 1: Run/usr/local/nginx/sbin/nginx-t to check whether the configuration file is correct! Or directly execute/usr/local/nginx/sbin/nginx
If there are multiple configuration files, you can use the specified configuration file to start:
#/Usr/local/nginx/sbin/nginx-c/usr/local/nginx/conf/nginx. conf
==> Nginx signal control:
Quickly disable TERM and INT
Close QUIT
Restart HUP and reload the configuration file
USR1 restarts and opens the log, which is of great use in log cutting.
USR2 smooth upgrade executable program
WINCH calmly closes the process
This article is from the "diving into the ocean of technology" blog