Install Apache for on-premises deployments apache
This guide walks you through installing Apache for Adobe Commerce on-premises deployments and configuring the Apache settings that Commerce requires. It includes shared Apache requirements and operating system-specific procedures for Ubuntu and CentOS. Adobe recommends following the configuration instructions provided in this guide to preserve both the functionality and security of the Commerce application.
Adobe supports the Apache versions listed in the system requirements for your Adobe Commerce release. Supported versions vary by release. Apache also requires a supported PHP configuration. For related PHP requirements, see PHP settings.
Start with the section that matches your environment:
- If Apache is already installed, start with Review Apache requirements.
- If you need to install or upgrade Apache on Ubuntu, go to Install or upgrade Apache on Ubuntu.
- If you need to install Apache on CentOS, go to Install Apache on CentOS.
Review Apache requirements
Complete these requirements on any Apache server that hosts Adobe Commerce.
Configure required directives
Set AllowEncodedSlashes in the server config (globally) or in the virtual host configurations to avoid decoding the encoded slashes that can cause issues for URLs. For example, when retrieving products with a slash in the SKU via the API, you do not want the slash converted. The following example block is not complete and other directives are required.
<VirtualHost *:443>
# Allow encoded slashes
AllowEncodedSlashes NoDecode
</VirtualHost>
Configure rewrites and .htaccess apache-rewrites-and-htaccess
Use this section to enable Apache rewrites and configure the distributed .htaccess file. Adobe Commerce uses server rewrites and .htaccess to provide directory-level instructions for Apache.
.htaccess.-
Enable the Apache rewrite module:
code language-bash a2enmod rewrite -
Enable the application to use the distributed
.htaccessconfiguration file.-
On Ubuntu, edit
/etc/apache2/sites-available/000-default.conf. For other Apache layouts or if additional parameters are required, see the Apache documentation and the Apache access control documentation. -
Add or update the
AllowOverridedirective for the directory where you plan to install Adobe Commerce.
For example, if you install Adobe Commerce in the default
docroot, add the following block to000-default.conf:code language-conf <Directory "/var/www/html"> AllowOverride All </Directory>note note NOTE If you upgraded from an earlier Apache version, first look for an existing <Directory "/var/www/html">or<Directory "/var/www">block in000-default.conf. If you install Adobe Commerce in a differentdocroot, update the matching<Directory>block for that path. -
-
Restart Apache to apply your changes:
code language-bash service apache2 restart
Install required modules
Adobe Commerce requires the following Apache modules to be installed:
Verify Apache is installed
To verify that Apache is installed and view the current version, enter:
apache2 -v
The result displays information similar to the following:
Server version: Apache/<installed-version>
Server built: <build-date>
-
If Apache is not installed, see:
Install or upgrade Apache on Ubuntu installing-or-upgrading-apache-on-ubuntu
Installing and configuring Apache on Ubuntu is a three-step process:
- Install the software.
- Enable rewrites.
- Specify
.htaccessdirectives.
When you configure Apache server rewrites, you must specify the type of directives that can be used in .htaccess, which the application uses to specify rewrite rules and security protections.
Install Apache on Ubuntu
-
Install Apache if you have not already done so:
code language-bash apt-get -y install apache2 -
Verify the installation:
code language-bash apache2 -vMessages similar to the following display to confirm that the installation was successful:
code language-text Server version: Apache/<installed-version> Server built: <build-date> -
Continue with the next section.
note note NOTE Even if Apache is provided by default with Ubuntu, see the following section to configure it.
Upgrade Apache on Ubuntu
If Apache is already installed and you are using a version earlier than 2.4, upgrade to Apache 2.4 or to the latest version supported by the Adobe Commerce version you have deployed. See system requirements.
-
Update package information:
code language-bash apt-get -y update -
Add a repository that provides a supported Apache version for your environment, if needed.
-
Install or upgrade Apache:
code language-bash apt-get install -y apache2note note NOTE If the apt-get installcommand fails because of unmet dependencies, consult your operating system package documentation or distribution support resources. -
Verify the installation:
code language-bash apache2 -v -
Confirm that the installed version matches the version supported for your Adobe Commerce release in system requirements.
Enable rewrites and .htaccess for Ubuntu
-
Open the
/etc/apache2/sites-available/000-default.conffile for editing:code language-bash vim /etc/apache2/sites-available/000-default.conf -
Locate the block that starts with:
code language-conf <Directory "/var/www/html"> -
Change the value of
AllowOverridetoAll.For example:
code language-conf <Directory "/var/www/html"> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all </Directory> -
Save the file and exit the text editor.
-
Configure Apache to use the
mod_rewritemodule:code language-bash cd /etc/apache2/mods-enabledcode language-bash ln -s ../mods-available/rewrite.load -
Restart Apache to apply changes:
code language-bash service apache2 restart
.htaccess.Install Apache on CentOS installing-apache-on-centos
Installing and configuring Apache on CentOS is a three-step process:
- Install the software
- Enable rewrites
- Specify
.htaccessdirectives.
When you configure Apache server rewrites, you must specify the type of directives that can be used in .htaccess, which the application uses to specify rewrite rules and security protections.
Installing Apache
-
Install Apache if you have not already done so.
code language-bash yum -y install httpd -
Verify the installation:
code language-bash httpd -vMessages similar to the following display to confirm that the installation was successful:
code language-text Server version: Apache/<installed-version> Server built: <build-date> -
Continue with the next section.
note note NOTE Even if Apache is provided by default with CentOS, see the following section to configure it.
Enable rewrites and .htaccess for CentOS
-
Open the
/etc/httpd/conf/httpd.conffile for editing:code language-bash vim /etc/httpd/conf/httpd.conf -
Locate the block that starts with:
code language-conf <Directory "/var/www/html"> -
Change the value of
AllowOverridetoAll.For example:
code language-conf <Directory "/var/www/"> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny Allow from all </Directory>note note NOTE The preceding values for Ordermight not work in all cases. For more information, see the Apache documentation. -
Save the file and exit the text editor.
-
To apply the Apache settings, restart Apache.
code language-bash systemctl restart httpd
.htaccess.Solving 403 (Forbidden) errors
If you encounter 403 Forbidden errors when trying to access the site, you can update your Apache configuration or your virtual host configuration to enable visitors to the site:
Solve 403 Forbidden errors for Apache
To enable website visitors to access your site, use one of the Require directives.
For example:
<Directory "/var/www/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Require all granted
</Directory>
Order might not work in all cases. For more information, see the Apache documentation.