Indiffer

Indiffer

Uninstall Nginx on Centos7 and reinstall Nginx (record using rpm method)

Uninstalling nginx

  1. 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
  2. Find and delete Nginx related files
  • View Nginx related files: whereis nginx

image

  • Use find to search for related files: find / -name nginx

image

  • 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:

  1. Want to know which ports the Nginx service uses? How to check the ports Nginx listens on?
    1. Check the Nginx process ID
    2. Check the corresponding process's occupied port number
    • Check the nginx master process ID
      ps aux | grep nginx

image

  • Check the port number used based on the PID
    netstat -anp | grep ${pid} # pid is the nginx master process ID obtained above

image
From the image, you can see that nginx uses the port numbers 13599, 13800, 8080, 80, 13590, 13591, 13592.

Source: https://cloud.tencent.com/developer/article/1801077

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.