In this tutorial we will show you how to install and configuration of Nginx on your CentOS 7 server. For those of you who didn’t know, Nginx is a powerful web server software that can be used on your server. It is also known for its high performance and low memory usage which will allow fewer resources to be used but getting the job done efficiently. A popular set up is to use it as a proxy for Apache, which can then serve application requests. That will not be covered in this tutorial, though.
This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple. I will show you through the step by step installation Nginx in CentOS 7.
Install Nginx on CentOS 7
Step 1. First let’s start by ensuring your system is up-to-date.
Step 2. Installing and Configuring NGINX in CentOS 7.
Nginx is not yet available in CentOS 7 official repositories, so we have to add / install Nginx yum repository by issuing command below:
Start Nginx and add it to automatically start on your system start-up using:
You can verify that Nginx is really running by opening your favorite web browser and entering the URL http://your-server’s-address, if it is installed, then you will see this:
Step 3 Configure Nginx web server.
Let’s say you have a domain mydomain.com and you like to use it to host a PHP based web application in /var/www/mydomain.com like WordPress, Joomla. To set-up Nginx serve requests for mydomain.com, and serve the PHP scripts in /var/www/mydomain.com you would have to create a server block in /etc/nginx/conf.d/mydomain.com.conf which would look something like:
### nano /etc/nginx/conf.d/mydomain.com.conf
Test and re-start Nginx using:
Step 4. Configure IPTables or Firewall.
CentOS 7 has a local firewall enabled by default. Proper TCP ports may need to be opened to allow external requests. This will usually be port 80 for normal HTTP traffic:
Congratulation’s! You have successfully installed Nginx. Thanks for using this tutorial for installing Nginx web server in CentOS 7 system. For additional help or useful information, we recommend you to check the official Nginx web site.