Install Nginx on CentOS 7 yum

CentOS 7 yum install Nginx
1. Add Nginx to YUM source
  sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch. rpm

2. Install Nginx
  sudo yum install -y nginx

3. Start Nginx
  sudo systemctl start nginx.service

4. Start
  sudo systemctl enable nginx.service
  More systemctl commands can be viewed in "systemctl command usage"

Nginx configuration information
Website files are stored in the default directory
  /usr/share/nginx/html

website default site configuration
  /etc/nginx/conf.d/default.conf

custom Nginx site configuration file storage directory
  /etc/nginx/conf.d/

Nginx global configuration
  /etc/nginx/nginx .conf

Nginx start
  nginx -c nginx.conf

restart NGinx
  service nginx restart

Possible problems:
1. Executing sudo systemctl start nginx.service reports an error [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use) .
Solution:
    (1) Use the command lsof -i tcp:80 to check the port 80 situation (install the lsof command: yum install lsof).
    (2), kill -9 3274
     can't be solved after executing service nginx start, it may be a firewall problem.
2. After installing Nginx on centos, why can't I access it?
Solution :
    CentOS 7 uses firewall as the firewall by default, which is changed to iptables firewall here.
    firewall:
    systemctl start firewalld.service#Start firewall
    systemctl stop firewalld.service#Stop firewall
    systemctl disable firewalld.service#Prohibit firewall startup and start
    Try using the $curl http://127.0.0.1 command to access nginx under centos. Determine whether it can be accessed; it is

recommended to read another article of mine, which can be solved by opening port 80 access permissions.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326179080&siteId=291194637