Home Linux CentOS How To Install Nginx on CentOS (Engine X)

How To Install Nginx on CentOS (Engine X)


Introduction

Nginx is a very popular web browser nowadays because of its high performance, can be used as reverse proxy, load balancer and pronounced as “Engine-X”. It is known for its steadiness, rich list of capabilities, basic arrangement, and low resources utilization. Therefore, it is great option in contrast to the Apache webserver.

Installation

There are numerous approaches to install Nginx. Here we are using Epel repository for the installation.

 Step 1. Install epel repository.

[root@localhost ~]# yum install epel-release.noarch
install epel repository
install epel repository

Step 2. Now run command install nginx.

[root@localhost ~]# yum install nginx
install nginx

Step 3. Start the nginx service.

[root@localhost ~]# systemctl start nginx

Step 4. Enable nginx on boot.

[root@localhost ~]# systemctl enable nginx

Nginx successfully installed.


Possible reasons For Errors

1. Port 80 is already in use, the error message will be like this:

command: [root@localhost ~]# service nginx start
Error: Redirecting to /bin/systemctl start  nginx.service
Job for nginx.service failed because the control process exited with error code. See “systemctl status nginx.service” and “journalctl -xe” for details.

This means that another web server (Apache) is already running on this server. Stop the Apache service (Systemctl stop httpd) and then start the service for NGINX (systemctl start nginx)

2. Also check the firewall status

[root@localhost ~]# systemctl status firewalld

if it is active- allow traffic for HTTP or HTTPS.

[root@localhost ~]# firewall-cmd –permanent –zone=public –add-service=http

[root@localhost ~]# firewall-cmd –reload 

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here