Facebook Twitter Instagram
    TecAdmin
    • Home
    • Ubuntu 20.04
      • Upgrade Ubuntu
      • Install Java
      • Install Node.js
      • Install Docker
      • Install LAMP Stack
    • Tutorials
      • AWS
      • Shell Scripting
      • Docker
      • Git
      • MongoDB
    • FeedBack
    • Submit Article
    • About Us
    Facebook Twitter Instagram
    TecAdmin
    Home»Web Servers»How to Install NGINX Web Server on CentOS/RHEL 7/6 and Fedora 27/26

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

    RahulBy RahulNovember 1, 20132 Mins ReadUpdated: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

    nginx webserver
    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email WhatsApp
    Previous ArticleA Windows Server Event Log Backup Script
    Next Article Install SugarCRM 6.5.16 Community Edition on Linux

    Related Posts

    How To Install Linux, Nginx, MySQL, & PHP (LEMP Stack) on Ubuntu 22.04

    Updated:April 7, 20227 Mins Read

    How to Increase Request Timeout in NGINX

    Updated:January 13, 20222 Mins Read

    How To Disable HTTP Methods in Apache

    Updated:December 31, 20212 Mins Read

    How to Install and Secure Apache on Debian11

    6 Mins Read

    How To Create SFTP User for a Web Server Document Root

    5 Mins Read

    How To Enable Brotli Compression in Apache

    2 Mins Read

    2 Comments

    1. gifts for women on July 7, 2013 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.

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

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

      Reply

    Leave A Reply Cancel Reply

    Recent Posts
    • How to Enable / disable Firewall in Windows
    • How to Install JAVA on Ubuntu 22.04
    • Switching Display Manager in Ubuntu – GDM, LightDM & SDDM
    • Changing the Login Screen Background in Ubuntu 22.04 & 20.04
    • How To Install PHP (8.1, 7.4 or 5.6) on Ubuntu 22.04
    Facebook Twitter Instagram Pinterest
    © 2022 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.