Nginx

How To Install Nginx On CentOS 7

Nginx is high performance and lightweight web server. It also work as web reverse proxy and email (POP3/IMAP)proxy server. It runs on Linux, UNIX, BSD, Mac OS X, Solaris and Microsoft Windows. As per the Netcraft more than 6% of all domains on the internet use Nginx web server. Nginx powers several high traffic web sites like WordPress, Github, Hulu, and SourceForge. The need for serving large number of concurrent requests is raising every day. Also Nginx solved the C10K ( i.e 10,000 concurrent clients) Problem.

In this article I will explain how to install and start Nginx on CentOS 7 server.

Prerequisites

To install nginx you should have root privileges. Follow the below steps to setup nginx on CentOS server.

Add Nginx Repository

First you have to add the CentOS 7 repository, type the below command to install repository:

# yum install epel-release

Install Nginx

After installing Nginx repository, now install Nginx typing below command:

# yum install nginx -y

Nginx web server has been successfuly installed on your CentOS server.

Start Nginx

To start the Nginx follow the below command:

# /etc/init.d/nginx start

Allow HTTP And HTTPS Traffic In Firewall

If you are running a firewall, run the following commands to allow HTTP and HTTPS traffic:

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

Verify

Now verify that everything went as planned by visiting your server’s Public IP address or Domain name in your
web browser.

http://Domain_name-or_IP_address/

You will get the default CentOS 7 Nginx web page. It will look like below:

nginx-default-page

If you see above page, it means your web server is now correctly installed.

Now set Nginx to start when your system reboots. Type the blow command:

# chkconfig nginx on

Server Root And Configuration File

If you want to access your own pages or application through Nginx, you should know where is the location of the Nginx configuration files and default server root directory.

Default Server Root

Default server root directory is /usr/share/nginx/html. This location is specified in the default Nginx server block configuration file that ships with Nginx, which is located at /etc/nginx/conf.d/default.conf.

Server Block Configuration

Creating a new configuration file in /etc/nginx/conf.d/ you can add additional server blocks, also know as Virtual Hosts in Apache. File that end with .conf in that directory will be loaded when Nginx is started.

Nginx Global Configuration

The main global Nginx configuration file is located at /etc/nginx/nginx.conf. You can change Nginx setting such as user that runs the Nginx daemon process, number of worker process that get spawned when Nginx is running.

Congratulations! Nginx is now installed and running!

Thanks:)

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment