How to Install Nginx on CentOS 8

How to Install Nginx on CentOS 8

Nginx, stylized as NGIИX, is a web server that can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache. The software was created by Igor Sysoev and publicly released in 2004. Nginx is free and open-source software, released under the terms of the 2-clause BSD license

NGINX is open source software for web serving, reverse proxying, caching, load balancing, media streaming, and more. It started out as a web server designed for maximum performance and stability.

Install Nginx on centOS 8; Through this tutorial, we will learn how to install Nginx on CentOS 8.

How to Install Nginx on CentOS 8

Follow the following steps to install Nginx on CentOS 8:

  • Step 1 – Install Nginx on CentOS
  • Step 2 – Enable and Start Nginx
  • Step 3 – Verify Status of Nginx
  • Step 4 – Adjust Firewall
  • Step 5 – Nginx Configuration File’s Structure

Step 1 – Install Nginx on CentOS

First of all, open terminal or command line and execute the following command into it to install Nginx on CentOS 8:

sudo yum install nginx

Step 2 – Enable and Start Nginx

Once the nginx installation is completed, then execute the following command on command line or terminal to enable and start nginx:

sudo systemctl enable nginx
sudo systemctl start nginx

Step 3 – Verify Status of Nginx

Once the start and enable nginx, execute the following command on command line or terminal to verify status of nginx:

sudo systemctl status nginx

Step 4 – Adjust Firewall

Execute the following command on command line or terminal to adjust firewall settings:

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

Step 5 – Nginx Configuration File’s Structure

And use the following instrucations to configure file’s in nginx:

  • All Nginx configuration files are located in the /etc/nginx/ directory.
  • The main Nginx configuration file is /etc/nginx/nginx.conf.
  • Creating a separate configuration file for each domain makes the server easier to maintain.
  • The Nginx server block files must end with .conf and be stored in /etc/nginx/conf.d directory. You can have as many server blocks as you want.
  • It is a good practice to follow a standard naming convention. For example, if the domain name is mydomain.com then the configuration file should be named mydomain.com.conf
  • If you use repeatable configuration segments in your domain server blocks, it is a good idea to refactor those segments into snippets.
  • Nginx log files (access.log and error.log) are located in the /var/log/nginx/ directory. It is recommended to have a different access and error log files for each server block.
  • You can set your domain document root directory to any location you want. The most common locations for webroot include:
    • /home/<user_name>/<site_name>
    • /var/www/<site_name>
    • /var/www/html/<site_name>
    • /opt/<site_name>
    • /usr/share/nginx/html

Conclusion

Install Nginx on centOS 8; Through this tutorial, we have learned how to install Nginx on CentOS 8.

Recommended CentOS Tutorials

AuthorAdmin

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *