NginxV1.8.0 installation and configuration, nginxv1.8.0 Configuration
1. Install related support libraries:
Yum-y install gcc-c ++ autoconf
Yum-y install openssl-devel
Pcre: To rewrite, zlib: For gzip compression, ngx_pagespeed plug-in: front-end webpage access speed-up optimization plug-in
(1) pcre installation:
Wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz
Tar-zxvf pcre-8.36.tar.gz
Cd pcre-8.36
./Configure
Make & make install
Cd ../
Ln-s/usr/local/lib/libpcre. so.1/lib64/
(2) zlib installation:
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
Cd ../
(3) openssl installation:
Wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
Tar-zxvf openssl-1.0.1c.tar.gz
Cd openssl-1.0.1c
./Config
Make & make install
Cd ../
(4) install pagespeed:
Wget https://github.com/pagespeed/ngx_pagespeed/archive/v1.8.31.4-beta.tar.gz
Wget https://dl.google.com/dl/page-speed/psol/1.8.31.4.tar.gz
Tar-zxvf v1.8.31.4-beta.tar.gz
Cp 1.8.31.4.tar.gz./ngx_pagespeed-1.8.31.4-beta
Cd ngx_pagespeed-1.8.31.4-beta
Tar-xzvf 1.8.31.4.tar.gz
Ii. Install nginx
Create special users and user groups:
/Usr/sbin/groupadd www
/Usr/sbin/useradd-g www
Ulimit-SHn 65535
Wget http://nginx.org/download/nginx-1.8.0.tar.gz
Tar-zxvf nginx-1.8.0.tar.gz
Cd nginx-1.8.0
./Configure-user = www \
-Prefix =/usr/local/nginx \
With-http_ssl_module \
With-http_stub_status_module \
With-http_realip_module \
-Add-module =/home/yq/ ngx_pagespeed-1.8.31.4-beta
Make & make install
3. Related configuration files:
1. nginx. conf
User www;
Worker_processes 4;
Error_log/var/log/nginx/error. log;
Pid/var/run/nginx. pid;
Events {
Use epoll;
Worker_connections 1024;
}
Http {
Upstream tomcat7 {
Server 127.0.0.1: 8090;
}
Upstream fdfs {
Server 192.168.77.32: 8888;
}
Pagespeed On;
Pagespeed FileCachePath "/var/cache/ngx_pagespeed /";
Pagespeed EnableFilters combine_css, combine_javascript;
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 65;gzip on;gzip_min_length 1000;gzip_buffers 4 16k;gzip_http_version 1.1;gzip_types text/plain application/x-javascript text/css application/xml; include vhost.conf; include vhost/*;
}
Vhost. conf is the default Project, which is a virtual machine configuration,
Server {
Listen 80;
Server_name localhost;
#charset koi8-r; #access_log logs/host.access.log main; location / { root html; index index.html index.htm; } #error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }}
The following describes a typical Virtual Machine Configuration:
Test. conf
Server {
Listen 80;
Server_name test.qq.cn;
#charset koi8-r;#access_log logs/host.access.log main;proxy_set_header REMOTE-HOST $remote_addr;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_connect_timeout 30;proxy_read_timeout 60;proxy_buffer_size 4k;proxy_buffers 4 32k;proxy_busy_buffers_size 64k;proxy_temp_file_write_size 64k;proxy_max_temp_file_size 128m;proxy_set_header Host $host;proxy_pass_header User-Agent; location / {proxy_pass http://tomcat7;}location /assets { root html;index index.html;}#error_page 404 /404.html;# redirect server error pages to the static page /50x.html#error_page 500 502 503 504 /50x.html;location = /50x.html { root html;}
}