• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install NGINX Web Server on CentOS/RHEL 7/6 and Fedora 27/26

Written by Rahul, Updated on October 26, 2017

NGINX (Engine X) is an powerful web server, Its getting popular very fast due to its fast speed. NGINX is also used as a reverse proxy server. This tutorial will help you to setup NGINX on CentOS/RHEL 7/6 and Fedora systems.

Step 1 – Install Nginx

Nginx packages are available under default repositories. Execute the following command to install latest Nginx available version on your system.

$ yum install nginx    
$ dnf install nginx    #On Fedora 22+ systems 

Step 2 – Nginx Basic Configuration

Do some initial setting before starting nginx. Edit Nginx main configuration file /etc/nginx/nginx.conf and update following values.

$ vim /etc/nginx/nginx.conf

Update following values:

worker_processes  4;   # Number of CPU available in system 
listen  80;  # Port on which nginx will listen 

Step 3 – Start Nginx Service

Use following commands to start Nginx web server and configure Nginx to autostart on system boot.

$ systemctl enable nginx.service
$ systemctl start nginx.service

Now access your server on port 80 with your favorite browser, It will show default Nginx page.

Install Nginx on CentOS

Step 4 – Create VirtualHost in NGINX

After making initial configuration changes to NGINX, let’s start with configuring the first virtual host. Firstly create document root for your application.

$ sudo mkdir -p /var/www/example.com/httpdocs
$ sudo chown -R nginx.nginx /var/www/example.com

Now create an index file with sample text

$ echo "Welcome to NGINX" > /var/www/example.com/httpdocs/index.html

Now create a virtual host configuration file. I just create a copy of default.conf file with name example.com.conf and edit file in the editor.

$ cp /etc/nginx/conf.d/virtual.conf /etc/nginx/conf.d/example.com.conf
$ vim /etc/nginx/conf.d/example.com.conf

Make few changes in the configuration file like below and keep other settings as it is.

server {
    listen       80;
    server_name  example.com;

    location / {
        root   /var/www/example.com/httpdocs;
        index  index.html index.htm;

    }

Finally, restart the NGINX service using the following command

$ sudo systemctl restart nginx.service

Congratulation’s! You have successfully installed Nginx. Read out other articles Install Nginx, MySQL, PHP (LEMP) Stack with PHP-FPM

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

2 Comments

  1. Avatar gifts for women Reply
    July 7, 2013 at 2:43 am

    I think that you could do with some pics to drive the message home a little bit, but other than that, this is great blog. A great read. I will certainly be back.

  2. Avatar polo ralph lauren pas cher Reply
    May 18, 2013 at 12:28 pm

    wow, awesome blog article.Really looking forward to read more. Awesome.

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • (Solved) apt-add-repository command not found – Ubuntu & Debian 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy