Uninstalling nginx
- First, enter the command
ps -ef | grep nginx
to check if the nginx service is running. If it is running, stop it. You need to execute it in the sbin directory of the nginx installation directory. If the environment is configured, it is not necessary:
./nginx -s stop
- Find and delete Nginx related files
- View Nginx related files:
whereis nginx
- Use find to search for related files:
find / -name nginx
- Delete all directories found by find one by one:
rm -rf /usr/local/nginx /usr/local/sbin/nginx /usr/local/nginx-1.13.9/objs/nginx
Then use yum to clean up:yum remove nginx
Installing nginx
- Add Nginx source
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
- Install Nginx
yum install -y nginx
- Start Nginx
systemctl start nginx.service
- Set Nginx to start on boot
systemctl enable nginx.service
- The configuration file for nginx is located at /etc/nginx/nginx.conf, and the directory is located at /etc/nginx
- Custom configuration files are placed in /etc/nginx/conf.d
- Project files are stored in /usr/share/nginx/html/
- Log files are stored in /var/log/nginx/
- There are also some other installation files in /etc/nginx
- This method of installation and configuration is relatively scattered, making it difficult to find, so it is better to install it by compiling the source code.
Tips:
- Want to know which ports the Nginx service uses? How to check the ports Nginx listens on?
- Check the Nginx process ID
- Check the corresponding process's occupied port number
- Check the nginx master process ID
ps aux | grep nginx
- Check the port number used based on the PID
netstat -anp | grep ${pid} # pid is the nginx master process ID obtained above
From the image, you can see that nginx uses the port numbers 13599, 13800, 8080, 80, 13590, 13591, 13592.