CentOS installation nginx


In order to build the Linux environment conveniently and quickly, I have these words

  1. CentOS install JDK using Yum or up2date
  2. CentOS install Tomcat
  3. CentOS installation nginx
  4. CentOS install MySQL

1. Preparation before installing nginx
Please confirm whether the GCC G + + development class library is installed.

Yum - y install GCC automake Autoconf libtool make
Yum install gcc-c + + (install G + +)

2. Download nginx and its components

cd /usr/local/src

Install OpenSSL

wget  http://www.openssl.org/source/openssl-fips-2.0.16.tar.gz (download OpenSSL)
tar -zxvf openssl-fips-2.0.16.tar.gz
cd  openssl-fips-2.0.16
./configure && make && make install

Install PCRE

wget  ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.42.tar.gz (download PCRE)
tar -zxvf pcre-8.42.tar.gz
cd pcre-8.42
./configure && make && make install

Install zlib

wget  http://zlib.net/zlib-1.2.11.tar.gz (download zlib)
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure && make && make install

Or install OpenSSL, PCRE and zlib using Yum or up2date

yum -y install openssl openssl-devel
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel

Installing nginx

wget  http://nginx.org/download/nginx-1.15.0.tar.gz (download nginx)
tar -zxvf nginx-1.15.0.tar.gz
cd nginx-1.15.0
./configure && make && make install

3. Start nginx

CD / usr / local / nginx / SBIN / (enter nginx installation directory)
. / nginx (start command)
Error message: / usr / local / nginx / SBIN / nginx: error while loading shared libraries: 
libpcre.so.1: cannot open shared object file: No such file or directory
Where is libpcre. So. 1 (check the installation location of libpcre. So. 1)
Location information: libpcre.so: / lib64 / libpcre. So.0 / usr / local / lib / libpcre. So.1 / usr / local / lib / libpcre.so
Ln - S / usr / local / lib / libpcre.so.1 / lib64 (just add a soft link and start again)

4. Modify the nginx configuration file, configure the domain name, and add a reverse proxy to point to Tomcat

vi /usr/local/nginx/conf/nginx.conf

Add the domain name to point to the server, and modify the first server to the following configuration:

    server {
        listen       80;
        server_name  coder7911.club;
        location / {

5. Nginx common related commands

./nginx -t
./nginx -s relaod
ps -ef|grep nginx
Kill - 9 process number
tail -f /usr/local/nginx/logs/access.log