# How to Install and Configure Apache for WordPress

Combining Apache with [WordPress](https://www.ionos.com/digitalguide/hosting/blogs/what-is-wordpress/) often works without having to make any updates or changes to the web server. However, in some cases, the server application needs to be updated or configured to run WordPress. Learn how to install and configure Apache for WordPress.

## What are the requirements for Apache for WordPress?

- A server running Linux
- Admin rights (root or sudo)

Note For cloud servers with Plesk, applications like WordPress should always be installed and managed through the Plesk interface. See our article on [using WordPress on a cloud server with Plesk](https://www.ionos.com/digitalguide/hosting/blogs/use-wordpress-on-a-cloud-server-with-plesk/) for step-by-step instructions.

## 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 respective command on your Linux system, you will get information about your Apache server, including the version number.

[![Image: Apache: Find out which version you have in the Ubuntu terminal](https://www.ionos.com/digitalguide/fileadmin/_processed_/a/2/csm_apache-show-version_c4a52fc754.webp "Apache: Find out which version you have in the Ubuntu terminal")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2023/apache-show-version.png) Find out which version you have in the Ubuntu terminal. In the example above, the [Ubuntu server](https://www.ionos.com/digitalguide/server/configuration/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 instructions on how to set up an [Apache web server](https://www.ionos.com/digitalguide/server/configuration/how-to-install-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 compatible 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](https://www.ionos.com/digitalguide/websites/web-development/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](https://httpd.apache.org/docs/current/upgrading.html "Apache Project: Upgrading from 2.2 to 2.4") carefully to ensure that your web application is not affected before upgrading Apache.

### Ubuntu and Debian

On newer Ubuntu and [Debian](https://www.ionos.com/digitalguide/server/know-how/debian-the-universal-system-software/) systems, including Ubuntu 22.04, install the latest version of Apache by first updating the package manager with the following command:

```bash
sudo apt update
```

The next step is to use the classic Apache2 installation command to perform the upgrade:

```bash
sudo apt install apache2
```

### CentOS, Fedora and RHEL

On newer [CentOS](https://www.ionos.com/digitalguide/server/know-how/what-is-centos-versions-system-requirements/) and RHEL/Fedora distributions, including CentOS 7, you can update Apache using the command:

```bash
sudo yum update
```

Note If the command does not work, you may first need to install and set up the EPEL (Extra Packages for Enterprise Linux) package tool. On Red Hat’s official website, you can find an EPEL [setup guide for RHEL and CentOS](https://www.redhat.com/sysadmin/install-epel-linux "Red Hat Guide: EPEL Installation").

## How to install mod\_rewrite

WordPress uses Apache’s `mod_rewrite` [rewrite engine](https://www.ionos.com/digitalguide/hosting/technical-matters/what-is-a-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:

```bash
sudo a2enmod rewrite
```

After installing it, you will need to restart Apache services using this command:

```bash
sudo systemctl restart apache2
```

You then regulate URL rewrites via a [.htaccess](https://www.ionos.com/digitalguide/hosting/technical-matters/htaccess-tricks/) file.

## 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 configuration file must be adapted accordingly. The specific file will depend on your server’s web hosting setup. By default, the main Apache configuration 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 configuration files for each individual 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 configuration file, open it with any text editor (administrator access) and look for the following:

```text
AllowOverride None
```

[![Image: Apache configuration file: Activate mod_rewrite](https://www.ionos.com/digitalguide/fileadmin/_processed_/2/2/csm_apache-mod-rewrite-entry_eb5729b073.webp "Apache configuration file: Activate mod_rewrite")](https://www.ionos.com/digitalguide/fileadmin/DigitalGuide/Screenshots_2023/apache-mod-rewrite-entry.png) Apache configuration file with mod\_rewrite module turned off Now replace the entry with the following:

```text
AllowOverride All
Order allow,deny
Allow from all
```

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

```bash
sudo systemctl restart apache2
```


This is a markdown version of: [https://www.ionos.com/digitalguide/server/configuration/how-to-install-and-configure-apache-for-wordpress/](https://www.ionos.com/digitalguide/server/configuration/how-to-install-and-configure-apache-for-wordpress/) for AI/LLM consumption.