Today, Shang Silicon Valley released a new version of the Nginx tutorial. I felt that the previous tutorial was a bit shallow, so I decided to read it again, and then uninstall the previous Nginx before starting to read it. Install the version of Nginx corresponding to the tutorial, so that there may be fewer errors when watching the tutorial.
content
1. Check if the nginx service is running
2) If Nginx is set to start automatically at boot, the following two steps may be required
3) You can use the yum command to clean up
2. Install the corresponding dependencies
3. Check whether Nginx is installed successfully
1. Uninstall Nginx
1. Check if the nginx service is running
ps -ef | grep nginx
2. Stop Nginx
/usr/local/nginx/sbin/nginx -s stop
If you forget where your Nginx is installed you can find it with the command below.
find / -name nginx
2. Uninstall Nginx
1) Execute the command rm -rf * to delete the related files installed by nignx (this command depends on your nginx location)
2) If Nginx is set to start automatically at boot, the following two steps may be required
chkconfig nginx off
rm -rf /etc/init.d/nginx
3) You can use the yum command to clean up
At this point, your nginx has been uninstalled cleanly.
2. Install Nginx
1. Download and unzip Nginx
Since I followed the tutorial, I directly transferred the installation provided by Shang Silicon Valley to my Centos.
Directly enter the tar zxvf nginx-1.21.6.tar.gz command to decompress
2. Install the corresponding dependencies
1) Install gcc
yum install -y gcc
2) Install the perl library
yum install -y pcre pcre-devel
3) Install the zlib library
yum install -y zlib zlib-devel
Then execute the following command:
make
make install
Because I have installed and make, the interface is not the same as yours.
4) Compile and install Nginx
./configure --prefix=/usr/local/nginx
make
make install
This is the page where make install is done
3. Check whether Nginx is installed successfully
1. Find your command to install nginx and enter the following command
./nginx
Then enter the ip addr command to get the ip of your virtual machine
2. Enter your ip address in the browser
See Welcome to nginx! It means your nginx installation is successful.
If it doesn't start, you have to turn off the firewall:
systemctl stop firewalld.service
Turn off the firewall once and for all:
systemctl disable firewalld.service