First conditions of installation

Ensure that you have logged in to the server as a user with sudo permission, and that no Apache or other service occupies ports 80 and 443

Start the installation

  • To set up the YUM repository, create/etc/yum.repos.d/nginx.repoA file containing the following contents
[nginx] 
name=nginx repo 
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0 
enabled=1
Copy the code
  • Start installing Nginx
yum install nginx
Copy the code
  • Set Nginx to boot upon startup
sudo systemctl enable nginx
Copy the code

After running the above command, output similar to the following, indicating that a soft connection has been created to associate Nginx, do not worry, it is not an error, then you can start Nginx.

Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
Copy the code
  • Start the Nginx
sudo systemctl start nginx
Copy the code
  • Check the Nginx status
sudo systemctl status nginx
Copy the code

  • Access your OWN IP address to see the Nginx welcome page, the first access to replace takes up port 80 so you only need to enter the IP address

Configuration file related

  • Install all configuration file directories in the above method/etc/nginx
  • Nginx master configuration file/etc/nginx/nginx.conf
  • Log file directory/var/log/nginx/
  • Default static resource directory/usr/share/nginx/html/

Nginx systemctl management

Nginx sudo systemctl start nginx sudo systemctl stop nginx sudo systemctl restart nginx sudo systemctl start nginx sudo systemctl stop nginx sudo systemctl restart nginx Nginx sudo systemctl enable nginx sudo systemctl enable nginx sudo systemctl Disable nginx sudo systemctl status nginxCopy the code

This article is formatted using MDNICE