Skip to content

Latest commit

 

History

History
328 lines (222 loc) · 9.24 KB

apache.md

File metadata and controls

328 lines (222 loc) · 9.24 KB
title functional_areas redirect_to status
Apache
Install
System
Setup
migrated

Apache versions supported {#apache-support}

Magento supports Apache 2.4.x.

Important: Apache required directives {#apache-required-directives}

  1. Set AllowEncodedSlashes in the server config (globally) or in the virtual host configurations to avoid decoding the encoded slashes that may cause issues for URLs. For instance, when retrieving products with a slash in the SKU via the API, you will not want that converted. The sample block is not complete and other directives will be required.

    <VirtualHost *:443>
      # Allow encoded slashes
      AllowEncodedSlashes NoDecode
    </VirtualHost>
    

Important: Apache rewrites and .htaccess {#apache-help-rewrite}

This topic discusses how 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. The following instructions are included in all of the other sections in this topic as well.

{% collapsible Click to show Apache 2.4 instructions %} {% include install/allowoverrides24.md %} {% endcollapsible %}

{:.bs-callout-info} Failure to enable these settings typically results in styles not displaying on the storefront or Admin.

Apache required modules {#apache-required-modules}

Magento requires the following Apache modules be installed:

Verify the Apache version {#install-prereq-apache-verify}

To verify the Apache version you're currently running, enter:

apache2 -v

The result displays similar to the following:

Server version: Apache/2.4.04 (Ubuntu)
Server built: Jul 22 2020 14:35:32

Installing or upgrading Apache on Ubuntu {#install-prereq-apache-ubuntu}

The following sections discusses how to install or upgrade Apache:

  • Install Apache
  • Upgrade to Apache 2.4 on Ubuntu to use PHP 7.4.

Installing Apache on Ubuntu {#install-prereq-apache-ubuntu-install}

{% collapsible Click to show/hide content %} To install the default version of Apache:

  1. Install Apache

    apt-get -y install apache2
  2. Verify the installation.

    apache2 -v

    The result displays similar to the following:

    Server version: Apache/2.4.18 (Ubuntu)
    Server built: 2020-04-15T18:00:57
    
  3. Enable rewrites and .htaccess as discussed in the following sections.

Enable rewrites and .htaccess for Apache 2.4

{% include install/allowoverrides24.md %}

{:.ref-header} Next steps

  • Solving 403 (Forbidden) errors
  • Continue with the next prerequisite ([PHP Settings]({{ page.baseurl }}/install-gde/prereq/php-settings.html))
  • [Determine your installation or upgrade path]({{ page.baseurl }}/install-gde/bk-install-guide.html)

{% endcollapsible %}

Upgrading Apache on Ubuntu {#install-prereq-apache-ubuntu-upgrade}

{% collapsible Click to show/hide content %}

To upgrade to Apache 2.4:

  1. Add the ppa:ondrej repository, which has Apache 2.4:

    apt-get -y update
    apt-add-repository ppa:ondrej/apache2
    apt-get -y update
  2. Install Apache 2.4:

    apt-get install -y apache2

    {:.bs-callout-info} If the 'apt-get install' command fails because of unmet dependencies, consult a resource like http://askubuntu.com.

  3. Verify the installation.

    apache2 -v

    Messages similar to the following should display:

    Server version: Apache/2.4.10 (Ubuntu)
    Server built: Jul 22 2020 22:46:25
    
  4. Continue with the next section.

Enable rewrites and .htaccess for Apache 2.4 {#enable-rewr-apache24-upgr-ubuntu12}

{% include install/allowoverrides24.md %}

{:.ref-header} Next steps

  • Solving 403 (Forbidden) errors
  • Continue with the next prerequisite ([PHP Settings]({{ page.baseurl }}/install-gde/prereq/php-settings.html))
  • [Determine your installation or upgrade path]({{ page.baseurl }}/install-gde/bk-install-guide.html)

{% endcollapsible %}

Installing Apache on CentOS {#install-prereq-apache-centos}

{% collapsible Click to install Apache on CentOS %} 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 {#apache-install-centos}

  1. Install Apache 2.4 if you have not already done so.

    yum -y install httpd
  2. Verify the installation:

    httpd -v

    Messages similar to the following display to confirm the installation was successful:

    Server version: Apache/2.4.40 (Unix)
    Server built: Oct 16 2020 14:48:21
    
  3. Continue with the next section.

    {:.bs-callout-info} Even if Apache 2.4 is provided by default with CentOS, see the following section to configure it.

Enable rewrites and .htaccess for CentOS

  1. Open /etc/httpd/conf/httpd.conf file for editing:

    vim /etc/httpd/conf/httpd.conf`
  2. Locate the block that starts with:

    <Directory "/var/www/html">
    
  3. Change the value of AllowOverride to All.

    For example,

    <Directory "/var/www/">
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      Allow from all
    </Directory>
    

    {:.bs-callout-info} The preceding values for Order might not work in all cases. For more information, see the Apache documentation (2.4).

  4. Save the file and exit the text editor.

  5. To apply Apache settings, restart Apache.

    service apache2 restart

{:.bs-callout-info} Failure to enable these settings typically results in no styles displaying on your storefront or Admin.

Enable rewrites and .htaccess for Ubuntu

  1. Open /etc/apache2/sites-available/default file for editing:

    vim /etc/apache2/sites-available/default
  2. Locate the block that starts with:

    <Directory "/var/www/html">

  3. Change the value of AllowOverride to All.

    For example:

    <Directory "/var/www/html">
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      Allow from all
    </Directory>
    
  4. Save the file and exit the text editor.

  5. Configure Apache to use the mod_rewrite module:

    cd /etc/apache2/mods-enabled
    ln -s ../mods-available/rewrite.load
  6. Restart Apache to apply changes:

    service apache2 restart

{:.ref-header} Next steps

  • Solving 403 (Forbidden) errors
  • Continue with the next prerequisite ([PHP Settings]({{ page.baseurl }}/install-gde/prereq/php-settings.html))
  • [Determine your installation or upgrade path]({{ page.baseurl }}/install-gde/bk-install-guide.html)

{% endcollapsible %}

Solving 403 (Forbidden) errors {#apache-error}

{% collapsible Click to install solve 403 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 {#apache-error-2-4}

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>

{:.bs-callout-info} The preceding values for Order might not work in all cases. For more information, see the Apache documentation. {% endcollapsible %}

{:.ref-header} Related topics

  • PHP
  • MySQL
  • [Configuring security options]({{page.baseurl }}/install-gde/prereq/security.html)
  • [Installing optional software]({{page.baseurl }}/install-gde/prereq/optional.html)
  • [Determine your installation or upgrade path]({{ page.baseurl }}/install-gde/bk-install-guide.html)