Home >Backend Development >PHP Tutorial >Installation of linux nginx
Install gcc
First download
pcre-8.12.tar.gz
http://download.csdn.net/detail/qq_2292 9803/8771933
tar -zxvf pcre-8.21.tar.gz
cd pcre-8.21
./configure
make
make install
./configure prompts insufficient permissions If so, just use chmod 777 ./configureIf it prompts
configure:
error: in `/usr/local/src/pcre-8.12':configure: error: no acceptable C compiler found in $PATH
Then there is a lack of gcc
yum install gcc download 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
dCD/USR/LOCAL/
wget
Http://www.opensl.org/source/opensl-1.0.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz./config
make
make install
install nginx
Nginx generally has two versions, They are the stable version and the development version. You can choose one of these two versions according to your purpose. The following are the detailed steps to install Nginx into 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.gzcd 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 pcre-8.21.
--with-zlib=/usr/src/zlib-1.2.7 refers to the source code path of zlib-1.2.7.
6. Start
Make sure the system’s port 80 is not occupied by other programs,
/usr/local/nginx/sbin/nginx
Check if Successful startup:
netstat -ano|grep 80 If the result is entered, it means the startup is successful.
Open the browser to access the IP of this machine. If the browser displays "Welcome to nginx!", it means that Nginx has been installed and run successfully.
7. Restart u/usr/local/nginx/sbin/nginx —S RELOAD
8. Modify the configuration file
CD/USR/LOCAL/NGINX/Conf .Vi nginx.conf
9. Common configuration
#nginx Run users and groups
User www www;
#startup process, usually set to the number of CPUs is equal
worker_processes 4;
#Global error log and PID file
pid /var/run/nginx.pid;
error_log /var/log/nginx/error.log;
{Events {en #Epoll is a way in multi -way reuse IO (I/O Multiplexing), but only for the core of Linux2.6 and above, it can greatly improve the performance of Nginx
USE EPOLL ; 个#Single background Worker PROCESS process maximum concurrent link number
worker_connections 10240;
}
#Set HTTP server, use its reverse proxy function to provide load balancing support 00 403 500 502 503 504 /50x.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 1k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_buffers 4 16k;
gzip_proxied any;
gzip_disable "MSIE [1-6].";
gzip_types text/plain text/html text/css application/x-javascript application/xml application/xml+rss text/javascript;
#gzip_vary on;
server_name_in_redirect off;
#设定负载均衡的服务器列表
upstream portals {
server 172.16.68.134:8082 max_fails=2 fail_timeout=30s;
server 172.16.68.135:8082 max_fails=2 fail_timeout=30s;
server 172.16.68.136:8082 max_fails=2 fail_timeout=30s;
server 172.16.68.137:8082 max_fails=2 fail_timeout=30s;
}
#upstream overflow {
# server 10.248.6.34:8090 max_fails=2 fail_timeout=30s;
# server 10.248.6.45:8080 max_fails=2 fail_timeout=30s;
#}
server {
#侦听8080端口
listen 8080;
server_name 127.0.0.1;
#403、404页面重定向地址
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_timeout 180;
proxy_read_timeout 180;
proxy_buffer_size 64k;
proxy_buffers 4 128k;
proxy_busy_buffers_size 128k;
client_header_buffer_size 16k;
large_client_header_buffers 4 64k;
#proxy_send_timeout 3m;
#proxy_read_timeout 3m;
#proxy_buffer_size 4k;
#proxy_buffers 4 32k;
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 10m;
}
location = /check.html {
root /usr/local/nginx/html/;
access_log off;
}
location = /50x.html {
root /usr/local/nginx/html/;
expires 1m;
access_log off;
}
location = /index.html {
add_header Vary Accept-Encoding;
#定义服务器的默认网站根目录位置
root /data/web/html/ebiz;
expires 10m;
}
#定义反向代理访问名称
location ~ ^/ecps-portal/* {
# expires 10m;
#重定向集群名称
proxy_pass http://portals;
#proxy_pass http://172.16.68.134:8082;
}
location ~ ^/fetionLogin/* {
# expires 10m;
proxy_pass http://portals;
#proxy_pass http://172.16.68.134:8082;
}
#location ~ ^/business/* {
# # expires 10m;
# proxy_pass http://172.16.68.132:8088;
# #proxy_pass http://172.16.68.134:8082;
#}
location ~ ^/rsmanager/* {
expires 10m;
root /data/web/;
#proxy_pass http://rsm;
}
#定义nginx处理的页面后缀
location ~* (.*).(jpg|gif|htm|html|png|js|css)$ {
root /data/web/html/;
#页面缓存时间为10分钟
expires 10m;
}
#设定查看Nginx状态的地址
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 10m;
# root /data/web/html/;
# }
Location / {
root /data/web/html/sysMaintain/;
if ( !-f $request_filename) {
;
The above introduces the installation of linux nginx, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.