Apache
Apache versions supported
Magento supports Apache 2.4.x.
Help if you are just starting out
If you’re new to all this and need some help getting started, we suggest the following:
- Is the Magento software installed already?
- What is the software that the Magento server needs to run?
- What operating system is my server running?
- How do I log in to my Magento server using a terminal, command prompt, or SSH?
Important: Apache rewrites and .htaccess
This topic discusses how to enable Apache 2.2 rewrites and specify a setting for the distributed configuration file, .htaccess
.
Magento uses server rewrites and .htaccess
to provide directory-level instructions for Apache. The following instructions are included in all of the other sections in this topic as well.
Use this section to enable Apache 2.4 rewrites and specify a setting for the distributed configuration file, .htaccess
Magento uses server rewrites and .htaccess
to provide directory-level instructions for Apache.
Failure to enable these settings typically results in no styles displaying on your storefront or Admin.
-
Enable the Apache rewrite module:
1
a2enmod rewrite
-
To enable Magento to use the distributed
.htaccess
configuration file, see the guidelines in the Apache 2.4 documentation.Note that in Apache 2.4, the server’s default site configuration file is
/etc/apache2/sites-available/000-default.conf
.For example, you can add the following to the end of
000-default.conf
:1 2 3
<Directory "/var/www/html"> AllowOverride <value from Apache site> </Directory>
In some cases, additional parameters might be required. For more information, see the Apache 2.4 documentation.
-
If you changed Apache settings, restart Apache:
1
service apache2 restart
- If you upgraded from an earlier Apache version, first look for
<Directory "/var/www/html">
or<Directory "/var/www">
in000-default.conf
. - You must change the value of
AllowOverride
in the directive for the directory to which you expect to install the Magento software. For example, to install in the web server docroot, edit the directive in<Directory /var/www>
.
- If you upgraded from an earlier Apache version, first look for
Use this section to enable Apache 2.2 rewrites and specify a setting for the distributed configuration file, .htaccess
Magento uses server rewrites and .htaccess
to provide directory-level instructions for Apache.
Failure to enable these settings typically results in no styles displaying on your storefront or Admin.
-
Open the following file for editing.
- Ubuntu:
vim /etc/apache2/sites-available/default
- CentOS:
vim /etc/httpd/conf/httpd.conf
- Ubuntu:
-
Locate the block that starts with:
- Ubuntu 12:
<Directory /var/www/>
- Ubuntu 14 or CentOS:
<Directory /var/www/html>
- Ubuntu 12:
-
Change the value of
AllowOverride
to<value from Apache site>
.An example for Ubuntu 12 follows.
1 2 3 4 5 6
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride <value from Apache site> Order allow,deny Allow from all <Directory>
The preceding values for
Order
might not work in all cases. For more information, see the Apache documentation (2.2), 2.4). - Save the file and exit the text editor.
-
Ubuntu only. Configure Apache to use the
mod_rewrite
module.1
cd /etc/apache2/mods-enabled
1
ln -s ../mods-available/rewrite.load
-
If you changed Apache settings, restart Apache.
1
service apache2 restart
Failure to enable these settings typically results in no styles displaying on your storefront or Admin.
Verify the Apache version
To verify the Apache version you’re currently running, enter:
1
apache2 -v
The result displays similar to the following:
1
2
Server version: Apache/2.2.22 (Ubuntu)
Server built: Jul 22 2014 14:35:32
- If Apache is not installed, see:
- Installing or upgrading Apache on Ubuntu
- [Installing Apache on CentOS]{#install-prereq-apache-centos}
- If Apache 2.2 is installed on Ubuntu 12 and you want to use PHP 5.6, see the next section
Installing or upgrading Apache on Ubuntu
The following sections discusses how to install or upgrade Apache:
- Install Apache
- Upgrade to Apache 2.4 on Ubuntu 12 to use PHP 7+
Installing Apache on Ubuntu 16, 14, or 12
To install the default version of Apache (Ubuntu 14, 16—Apache 2.4, Ubuntu 12—Apache 2.2):
-
Install Apache
1
apt-get -y install apache2
-
Verify the installation.
1
apache2 -v
The result displays similar to the following:
1 2
Server version: Apache/2.4.18 (Ubuntu) Server built: 2016-04-15T18:00:57
-
Enable rewrites and
.htaccess
as discussed in the following sections.
Enable rewrites and .htaccess for Apache 2.4
Use this section to enable Apache 2.4 rewrites and specify a setting for the distributed configuration file, .htaccess
Magento uses server rewrites and .htaccess
to provide directory-level instructions for Apache.
Failure to enable these settings typically results in no styles displaying on your storefront or Admin.
-
Enable the Apache rewrite module:
1
a2enmod rewrite
-
To enable Magento to use the distributed
.htaccess
configuration file, see the guidelines in the Apache 2.4 documentation.Note that in Apache 2.4, the server’s default site configuration file is
/etc/apache2/sites-available/000-default.conf
.For example, you can add the following to the end of
000-default.conf
:1 2 3
<Directory "/var/www/html"> AllowOverride <value from Apache site> </Directory>
In some cases, additional parameters might be required. For more information, see the Apache 2.4 documentation.
-
If you changed Apache settings, restart Apache:
1
service apache2 restart
- If you upgraded from an earlier Apache version, first look for
<Directory "/var/www/html">
or<Directory "/var/www">
in000-default.conf
. - You must change the value of
AllowOverride
in the directive for the directory to which you expect to install the Magento software. For example, to install in the web server docroot, edit the directive in<Directory /var/www>
.
- If you upgraded from an earlier Apache version, first look for
Enable rewrites and .htaccess for Apache 2.2
Use this section to enable Apache 2.2 rewrites and specify a setting for the distributed configuration file, .htaccess
Magento uses server rewrites and .htaccess
to provide directory-level instructions for Apache.
Failure to enable these settings typically results in no styles displaying on your storefront or Admin.
-
Open the following file for editing.
- Ubuntu:
vim /etc/apache2/sites-available/default
- CentOS:
vim /etc/httpd/conf/httpd.conf
- Ubuntu:
-
Locate the block that starts with:
- Ubuntu 12:
<Directory /var/www/>
- Ubuntu 14 or CentOS:
<Directory /var/www/html>
- Ubuntu 12:
-
Change the value of
AllowOverride
to<value from Apache site>
.An example for Ubuntu 12 follows.
1 2 3 4 5 6
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride <value from Apache site> Order allow,deny Allow from all <Directory>
The preceding values for
Order
might not work in all cases. For more information, see the Apache documentation (2.2), 2.4). - Save the file and exit the text editor.
-
Ubuntu only. Configure Apache to use the
mod_rewrite
module.1
cd /etc/apache2/mods-enabled
1
ln -s ../mods-available/rewrite.load
-
If you changed Apache settings, restart Apache.
1
service apache2 restart
Next steps
- Solving 403 (Forbidden) errors
- Continue with the next prerequisite (PHP Settings)
- Determine your installation or upgrade path
Upgrading Apache on Ubuntu 12
To use PHP 5.6 on Ubuntu 12, you must upgrade Apache to version 2.4. (By default, Ubuntu 12 comes with Apache 2.2.)
To upgrade to Apache 2.4:
-
Add the
ppa:ondrej
repository, which has Apache 2.4:1
apt-get -y update
1
apt-add-repository ppa:ondrej/apache2
1
apt-get -y update
-
Install Apache 2.4:
1
apt-get install -y apache2
If the ‘apt-get install’ command fails because of unmet dependencies, consult a resource like http://askubuntu.com.
-
Verify the installation.
1
apache2 -v
Messages similar to the following should display:
1 2
Server version: Apache/2.4.10 (Ubuntu) Server built: Jul 22 2014 22:46:25
-
Continue with the next section.
Enable rewrites and .htaccess for Apache 2.4
Use this section to enable Apache 2.4 rewrites and specify a setting for the distributed configuration file, .htaccess
Magento uses server rewrites and .htaccess
to provide directory-level instructions for Apache.
Failure to enable these settings typically results in no styles displaying on your storefront or Admin.
-
Enable the Apache rewrite module:
1
a2enmod rewrite
-
To enable Magento to use the distributed
.htaccess
configuration file, see the guidelines in the Apache 2.4 documentation.Note that in Apache 2.4, the server’s default site configuration file is
/etc/apache2/sites-available/000-default.conf
.For example, you can add the following to the end of
000-default.conf
:1 2 3
<Directory "/var/www/html"> AllowOverride <value from Apache site> </Directory>
In some cases, additional parameters might be required. For more information, see the Apache 2.4 documentation.
-
If you changed Apache settings, restart Apache:
1
service apache2 restart
- If you upgraded from an earlier Apache version, first look for
<Directory "/var/www/html">
or<Directory "/var/www">
in000-default.conf
. - You must change the value of
AllowOverride
in the directive for the directory to which you expect to install the Magento software. For example, to install in the web server docroot, edit the directive in<Directory /var/www>
.
- If you upgraded from an earlier Apache version, first look for
Next steps
- Solving 403 (Forbidden) errors
- Continue with the next prerequisite (PHP Settings)
- Determine your installation or upgrade path
Installing Apache on CentOS 6 or 7
Magento requires Apache use server rewrites. You must also specify the type of directives that can be used in .htaccess
, which Magento uses to specify rewrite rules.
Installing and configuring Apache is basically a three-step process: install the software, enable rewrites, and specify .htaccess
directives.
Installing Apache
-
Install Apache 2.4 if you haven’t already done so.
1
yum -y install httpd
-
Verify the installation:
1
httpd -v
Messages similar to the following display to confirm the installation was successful:
1 2
Server version: Apache/2.2.15 (Unix) Server built: Oct 16 2014 14:48:21
-
Continue with the next section.
Even though Apache 2.4 is provided by default with CentOS 7, you configure it like Apache 2.2. See the following section.
Enable rewrites and .htaccess for Apache 2.2 (including CentOS 7)
Use this section to enable Apache 2.2 rewrites and specify a setting for the distributed configuration file, .htaccess
Magento uses server rewrites and .htaccess
to provide directory-level instructions for Apache.
Failure to enable these settings typically results in no styles displaying on your storefront or Admin.
-
Open the following file for editing.
- Ubuntu:
vim /etc/apache2/sites-available/default
- CentOS:
vim /etc/httpd/conf/httpd.conf
- Ubuntu:
-
Locate the block that starts with:
- Ubuntu 12:
<Directory /var/www/>
- Ubuntu 14 or CentOS:
<Directory /var/www/html>
- Ubuntu 12:
-
Change the value of
AllowOverride
to<value from Apache site>
.An example for Ubuntu 12 follows.
1 2 3 4 5 6
<Directory /var/www/> Options Indexes FollowSymLinks MultiViews AllowOverride <value from Apache site> Order allow,deny Allow from all <Directory>
The preceding values for
Order
might not work in all cases. For more information, see the Apache documentation (2.2), 2.4). - Save the file and exit the text editor.
-
Ubuntu only. Configure Apache to use the
mod_rewrite
module.1
cd /etc/apache2/mods-enabled
1
ln -s ../mods-available/rewrite.load
-
If you changed Apache settings, restart Apache.
1
service apache2 restart
Next steps
- Solving 403 (Forbidden) errors
- Continue with the next prerequisite (PHP Settings)
- Determine your installation or upgrade path
Solving 403 (Forbidden) errors
If you encounter 403 Forbidden errors when trying to access the Magento site, you can update your Apache configuration or your virtual host configuration to enable visitors to the site as discussed in one of the following sections:
Solving 403 Forbidden errors for Apache 2.4
To enable website visitors to access your site, use one of the Require directives.
For example:
1
2
3
4
5
6
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride <value from Apache site>
Order allow,deny
Require all granted
</Directory>
The preceding values for Order
might not work in all cases. For more information, see the Apache documentation.
Solving 403 Forbidden errors for Apache 2.2
To enable website visitors to access your site, use the Allow directive.
For example:
1
2
3
4
5
6
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride <value from Apache site>
Order allow,deny
Allow from all
</Directory>
The preceding values for Order
might not work in all cases. For more information, see the Apache documentation.
Related topics