Most WordPress sites run on Linux servers, and CentOS has long been a common choice because of its stability. That stability usually also means the distribution ships with an older but well-tested kernel.
For many servers that default kernel is perfectly fine. In some cases, though, you may want a newer kernel for features such as BBR, newer drivers, newer KVM support, or other low-level improvements.
On CentOS 7, the usual approach is to enable the ELRepo repository and then install the latest kernel package from there.
Upgrade the kernel in CentOS 7 to the latest version
The default CentOS 7 repositories do not provide the newest Linux kernel, so the first step is to install and enable ELRepo.
# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
# rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
After the repository is enabled, list the available kernel packages:
# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
Once you confirm that the newer kernel is available, install it:
# yum --enablerepo=elrepo-kernel install kernel-ml
Set GRUB to boot the newest kernel by default
After installation, the server must be rebooted before the new kernel can be used. To avoid choosing it manually on every reboot, set it as the default boot entry.
Use the following command to make the first GRUB entry the default boot option:
grub2-set-default 0
Then confirm that the setting was saved correctly:
grub2-editenv list
Finally, rebuild the GRUB configuration file:
grub2-mkconfig -o /boot/grub2/grub.cfg
Reboot the server and verify which kernel is now running:
uname -sr
If the output shows the newer kernel you installed in the first step, the change worked.
A newer kernel can bring real benefits such as BBR support, newer hardware support, and newer virtualization features. Still, if you do not specifically need those improvements, the distribution’s default kernel is usually the safer choice on production servers.
