If you’re using CentOS 8 (or EL8) and want to update Nginx to the latest official version, you’ll notice that the default installation might provide an older version of the web server, such as Nginx 1.14.1. In this guide, we’ll walk you through the steps to update Nginx and disable the older version.
Step 1: Disable and Uninstall the Old Version of Nginx
By default, CentOS 8 installs an outdated version of Nginx. To start the update process, you first need to disable the old Nginx module and remove the existing installation. This ensures that no conflicts occur when installing the latest version.
1. Disable the old Nginx module:
dnf module disable nginx php
2. Remove the old Nginx package:
dnf remove nginx*
Step 2: Add the Official Nginx Repository
CentOS 8 uses its own repository to install software, but it may not always have the latest version of Nginx. To get the most recent version, you need to add the official Nginx repository.
1. Edit the Nginx repository file:
nano /etc/yum.repos.d/nginx.repo
2. point to the official Nginx repository
Remove any existing content in the file and add the following lines to point to the official Nginx repository:
[nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ gpgcheck=0 enabled=1
Save the changes and exit the editor.
Step 3: Install the Latest Version of Nginx
With the official repository added, you can now install the latest stable version of Nginx.
1. Install Nginx:
yum install nginx
2. Verify Install
After the installation is complete, verify the version of Nginx installed:
nginx -V
This should show the latest version of Nginx.
For CWP (CentOS Web Panel) Users
If you’re using CWP, after installing the updated Nginx, it’s important to rebuild the web server configuration to ensure everything works correctly. Once completed, your server will be running the latest stable version of Nginx.
You May Also Like
- How to Optimize Apache, PHP, and MySQL Performance for a 1GB RAM VPS
- How to Reset the Root Password in MariaDB 10.5/10.4 and MySQL 8.0
- How to Create and Add Swap Space on Linux (CentOS, Ubuntu, CWP, and VestaCP)
- Photography Hacks: How to Create Compelling Product Images
- Boost Your Website Performance with These Content Creation Tips