How to Install and Configure Apache for WordPress

Leave your reply

Introduction

Learn how to install and configure Apache for WordPress. WordPress is one of the world's most popular CMS and blogging software packages, and its famous "five minute install" makes it one of the easiest to use.

Most WordPress users will find that it works on their server without having to make any updates or changes to Apache. However, in some cases Apache may need to be updated or configured in order to run WordPress.

Requirements

  • A server running Linux
  • Root or sudo permissions

Note: For any 1&1 Cloud Server with Plesk, applications like WordPress should always be installed and managed through the Plesk interface. See our article Use WordPress on a 1&1 Cloud Server With Plesk for step-by-step instructions.

Checking Your Apache Version

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

  • CentOS and Red Hat: sudo httpd -v
  • Ubuntu and Debian: sudo apache2 -v

This will return information about your Apache server.

WordPress

In the example above, the server is running Apache version 2.4.6.

Updating Apache

The current version of WordPress requires Apache version 2.4 or later, in order to run the required version of PHP.

Note: Updating to the newest version of Apache can cause issues with older web software packages. Consult this list of changes to ensure that your website(s) will not be affected before you update Apache.

Ubuntu 14.04

On newer Ubuntu and Debian systems including Ubuntu 14.04, update Apache with the command:

sudo apt-get dist-upgrade

CentOS 6

On older CentOS and Red Hat systems including CentOS 6, update Apache with the commands:

  cd /etc/yum.repos.d/
  sudo wget http://repos.fedorapeople.org/repos/jkaluza/httpd24/epel-httpd24.repo
  sudo yum install httpd24.x86_64
  sudo chkconfig httpd off
  sudo service httpd24-httpd start

You can then check the version of the new installation with the command:

sudo /opt/rh/httpd24/root/usr/sbin/httpd -version

CentOS 7

On newer CentOS and Red Hat systems including CentOS 7, update Apache with the command:

sudo yum update

Installing mod_rewrite

WordPress uses Apache's mod_rewrite in order to format (and change the format of) its links.

To see if mod_rewrite is installed on your system:

  • Red Hat and CentOS: sudo httpd -M | grep rewrite_module
  • Ubuntu and Debian: sudo apache2ctl -M | grep rewrite_module

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

sudo a2enmod rewrite

After installing it, you will need to restart Apache services with the command:

service apache2 restart

Configuring Apache to Allow mod_rewrite

In some cases, Apache may need to be configured in order to allow mod_rewrite to run. To do this, you will first need to locate and edit the relevant Apache configuration file.

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:

  • Red Hat 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. By common convention, these are usually found at:

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

You will need to edit the file and find the directive:

AllowOverride None

Change it to:

AllowOverride All
Order allow,deny
Allow from all

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

  • Red Hat and CentOS: sudo systemctl restart apache
  • Ubuntu and Debian: sudo service apache2 restart

Leave your reply