Combining Apache with WordPress often works without having to make any updates or changes to the web server. However, in some cases, the server ap­pli­ca­tion needs to be updated or con­fig­ured to run WordPress. Learn how to install and configure Apache for WordPress.

What are the re­quire­ments for Apache for WordPress?

  • A server running Linux
  • Admin rights (root or sudo)
Note

For cloud servers with Plesk, ap­pli­ca­tions like WordPress should always be installed and managed through the Plesk interface. See our article on using WordPress on a cloud server with Plesk for step-by-step in­struc­tions.

How to check your Apache version

You can find your version of Apache using the following commands:

  • Ubuntu and Debian: sudo apache2 -v
  • CentOS, Fedora and RHEL: sudo httpd -v

If you run the re­spec­tive command on your Linux system, you will get in­for­ma­tion about your Apache server, including the version number.

Image: Apache: Find out which version you have in the Ubuntu terminal
Find out which version you have in the Ubuntu terminal.

In the example above, the Ubuntu server is running Apache version 2.4.52.

Tip

Haven’t installed the web server on your Linux server yet? Read our step-by-step in­struc­tions on how to set up an Apache web server.

How to update Apache

The current version of WordPress requires Apache version 2.4 or later. This is so you can ensure that the web server is com­pat­i­ble with the PHP edition that is being used (7.4+). It also ensures that WordPress can fall back on the Apache mod_rewrite module. You can learn how to install PHP in our Digital Guide.

Note

Updating Apache from version 2.2 to 2.4 may cause problems with older web software packages. Read the following list of changes carefully to ensure that your web ap­pli­ca­tion is not affected before upgrading Apache.

Ubuntu and Debian

On newer Ubuntu and Debian systems, including Ubuntu 22.04, install the latest version of Apache by first updating the package manager with the following command:

sudo apt update
bash

The next step is to use the classic Apache2 in­stal­la­tion command to perform the upgrade:

sudo apt install apache2
bash

CentOS, Fedora and RHEL

On newer CentOS and RHEL/Fedora dis­tri­b­u­tions, including CentOS 7, you can update Apache using the command:

sudo yum update
bash
Note

If the command does not work, you may first need to install and set up the EPEL (Extra Packages for En­ter­prise Linux) package tool. On Red Hat’s official website, you can find an EPEL setup guide for RHEL and CentOS.

How to install mod_rewrite

WordPress uses Apache’s mod_rewrite rewrite engine to forward URLs and change them.

mod_rewrite is installed by default on CentOS and Red Hat systems. To install this module on Ubuntu and Debian, use the following command:

sudo a2enmod rewrite
bash

After in­stalling it, you will need to restart Apache services using this command:

sudo systemctl restart apache2
bash

You then regulate URL rewrites via a .htaccess file.

Managed Hosting for WordPress
Create your site with AI, we manage the rest
  • Stress-free, no matter your skill level with easy AI tools
  • Fully cus­tomiz­able with themes and plugins
  • Hassle-free updating and less admin

How to enable mod_rewrite in Apache

In some cases, you need to configure Apache in order for mod_rewrite to be executed. For this, the Apache con­fig­u­ra­tion file must be adapted ac­cord­ing­ly. The specific file will depend on your server’s web hosting setup. By default, the main Apache con­fig­u­ra­tion file for your server’s primary domain is:

  • RHEL, Fedora and CentOS: /etc/httpd/conf/httpd.conf
  • Ubuntu and Debian: /etc/apache2/apache2.conf

There may also be separate Apache con­fig­u­ra­tion files for each in­di­vid­ual domain. These are usually found at:

  • RHEL, Fedora and CentOS: /etc/httpd/conf.d/[your domain name].conf
  • Ubuntu and Debian: /etc/apache2/sites-available/[your domain name].conf

Once you have found the location of the con­fig­u­ra­tion file, open it with any text editor (ad­min­is­tra­tor access) and look for the following:

AllowOverride None
text
Image: Apache configuration file: Activate mod_rewrite
Apache con­fig­u­ra­tion file with mod_rewrite module turned off

Now replace the entry with the following:

AllowOverride All
Order allow,deny
Allow from all
text

Save and exit the file, then restart Apache with the command:

sudo systemctl restart apache2
bash
Go to Main Menu