1. First use yum to install the plug-in required for nginx.
Yum-y install make zlib zlib-devel gcc-c++ libtool OpenSSL openssl-devel
Yum-y install gcc gcc-c++ autoconf automake
Yum-y install zlib zlib-devel OpenSSL openssl-devel pcre-devel
"Comment" Don't ask me why I installed these, because I'm doing it later./configure times the wrong hint is missing these components. The main and I need to install those modules and functional support has a relationship.
2, download the nginx-1.9.4 installation package, you can download to the official web surface.
Unzip, new Nginx user group and Nginx user, and set to not login.
TAR-ZXVF nginx-1.9.4.tar.gz
CD nginx-1.9.4
Groupadd-r Nginx
Useradd-s/sbin/nologin-g nginx-r Nginx
3, implementation./CONFIGURE Inspection Environment
./configure--prefix=/opt/nginx--sbin-path=/usr/sbin/nginx--conf-path=/opt/nginx/nginx.conf--error-log-path=/ Opt/nginx/logs/error.log--http-log-path=/opt/nginx/logs/access.log--pid-path=/opt/nginx/nginx.pid--lock-path=/ Var/run/nginx.lock--http-client-body-temp-path=/var/cache/nginx/client_temp--http-proxy-temp-path=/var/cache/ Nginx/proxy_temp--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp--http-uwsgi-temp-path=/var/cache/nginx/ Uwsgi_temp--http-scgi-temp-path=/var/cache/nginx/scgi_temp--user=nginx--group=nginx--with-http_ssl_module-- With-http_realip_module--with-http_addition_module--with-http_sub_module--with-http_dav_module--with-http_flv_ Module--with-http_mp4_module--with-http_gunzip_module--with-http_gzip_static_module--with-http_random_index_ Module--with-http_secure_link_module--with-http_stub_status_module--with-http_auth_request_module--with-mail-- With-mail_ssl_module--with-file-aio--with-ipv6--with-http_spdy_module--with-cc-opt= '-o2-g-pipE-wp,-d_fortify_source=2-fexceptions-fstack-protector--param=ssp-buffer-size=4-m64-mtune=generic '
"Comments" above parameters are mainly specified Nginx installation directory, start the command path, configuration file path, error log path, and you need to install the module, specific on the official website and on the internet has a description, here is not introduced.
4. Perform compilation and Installation
Make && make install
5.
CD Nginx
MV Nginx.conf Nginx.conf.bak #备份初始配置文件
[Email protected] ~]# cat/opt/nginx/nginx.conf #上传我自己的配置好的conf文件
#user nobody;
Worker_processes 1;
Error_log Logs/error.log;
Pid/opt/nginx/nginx.pid;
Worker_rlimit_nofile 65535;
Events {
Use Epoll;
Worker_connections 65535;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
Server_names_hash_bucket_size 128;
Client_header_buffer_size 32k;
Large_client_header_buffers 4 32k;
Sendfile on;
Tcp_nopush on;
Keepalive_timeout 65;
Fastcgi_connect_timeout 300;
Fastcgi_send_timeout 300;
Fastcgi_read_timeout 300;
Fastcgi_buffer_size 64k;
Fastcgi_buffers 4 64k;
Fastcgi_busy_buffers_size 128k;
Fastcgi_temp_file_write_size 128k;
gzip on;
Gzip_min_length 1k;
Gzip_buffers 4 16k;
Gzip_http_version 1.0;
Gzip_comp_level 2;
Gzip_types text/plain application/x-javascript text/css application/xml;
Gzip_vary on;
Client_max_body_size 300m;
Client_body_buffer_size 128k;
Proxy_connect_timeout 600;
Proxy_read_timeout 600;
Proxy_send_timeout 600;
Proxy_buffer_size 16k;
Proxy_buffers 4 32k;
Proxy_busy_buffers_size 54k;
Proxy_temp_file_write_size 64k;
Upstream hm.bioeh.com {
Server 192.168.2.11:8080 weight=10 max_fails=2 fail_timeout=30s;
Server 192.168.2.12:8080 weight=10 max_fails=2 fail_timeout=30s;
}
Upstream Doctor_server_pool {
Server 192.168.2.11:8081 weight=10 max_fails=2 fail_timeout=30s;
Server 192.168.2.12:8081 weight=10 max_fails=2 fail_timeout=30s;
}
server {
Listen 80;
server_name hm.bioeh.com;
CharSet Utf-8;
location/bsp/{
root HTML;
Index index.html index.htm;
Proxy_pass http://hm.bioeh.com;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $remote _addr;
Client_max_body_size 100m;
}
location/doctor/{
root HTML;
Index index.html index.htm;
Proxy_pass Http://doctor_server_pool;
Proxy_set_header X-real-ip $remote _addr;
Proxy_redirect off;
Proxy_set_header Host $host;
Proxy_set_header X-real-ip $remote _addr;
Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
Client_max_body_size 100m;
}
}
}
Nginx-c nginx.conf #检查配置文件
Mkdir-p/var/cache/nginx/client_temp #提示有错误, you need to create this directory
Nginx-c nginx.conf #再次检查配置文件, no problem.
6. Start Nginx
#nginx
# Netstat-tulnp|grep 80
TCP 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 14263/nginx
The "note" 80 port exists, indicating that the service started successfully, also Telnet IP 80 view, or access directly in the browser.
CentOS 6.5 Installation Quick Install deployment nginx-1.9.4