Install nginx under Centos8
I recently engaged in an Alibaba Cloud server and wanted to install nginx. I encountered a lot of problems during the installation process. Here is a share of my installation process;
Environment: Alibaba Cloud Server
System: centos8
Nginx version: nginx-1.6.2.tar.gz
start installation
Install dependent packages, use yum tool to install
yum -y install gcc make zlib-devel pcre pcre-devel openssl-devel
Now start to download the nginx source package, use the wget tool to download
wget http://nginx.org/download/nginx-1.6.2.tar.gz
If there is an error message such as the command does not exist when performing this step, it may be because the wget tool is not installed, and you need to use the yum tool to install the wget tool
yum -y install wget
Unzip the nginx-1.6.2.tar.gz compressed package
tar -xvf nginx-1.6.2.tar.gz
After decompression, there will be a directory file named nginx-1.6.2;
enter the nginx-1.6.2 directory and execute the configuration command
./configure
Next, compile the file, after the compilation is successful, you can see a Makefile file
make
Generally there will be problems here, the screenshots and solutions are given below
The cause of the problem: I don’t know.
Solution:
Go to the nginx-1.6.2 directory (the decompressed directory) , find the objs folder in the current directory, and enter, open the file Makefile,
vim objs/Makefile
Find the line with the following content: (just the first few lines)
CFLAGS = -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g
-Werror: gcc treats all warnings as errors and removes the "-Werror" from the content of this line. If you
execute make again to compile, an error will be reported. The error message is as follows:
Cause of error: I don’t know.
Solution: Edit this file
vim /usr/local/nginx-1.6.2/src/os/unix/ngx_user.c
Comment out this line in the figure
Re-execute the compilation command, generally there will be no problems
make
Perform compile and install
Perform compilation and installation, that is, copy the compiled files to the specified directory. (Copy the files in the /nginx-1.6.2 directory to /usr/local/nginx/).
make install
Start the nginx server:
/usr/local/nginx/sbin/nginx
Test whether the nginx server is available, ip:80