Install nginx on centos 8
Nginx is free and open-source high-performance web server. It also acts as a reverse proxy server and load balancer.
In this article, we will see installation of nginx on centos 8 server.
Step 1: Install nginx
we can install nginx package using yum command
[root@centos ~]# yum install nginx
once it is installed start and enable the service on autoboot.
[root@centos ~]# systemctl start nginx
[root@centos ~]# systemctl enable nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
[root@centos ~]# systemctl status nginx
output should look something like below
[root@centos ~]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Drop-In: /usr/lib/systemd/system/nginx.service.d
└─php-fpm.conf
Active: active (running) since Fri 2020-03-06 19:33:21 IST; 31s ago
Step 2: Allow ports
If firewall service is running on your system then update firewall settings and open TCP port 80 and 443 with following commands.
[root@centos ~]# firewall-cmd --permanent --zone=public --add-service=http
[root@centos ~]# firewall-cmd --permanent --zone=public --add-service=https
[root@centos ~]# firewall-cmd --reload
Step 3: Test nginx
Now, you can test your nginx installation, open your browser and type your system ip like http://ip_address. It should open default Nginx welcome page.
Step 4: configure nginx
we will see few important nginx default file paths below
default document root for nginx is /usr/share/nginx/html
Main configuration file is located at /etc/nginx/nginx.conf
log files are located at /var/log/nginx.
All Nginx configuration files are located in the /etc/nginx.