Centos6.8 install nginx (1) and centos6.8 install nginx
Here, we will record the installation of nginx in detail.
1. Install gcc-c ++ in yum:
yum install -y gcc gcc-c++ [enter]
2. Download required dependent libraries: zlib, openssl, and pcre
wget http://nginx.org/download/nginx-1.11.13.tar.gz [enter]wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz [enter]wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.21.tar.gz [enter]wget http://www.zlib.net/zlib-1.2.11.tar.gz [enter]
3. Install dependency libraries: zlib, openssl, and pcre
Tar xvf nginx-1.11.13.tar.gz [enter] tar xvf openssl-1.1.0e.tar.gz [enter] tar xvf pcre2-10.21.tar.gz [enter] tar xvf zlib-1.2.11.tar.gz [enter] cd. /nginx-1.11.13 [enter]. /configure -- prefix =/usr/local/nginx -- with-pcre = .. /pcre2-10.21 -- with-openssl = .. /openssl-1.1.0e -- with-zlib = .. /zlib-1.2.11 [enter] make [enter] make install [enter] Note: The -- with option points to the source code path.
4. Modify the Configuration:
vi /usr/local/nginx/conf/nginx.conf [enter]
Note the following:
upstream test { server 127.0.0.1:18087; server 127.0.0.1:28087; }server { listen 80; server_name localhost; charset utf-8; location /test { root html; index index.html index.htm; proxy_pass http://test; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }}
5. Check whether the configuration is correct:
/usr/local/nginx/sbin/nginx -t [enter]
The following information is correct:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
6. Start:
Start:/usr/local/nginx/sbin/nginx [enter] restart:/usr/local/nginx/sbin/nginx-s reload [enter]
7. Access:
Installed successfully!
Record it here first, and then add in detail ^_^ ~