During the first day of study, we have contacted the installation and use of Nginx under the Windows system, which is relatively simple. But in our work, more contact is Nginx installed under the Linux system. Let ’s come together below. Take a look at the installation process of Nginx under the Linux system;
-
CentOS 6.5
-
Oracle VM VirtualBox (Run Centos 6.5 System)
-
nginx-1.12.2
-
Xshell 5
nginx official website, choose to download the stable version;
Note: We put the installation package in/usr/local/src/directory, nginx is installed in/usr/local/directory, and the command determines ./configure -prefix =/usr/local/nginxx
cd /usr/local/src/
execute the command wett, download the nginx compressed package;
View directory, we found that the Nginx compressed package has been successfully downloaded;
# 9 9
Tar ZXVF nginx-1.12.2.tar.gz
After decompression is completed, as shown below
First, enter the Nginx directory
execute the following command: mainly to match the directory of Nginx configuration files and log files
# Configure command
./configure -Prefix =/usr/local/nginx
We found an error. This is because installing NGINX needs to compile the source code downloaded on the official website first, compile dependent GCC environment, if there is no GCC environment, you need to install:
execute the following command:
yum -y install gcc gcc-c++ autoconf automake make
GCC environment installation is completed, we re -execute the configuration command ./configure -prefix =/usr/local/nginx, and find that the following errors are reported;
PCRE (Perl Composition Regular Expressions) is a Perl library, including Perl compatible regular expression library. Nginx’s HTTP module uses PCRE to analyze the regular expression, so you need to install the PCRE library on Linux. PCRE-Devel is a secondary development library developed using PCRE development. Nginx also needs this library.
execute the following command:
yum install -y pcre pcre-devel
PCRE library installation is completed, we execute a configuration command once,./Configure -prefix =/usr/local/nginx, and found that the following errors were reported again;
The
ZLIB library provides many ways to compress and decompress. Nginx uses ZLIB to use the content of the HTTP package for GZIP, so you need to install the ZLIB library on the CentOS.
execute the following command:
yum install -y zlib zlib-devel
Finally, we are executing a configuration command at a time and found a successful configuration
Enter /usr/src/nginx-1.12.2 Nginx directory under directory
execute the following command
make && make install
compilation and installation complete:
At this point, the installation of Nginx is completed!
Enter the directory/usr/local/nginx, and find that there are four directory (the first leakage is leaked, and the path will be a bit out in the back)
Enter the directory/usr/local/nginx
Note: We are decompressed in the/usr/local/src directory, but we are not installed in the src directory, but the Local directory;
execute the following command:
./sbin/nginx
According to the error message in the figure, we found that port 80 has been occupied;
Next, we checked what it took over 80 ports, and then kill dropped it;
execute the following command:
# Find port
netstat -NTP
We found that the Nginx process occupied, so let’s close and restart
execute the following command:
# Quickly close
Kill Term 9999
After executing the order, we were inquiring once and found that port 80 has been released; then we restart and try to find it normally;
On the start and closing of Nginx, we are studying next time, and I will not introduce them here;