{"id":2599,"date":"2018-09-30T10:25:26","date_gmt":"2018-09-30T04:55:26","guid":{"rendered":"https:\/\/pheonixsolutions.com\/blog\/?p=2599"},"modified":"2026-09-25T18:25:30","modified_gmt":"2026-09-25T12:55:30","slug":"how-to-install-latest-version-of-ngnix-1-15-4-on-centos-7","status":"publish","type":"post","link":"https:\/\/pheonixsolutions.com\/blog\/how-to-install-latest-version-of-ngnix-1-15-4-on-centos-7\/","title":{"rendered":"How to Install Nginx on CentOS 7 Using the Official Nginx Repository"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Post Date:<\/strong> September 30, 2018<br><strong>Last Updated:<\/strong> September 25, 2026<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introduction<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx is a lightweight, high-performance web server and reverse proxy commonly used for hosting websites, applications, APIs, and load-balanced services.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The original version of this article covered installing <strong>Nginx 1.15.4 on CentOS 7<\/strong> using the Nginx repository. Since the original procedure was published, Nginx repository configurations, package signing practices, and Linux security requirements have evolved.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before starting, make sure you have:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A CentOS 7 x86_64 server<\/li>\n\n\n\n<li>Root or <code>sudo<\/code> access<\/li>\n\n\n\n<li>Internet connectivity<\/li>\n\n\n\n<li>A configured hostname or server IP<\/li>\n\n\n\n<li><code>firewalld<\/code> enabled if you plan to use the local firewall<\/li>\n\n\n\n<li>An existing application or website if Nginx will be used as a reverse proxy<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Note:<\/strong> CentOS 7 is no longer supported. For production systems, migration to a supported operating system should be planned.<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Check the CentOS Version<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">First, verify the operating system version:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cat \/etc\/centos-release\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also check the kernel and architecture:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">uname -m\nuname -r\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The original environment for this article is:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">CentOS 7\nx86_64\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Remove an Existing Nginx Package if Required<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before installing Nginx from the official repository, check whether Nginx is already installed:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nginx -v\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If Nginx is already installed through another repository or package source, review the installation before replacing it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You can check the installed RPM package with:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">rpm -qa | grep nginx\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the existing installation is no longer required, remove it:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo yum remove nginx\n<\/pre>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Warning:<\/strong> Do not remove an existing Nginx installation on a production server until you have confirmed its configuration and dependencies.<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Create the Official Nginx Repository<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Create the repository configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo vi \/etc\/yum.repos.d\/nginx.repo\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For the Nginx mainline repository, add:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[nginx]\nname=nginx repo\nbaseurl=http:\/\/nginx.org\/packages\/mainline\/centos\/$releasever\/$basearch\/\ngpgcheck=1\nenabled=1\ngpgkey=https:\/\/nginx.org\/keys\/nginx_signing.key\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Save the file and exit.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Mainline vs. Stable<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx provides two primary release tracks:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Mainline<\/strong> \u2013 receives newer features and improvements first.<\/li>\n\n\n\n<li><strong>Stable<\/strong> \u2013 focuses on a more conservative release stream.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For production environments, select the release stream according to your application&#8217;s compatibility and operational requirements rather than automatically choosing the newest package.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Security Note:<\/strong> The original article used <code>gpgcheck=0<\/code>. That disables RPM signature verification and is not recommended. The updated configuration enables GPG verification.<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Clean the YUM Cache<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo yum clean all\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then rebuild the package metadata:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo yum makecache\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Verify that the Nginx repository is available:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">yum repolist enabled | grep nginx\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Install Nginx<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Install Nginx using YUM:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo yum install nginx\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">When prompted to confirm the installation, enter:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">y\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">After installation, verify the installed version:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nginx -v\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For additional build information:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nginx -V\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6: Test the Nginx Configuration<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before starting the service, validate the configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo nginx -t\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A successful result should indicate that the syntax is valid and the configuration test was successful.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This check is especially important before making configuration changes on production servers.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7: Start Nginx<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Start the Nginx service:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl start nginx\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check its status:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl status nginx\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If the service starts successfully, Nginx should show an active status.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 8: Enable Nginx at Boot<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To automatically start Nginx after a server reboot:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl enable nginx\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Verify:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl is-enabled nginx\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Expected output:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">enabled\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 9: Check the Listening Port<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">By default, Nginx listens for HTTP traffic on port 80.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check the listening socket:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo ss -ltnp | grep ':80'\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If <code>ss<\/code> is unavailable, you can use:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo netstat -lntp | grep ':80'\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should see Nginx listening on port 80.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 10: Allow HTTP Traffic Through the Firewall<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">On CentOS 7, <code>firewalld<\/code> may be enabled by default.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check its status:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl status firewalld\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To allow HTTP traffic:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo firewall-cmd --permanent --zone=public --add-service=http\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If HTTPS will be used, also allow HTTPS:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo firewall-cmd --permanent --zone=public --add-service=https\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Reload the firewall:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo firewall-cmd --reload\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Verify the configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo firewall-cmd --zone=public --list-services\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You should see:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">http https\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">if both services were added.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\"><strong>Important:<\/strong> Opening a firewall port does not automatically make the service accessible from the Internet. Cloud providers may also have external firewall rules, security groups, or network ACLs that need to allow the traffic.<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 11: Test Nginx Locally<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Test the web server directly from the server:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">curl -I http:\/\/127.0.0.1\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A successful response should return an HTTP status such as:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">HTTP\/1.1 200 OK\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can also test using the server&#8217;s IP address:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">curl -I http:\/\/SERVER_IP\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>SERVER_IP<\/code> with the actual server IP address.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Step 12: Access Nginx from a Browser<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Open the following URL:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">http:\/\/SERVER_IP\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Replace <code>SERVER_IP<\/code> with your server&#8217;s public IP address.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If DNS is configured, you can instead access the server using its hostname:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">http:\/\/example.com\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If Nginx is running correctly and the firewall allows the connection, the default Nginx welcome page should be displayed.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Nginx Configuration Location<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The main Nginx configuration file installed from the official Nginx repository is generally:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/etc\/nginx\/nginx.conf\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Additional configuration files are commonly located under:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/etc\/nginx\/conf.d\/\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You can inspect the complete active configuration with:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo nginx -T\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is useful when troubleshooting configuration inheritance, virtual hosts, and included configuration files.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Common Troubleshooting<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Nginx Does Not Start<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Check the service:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl status nginx\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Check the system journal:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo journalctl -u nginx --no-pager -n 100\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Test the configuration:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo nginx -t\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Port 80 Is Already in Use<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Check which process is using port 80:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo ss -ltnp | grep ':80'\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A common cause is another web server such as Apache\/httpd.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Check Apache:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl status httpd\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If Apache is not required:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl stop httpd\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To prevent it from starting automatically:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl disable httpd\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Firewall Is Blocking the Connection<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Check the active firewall rules:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo firewall-cmd --zone=public --list-all\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Make sure HTTP is allowed:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo firewall-cmd --zone=public --list-services\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">If required:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo firewall-cmd --permanent --zone=public --add-service=http\nsudo firewall-cmd --reload\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Cloud Firewall or Security Group Is Blocking Traffic<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If the server is hosted on a cloud platform, verify the provider-level firewall or security group.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For HTTP access, TCP port <strong>80<\/strong> must be permitted.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For HTTPS access, TCP port <strong>443<\/strong> must be permitted.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The operating system firewall and cloud firewall are separate security layers.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Nginx Service Management Commands<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The following commands are useful for day-to-day Nginx administration:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Start Nginx<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl start nginx\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Stop Nginx<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl stop nginx\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Restart Nginx<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl restart nginx\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Reload Nginx<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Use reload when you want to apply configuration changes without unnecessarily stopping active connections:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl reload nginx\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Check Status<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl status nginx\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Enable at Boot<\/h3>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl enable nginx\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Security Considerations<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Installing Nginx is only the first step in securing a web server.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For production environments, consider:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Use HTTPS with a valid TLS certificate.<\/li>\n\n\n\n<li>Keep Nginx and the operating system patched where supported.<\/li>\n\n\n\n<li>Restrict unnecessary firewall ports.<\/li>\n\n\n\n<li>Use strong SSH authentication and disable unnecessary access.<\/li>\n\n\n\n<li>Monitor Nginx access and error logs.<\/li>\n\n\n\n<li>Use appropriate security headers.<\/li>\n\n\n\n<li>Protect administrative interfaces.<\/li>\n\n\n\n<li>Review file and directory permissions.<\/li>\n\n\n\n<li>Implement centralized monitoring and alerting.<\/li>\n\n\n\n<li>Maintain tested backups.<\/li>\n\n\n\n<li>Plan migration away from unsupported operating systems such as CentOS 7.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx logs are typically available under:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/var\/log\/nginx\/access.log\n\/var\/log\/nginx\/error.log\n<\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Configuration Summary<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>Task<\/th><th>Command \/ Location<\/th><\/tr><\/thead><tbody><tr><td>Nginx repository<\/td><td><code>\/etc\/yum.repos.d\/nginx.repo<\/code><\/td><\/tr><tr><td>Install Nginx<\/td><td><code>sudo yum install nginx<\/code><\/td><\/tr><tr><td>Test configuration<\/td><td><code>sudo nginx -t<\/code><\/td><\/tr><tr><td>Start service<\/td><td><code>sudo systemctl start nginx<\/code><\/td><\/tr><tr><td>Enable at boot<\/td><td><code>sudo systemctl enable nginx<\/code><\/td><\/tr><tr><td>Check status<\/td><td><code>sudo systemctl status nginx<\/code><\/td><\/tr><tr><td>Check port 80<\/td><td><code>sudo ss -ltnp | grep ':80'<\/code><\/td><\/tr><tr><td>Allow HTTP<\/td><td><code>firewall-cmd --permanent --add-service=http<\/code><\/td><\/tr><tr><td>Allow HTTPS<\/td><td><code>firewall-cmd --permanent --add-service=https<\/code><\/td><\/tr><tr><td>Nginx configuration<\/td><td><code>\/etc\/nginx\/nginx.conf<\/code><\/td><\/tr><tr><td>Nginx logs<\/td><td><code>\/var\/log\/nginx\/<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Nginx can be installed on CentOS 7 using the official Nginx repository rather than relying on the older packages available through the default CentOS repositories.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The updated process includes repository configuration, GPG verification, Nginx installation, configuration validation, service management, firewall configuration, and connectivity testing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">However, <strong>CentOS 7 is now end-of-life<\/strong>, so new production deployments should use a supported operating system. Existing CentOS 7 environments should be evaluated for migration to a supported Linux distribution.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">FAQ<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Is CentOS 7 still supported?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">No. CentOS 7 reached End of Life on June 30, 2024. Existing systems should be evaluated for migration to a supported operating system.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Should I use Nginx Mainline or Stable?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The choice depends on your application requirements and operational policies. Mainline receives newer features earlier, while stable releases are generally preferred when a more conservative release stream is required.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Why is <code>gpgcheck=1<\/code> recommended?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">GPG verification allows YUM\/RPM to verify that packages are signed by a trusted key. Disabling package signature verification is not recommended.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. Why can&#8217;t I access Nginx from my browser?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Check the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Nginx service status<\/li>\n\n\n\n<li>Nginx configuration<\/li>\n\n\n\n<li>Port 80 listening status<\/li>\n\n\n\n<li><code>firewalld<\/code><\/li>\n\n\n\n<li>Cloud firewall\/security group<\/li>\n\n\n\n<li>DNS configuration<\/li>\n\n\n\n<li>Network connectivity<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">5. How do I verify the installed Nginx version?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nginx -v\n<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. Can Nginx listen on a port other than 80?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Yes. Nginx can be configured to listen on another port, such as 8080, by changing the appropriate <code>listen<\/code> directive in its configuration.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Related Articles<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/nginx-configuration-to-enable-acme-challenge-support-on-all-http-virtual-hosts\/\">Nginx configuration to enable ACME Challenge support on all HTTP virtual hosts<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/pheonixsolutions.com\/blog\/nginx-missing-sites-available-directory-in-the-nginx-configuration-directory\/\">Nginx missing sites-available directory in the Nginx configuration directory<\/a><\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Get Expert Nginx &amp; Linux Server Support<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Managing Nginx, Linux servers, firewalls, web applications, and production infrastructure can require careful configuration and ongoing monitoring. Our team can help with Nginx deployment, Linux server administration, security hardening, reverse proxy configuration, troubleshooting, monitoring, and performance optimization.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong><a href=\"https:\/\/pheonixsolutions.com\/contact\" data-type=\"link\" data-id=\"https:\/\/pheonixsolutions.com\/contact\">Connect with our technology experts<\/a><\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Post Date: September 30, 2018Last Updated: September 25, 2026 Introduction Nginx is a lightweight, high-performance web server and reverse proxy [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[1022],"tags":[415,423,422,421],"class_list":["post-2599","post","type-post","status-publish","format-standard","hentry","category-web-architecture","tag-centos-7","tag-firewalld","tag-http","tag-nginx-1-15-4","psol-cat-web-architecture"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/phn2x7-FV","jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/comments?post=2599"}],"version-history":[{"count":1,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2599\/revisions"}],"predecessor-version":[{"id":11926,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/posts\/2599\/revisions\/11926"}],"wp:attachment":[{"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/media?parent=2599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/categories?post=2599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pheonixsolutions.com\/blog\/wp-json\/wp\/v2\/tags?post=2599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}