: This article describes how to install linuxnginx. if you are interested in the PHP Tutorial, refer to it. Install gcc
Yum install gcc-c ++
First Download
Pcre-8.12.tar.gz
Http://download.csdn.net/detail/qq_22929803/8771933
Tar-zxvf pcre-8.21.tar.gz
Cd pcre-8.21
./Configure
Make
Make install
If you are prompted that the permission is insufficient in./configure, use chmod 777./configure.
If the prompt is displayed at./configure
Configure: error: in '/usr/local/src/pcre-8.12 ':
Configure: error: no acceptable C compiler found in $ PATH
The gcc is missing.
Download gcc from yum install gcc
Install zlib library
Cd/usr/local/
Wget http://zlib.net/zlib-1.2.8.tar.gz
Tar-zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8
./Configure
Make
Make install
Install ssl
Cd/usr/local/
Wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
Tar-zxvf openssl-1.0.1c.tar.gz
./Config
Make
Make install
Install nginx
Nginx generally has two versions: stable version and development version. you can select one of these two versions based on your purpose, the following describes how to install Nginx in the/usr/local/nginx Directory:
Cd/usr/local/
Wget http://nginx.org/download/nginx-1.2.8.tar.gz
Tar-zxvf nginx-1.2.8.tar.gz
Cd nginx-1.2.8
./Configure -- prefix =/usr/local/nginx -- with-pcre =/usr/local/src/pcre-8.12 -- with-http_ssl_module -- with-openssl =/usr/local/src/openssl-1.0.1c
Make
Make install
-- With-pcre =/usr/src/pcre-8.21 refers to the source code path of the pcre-8.21.
-- With-zlib =/usr/src/zlib-1.2.7 refers to the source code path of the zlib-1.2.7.
6. start
Make sure that Port 80 of the system is not occupied by other programs,
/Usr/local/nginx/sbin/nginx
Check whether startup is successful:
Netstat-ano | grep 80 indicates that the startup is successful.
Open the browser to access the IP address of this machine. if the browser displays Welcome to nginx! Nginx has been installed and runs successfully.
7. restart
/Usr/local/nginx/sbin/nginx-s reload
8. modify the configuration file
Cd/usr/local/nginx/conf
Vi nginx. conf
9. Common configurations
# Nginx running Users and Groups
User www;
# Start the process. generally, it is set to be equal to the number of CPUs
Worker_processes 4;
# Global error logs and PID files
Pid/var/run/nginx. pid;
Error_log/var/log/nginx/error. log;
Events {
# Epoll is a method in Multiplexing I/O Multiplexing, but it is only used in Linux or later kernels, which can greatly improve nginx performance.
Use epoll;
# Maximum number of concurrent connections of a single backend worker process
Worker_connections 10240;
}
# Set the http server and use its reverse proxy function to provide load balancing support
Http {
Include mime. types;
Default_type application/octet-stream;
Error_page 400 403 500 502 503 x.html;
Index index.html index.shtml
Autoindex off;
Fastcgi_intercept_errors on;
Sendfile on;
# These are good default values.
Tcp_nopush on;
Tcp_nodelay off;
# Output compression saves bandwidth
Gzip off;
# Gzip_static on;
# Gzip_min_length 1 k;
Gzip_http_version 1.0;
Gzip_comp_level 2;
Gzip_buffers 4 16 k;
Gzip_proxied any;
Gzip_disable "MSIE [1-6] \.";
Gzip_types text/plain text/html text/css application/x-javascript application/xml + rss text/javascript;
# Gzip_vary on;
Server_name_in_redirect off;
# Set the server list of server load balancer
Upstream portals {
Server 172.16.68.134: 8082 max_fails = 2 fail_timeout = 30 s;
Server 172.16.68.135: 8082 max_fails = 2 fail_timeout = 30 s;
Server 172.16.68.136: 8082 max_fails = 2 fail_timeout = 30 s;
Server 172.16.68.133: 8082 max_fails = 2 fail_timeout = 30 s;
}
# Upstream overflow {
# Server 10.248.6.34: 8090 max_fails = 2 fail_timeout = 30 s;
# Server 10.248.6.45: 8080 max_fails = 2 fail_timeout = 30 s;
#}
Server {
# Listening on port 8080
Listen 8080;
Server_name 127.0.0.1;
#403 and 404 page redirection addresses
Error_page 403 = http://www.e100.cn/ebiz/other/217/403.html;
Error_page 404 = http://www.e100.cn/ebiz/other/218/404.html;
Proxy_connect_timeout 90;
Proxy_send_timeouts 180;
Proxy_read_timeout 180;
Proxy_buffer_size 64 k;
Proxy_buffers 4 128 k;
Proxy_busy_buffers_size 128 k;
Client_header_buffer_size 16 k;
Large_client_header_buffers 4 64 k;
# Proxy_send_timeout 3 m;
# Proxy_read_timeout 3 m;
# Proxy_buffer_size 4 k;
# Proxy_buffers 4 32 k;
Proxy_set_header Host $ http_host;
Proxy_max_temp_file_size 0;
# Proxy_hide_header Set-Cookie;
# If ($ host! = 'Www .e100.cn '){
# Rewrite ^/(. *) $ http://www.e100.cn/#1 permanent;
#}
Location /{
Deny all;
}
Location ~ ^/Resource/res/img/blue/space.gif {
Proxy_pass http: // tecopera;
}
Location = /{
Rewrite ^ (. *) $/ebiz/event/517.html last;
}
Location =/ebiz/event/517.html {
Add_header Vary Accept-Encoding;
Root/data/web/html;
Expires 10 m;
}
Location =/check.html {
Root/usr/local/nginx/html /;
Access_log off;
}
Location =/50x.html {
Root/usr/local/nginx/html /;
Expires 1 m;
Access_log off;
}
Location =/index.html {
Add_header Vary Accept-Encoding;
# Define the default website root directory location of the server
Root/data/web/html/ebiz;
Expires 10 m;
}
# Define the reverse proxy access name
Location ~ ^/Ecps-portal /*{
# Expires 10 m;
# REDIRECT cluster name
Proxy_pass http: // portals;
# Proxy_pass http: // 172.16.68.134: 8082;
}
Location ~ ^/FetionLogin /*{
# Expires 10 m;
Proxy_pass http: // portals;
# Proxy_pass http: // 172.16.68.134: 8082;
}
# Location ~ ^/Business /*{
# Expires 10 m;
# Proxy_pass http: // 172.16.68.132: 8088;
# Proxy_pass http: // 172.16.68.134: 8082;
#}
Location ~ ^/Rsmanager /*{
Expires 10 m;
Root/data/web /;
# Proxy_pass http: // rsm;
}
# Define the page suffix for nginx processing
Location ~ * (. *) \. (Jpg | gif | htm | html | png | js | css) $ {
Root/data/web/html /;
# The page cache time is 10 minutes.
Expires 10 m;
}
# Set the address for viewing Nginx status
Location ~ * ^/NginxStatus /{
Stub_status on;
Access_log off;
Allow 10.1.252.126;
Allow 10.248.6.49;
Allow 127.0.0.1;
Deny all;
}
# Error_page 405 = 200 @ 405;
# Location @405
#{
# Proxy_pass http: // 10.248.6.45: 8080;
#}
Access_log/data/logs/nginx/access. log combined;
Error_log/data/logs/nginx/error. log;
}
Server {
Listen 8082;
Server_name _;
Location =/check.html {
Root/usr/local/nginx/html /;
Access_log off;
}
}
Server {
Listen 8088;
Server_name _;
Location ~ ^ /*{
Root/data/web/b2bhtml /;
Access_log off;
}
}
Server {
Listen 9082;
Server_name _;
# Location ~ ^/Resource /*{
# Expires 10 m;
# Root/data/web/html /;
#}
Location /{
Root/data/web/html/sysMaintain /;
If (! -F $ request_filename ){
Rewrite ^/(. *) $/sysMaintain.html last;
}
}
}
The above introduces the installation of linux nginx, including some content, and hope to be helpful to friends who are interested in the PHP Tutorial.