Nginx
--------
Install Nginx on CentOS 7
# yum install epel-release
# yum -y install nginx
systemctl enable nginx
systemctl start nginx
systemctl status nginx
systemctl restart nginx
systemctl stop nginx
systemctl disable nginx
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --reload
firewall-cmd --zone=public --permanent --add-service=http
firewall-cmd --zone=public --permanent --add-service=https
firewall-cmd --reload
http://YOUR_IP,
Configuration File: vi /etc/nginx/nginx.conf
---------------------------
user nginx;
worker_processes 1;
events {
worker_connections 1024;
}
-------------------------------
Test Failed Error Message
# vi /etc/nginx/nginx.conf
listen [::]:80 default_server ‘#’ Just add at the beginning of the line. It should look like this:
# listen [::]:80 default_server; Save the changes you have made and reload the NGINX service.
systemctl reload nginx
Nginx important and configuration file structure
1. /etc/nginx/ is the leading directory of the Nginx server; all configuration files located here.
2. /etc/nginx/nginx.conf is the main configuration file of Nginx Server. Create new Nginx server block files with extension “.conf” and it is stored into /etc/nginx/conf.d/ directory.
3. Nginx server always read sites configuration from /etc/nginx/conf.d/ directories. It is recommended to make separate configuration files for each site to make changes quickly.
The default server document root directory which contains web files is usr/share/nginx/html.
nginx -V = displays Nginx modules and configurations
nginx -h = help options
nginx = start Nginx process
nginx -s stop = stop Nginx process
nginx -s reload = reload Nginx process
--------