• Home
  • Knowledgebase
  • Blog
  • Home
  • Knowledgebase
  • Blog
home/Knowledge Base/Centos/How To Install Nginx on CentOS 7

How To Install Nginx on CentOS 7

16 views 0 October 21, 2022 host_know_user

Introduction

Popular high-performance web servers include Nginx. You will learn how to install and launch Nginx on your CentOS 7 server in this guide.

Prerequisites

This tutorial’s instructions call for a non-root user with sudo capabilities.

Step 1: Adding the EPEL Software Repository

You must first establish an SSH connection to your CentOS 7 system before you can use the yum command to add the EPEL repository:

# sudo yum install epel-release

You will be asked to confirm your desire to install the software. Enter y to continue after you.

After that, you’ll set up the actual nginx programme.

Step 2: Nginx installation

After setting up the EPEL repository on your server, run the yum command below to install Nginx:

# sudo yum install nginx

Once more, select yes to the verification question, and Nginx’s installation will be completed.

Step 3: Launch Nginx

Nginx won’t launch on its own after installation. Make use of the systemctl command to start Nginx:

# sudo systemctl start nginx

Systemctl status can be used to determine the status of the service.

# sudo systemctl status nginx

Output :
● nginx.service – The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2022-01-24 20:14:24 UTC; 5s ago
Process: 1898 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 1896 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 1895 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 1900 (nginx)
CGroup: /system.slice/nginx.service
├─1900 nginx: master process /usr/sbin/nginx
└─1901 nginx: worker process

Jan 24 20:14:24 centos-updates systemd[1]: Starting The nginx HTTP and reverse proxy server…
Jan 24 20:14:24 centos-updates nginx[1896]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Jan 24 20:14:24 centos-updates nginx[1896]: nginx: configuration file /etc/nginx/nginx.conf test is successful
Jan 24 20:14:24 centos-updates systemd[1]: Started The nginx HTTP and reverse proxy server.

The service should be active.

Run the following commands on your firewall to enable HTTP and HTTPS traffic:

# sudo firewall-cmd --permanent --zone=public --add-service=http
# sudo firewall-cmd --permanent --zone=public --add-service=https
# sudo firewall-cmd –reload

Visit your server’s public IP address in your web browser straight away to make sure everything went according to plan:

http://server_domain_name_or_IP/

You will view the CentOS 7 Nginx default web page, which is provided for testing and informational reasons. It should resemble the following:

Your web server has now been correctly installed if you can view this page.

 

Note: Look for the network interfaces on your computer by typing: To discover your server’s public IP address, locate:

# ip addr

Output :
1. lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN

. . .
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

. . .

Based on the hardware your server has, you can notice a variety of interfaces here. The local loopback interface, or lo interface, is not what we desire. We want the eth0 interface in the aforementioned case.

Run the following command to disclose your server’s public IP address once you have the interface name. Replace with the interface name you discovered above:

# ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

You should enable Nginx to start when your system boots before moving on. Enter the following command to accomplish that:

# sudo systemctl enable nginx

Currently, Nginx is set up and operating.

Step 4: Investigating and setting up Nginx

The locations of the Nginx configuration files and the default server root directory are important to know if you wish to start using Nginx to serve your own web pages or applications.

Standard Server Root

/usr/share/nginx/html is the server’s default home directory. The files you put there will be provided by your web server. This location is supplied in the /etc/nginx/conf.d/default.conf configuration file for the default server block that comes with Nginx.

Block configuration for servers

/etc/nginx/nginx.conf is the location of the main Nginx configuration file. Here, among other things, you can modify parameters like the user who manages the Nginx daemon processes and the quantity of worker processes that are launched when Nginx is active.

Conclusion

Once you have Nginx installed on your CentOS 7 server.

Was this helpful?

Yes  No
Related Articles
  • How to Set Up and Secure phpMyAdmin on a CentOS 7 Server Using Apache
  • How To Install WordPress on CentOS 7
  • How To install Git on Centos 7
  • How To Install MariaDB on CentOS 7
  • How To Create a New User and Grant Permissions in MySQL
  • How To Install Linux, Apache, MySQL, PHP (LAMP) stack On CentOS 7

Didn't find your answer? Contact Us

Leave A Comment Cancel reply

Centos
  • How To Install Nginx on CentOS 7
  • How To Set Up SSH Keys on  CentOS 7
  • How To Set Up Apache Virtual Hosts on CentOS 7
  • How To Install Linux, Apache, MySQL, PHP (LAMP) stack On CentOS 7
  • How To Create a New User and Grant Permissions in MySQL
  • How To Install MariaDB on CentOS 7
  • How To install Git on Centos 7
  • How To Install WordPress on CentOS 7
  • How to Set Up and Secure phpMyAdmin on a CentOS 7 Server Using Apache
All Categories
  • Centos
  • container
  • Ubuntu
  • Debian
  • Linux Basics

  How To Install MariaDB on CentOS 7

How To install Git on Centos 7  

Support
  • Live chat
  • Knowledge Base
  • Blog
Manual Head Office
Toll free : 1800 572 8782
  • Copyright 2022 Hostzop Expert Solutions. All Rights Reserved.