• Courses
    [INSERT_ELEMENTOR id="8887"]
  • Features
    • Membership
    • Portfolio
    • About Us
    • FAQs
    • Sidebar Shop
    • 404 Page
  • Events
  • Gallery
  • Blog
  • Contact
  • Shop
    Have any question?
    [email protected]
    Login
    ITIBooks
    • Courses
      [INSERT_ELEMENTOR id="8887"]
    • Features
      • Membership
      • Portfolio
      • About Us
      • FAQs
      • Sidebar Shop
      • 404 Page
    • Events
    • Gallery
    • Blog
    • Contact
    • Shop

      Nginx

      • Home
      • Blog
      • Nginx
      • How to Install and Configure Nginx on CentOS 7

      How to Install and Configure Nginx on CentOS 7

      • Categories Nginx
      • Date October 10, 2020
      • Comments 0 comment
      • Tags Install Nginx, Nginx, Nginx Web Server
      nginx

      Nginx is a high-performance, open-source software for web serving. It can be used as a proxy server for email (IMAP, POP3, and SMTP), as a reverse proxy and load balancer for HTTP, TCP, and UDP servers.

      Install Nginx on CentOS 7

      – Update Repository Package Lists

      Use the following command to update the repository package lists:

      yum update

      – Install Extra Packages for Enterprise Linux (EPEL)

      Nginx is not available in the standard repositories that come with the CentOS package,
      So you will need to install the EPEL repository on your server.
      EPEL is free to use and provides numerous open-source packages to install with Yum.

      To install EPEL, run the following command:

      yum install epel-release

      – Install Nginx

      Now, you can install Nginx by running the following command:

      yum install nginx

      – Start Nginx as a Service

      Set up Nginx to start automatically at a server boot.
      You can do this by running the following command:

      systemctl enable nginx

      Nginx does not start on its own. To start Nginx, type the following command:

      systemctl start nginx

      Make sure the service had no errors by running:

      systemctl status nginx

      – Configure Firewall to Allow Traffic

      To allow HTTP and HTTPS traffic, run the following commands:

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

      – Verify Nginx is working fine

      The easiest way to check whether Nginx is running properly is by visiting your server’s public IP address. Just open your web browser and visit http://your_server_IP/

      Configure Nginx on CentOS 7

      – Nginx Global Configuration

      Nginx primary configuration file is /etc/nginx/nginx.conf.

      This configuration file is broken down into contexts.
      By default, you can identify three (3) contexts:

      1. Events are global settings that define how Nginx handles connections in general.
      2. HTTP defines how the server handles HTTP and HTTPS connections.
      3. Server is defined within the HTTP context. It specifies server ports, document root, etc.

      You can always add additional contexts.

      – Default Nginx Server Root

      The default Nginx server root directory is /usr/share/nginx. This is specified in the default server block configuration file, located at /etc/nginx/conf.d/default.conf.

      The default server document root directory which contains web files is usr/share/nginx/html.

      – Nginx Server Blocks

      Nginx does not have Virtual hosts to run multiple websites like Apache, it has “Server Blocks” that can be added by creating new configuration files in /etc/nginx/conf.d

      Files that end with .conf in that directory will be loaded when Nginx is started.

      – Check for syntax errors

      It is very important to check for any syntax errors when configuring Nginx. This can be done by issuing the following command:

      nginx -t

      – Reload Nginx

      If you made some modifications to the Nginx main configuration changes. You need to reload the server to propagate the changes.

      systemctl reload nginx

      Tag:Install Nginx, Nginx, Nginx Web Server

      • Share:
      author avatar
      admin

      Previous post

      How To Install MySQL on CentOS 7
      October 10, 2020

      Next post

      Installing and Configuring Pure-FTPD on CentOS 7
      October 11, 2020

      Leave A Reply Cancel reply

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

      Search

      Categories

      • Apache tomcat
      • Backup
      • FTP Server
      • MySQL Database
      • Nginx
      • WildFly
      • Windows
      Introduction LearnPress – LMS plugin

      Introduction LearnPress – LMS plugin

      Free
      From Zero to Hero with Nodejs

      From Zero to Hero with Nodejs

      Free
      Learn Python – Interactive Python

      Learn Python – Interactive Python

      $69.00

      logo-eduma-the-best-lms-wordpress-theme

      (00) 123 456 789

      [email protected]

      Company

      • About Us
      • Blog
      • Contact
      • Become a Teacher

      Links

      • Courses
      • Events
      • Gallery
      • FAQs

      Support

      • Documentation
      • Forums
      • Language Packs
      • Release Status

      Recommend

      • WordPress
      • LearnPress
      • WooCommerce
      • bbPress

      Powered by AxialSystem.

      • Privacy
      • Terms
      • Sitemap
      • Purchase
      [miniorange_social_login shape="longbuttonwithtext" theme="default" space="4" width="240" height="40"]

      Login with your site account

      Lost your password?