How VPS - How to use/setup VPS
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Securing VPS/Servers

Updating Virtual Host Settings from Apache 2.2 to Apache 2.4

How VPS by How VPS
November 2, 2018
in Securing VPS/Servers, Upgrading
0
Updating Virtual Host Settings from Apache 2.2 to Apache 2.4
0
SHARES
9
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Make a Backup
  2. Virtual Host Settings Updates
    1. Ubuntu and Debian: Adding .conf Extensions
    2. All Distros: Permissions
  3. Default Virtual Host
  4. Module Configurations
  5. Errors From Non-Updated Settings
  6. Apache Upgrade Dates by Distribution
  7. More Information
    1. Join our Community

Updating Virtual Host Settings from Apache 2.2 to Apache 2.4

This guide explains the configuration changes needed to update a standard virtual host setup, such as the one presented here, from Apache 2.2 to Apache 2.4. These configuration updates are necessary, because a working Apache 2.2 virtual host setup will break silently when you upgrade to Apache 2.4. We’ll also discuss changes the new version of Apache makes to the default virtual host and module configuration.

Updating Virtual Host Settings from Apache 2.2 to Apache 2.4

Before you upgrade, you should make a backup of your main Apache 2.2 configuration file so you don’t lose any settings. However, keep in mind that if you try to use it as-is with Apache 2.4, incompatibilities can prevent Apache from starting or running.

This article is not a comprehensive guide to updating from Apache 2.2 to 2.4. For complete information, read the apache.org guidelines on the subject.

Make a Backup

Make a backup of your data before upgrading your Apache software. Upgrading can sometimes cause you to lose data, particularly if you had settings in an Apache configuration file that no longer apply in Apache 2.4. If you use Apache modules, this is especially likely.

Even with the simplest Apache setup, you should back up your Apache settings, modules, and other data in case unforeseen issues arise.

Virtual Host Settings Updates

You will have to make changes to your Apache 2.2 virtual hosts settings to make your websites work again with Apache 2.4. Blindly upgrading from Apache 2.2 to 2.4 will break for these reasons:

  • Ubuntu and Debian: Virtual host configuration files in the sites-available directory must now use the .conf extension
  • Virtual host configuration files must have the Require all granted line in an appropriate Directory block:

    virtual host configuration file
    1
    2
    3
    
    <Directory /path/to/public/website/>
       Require all granted
    </Directory>

Ubuntu and Debian users will need to make both changes. Users of other distributions will need to make the second change. We’ll go into detail on how to make these changes in the next two sections.

Ubuntu and Debian: Adding .conf Extensions

Follow these instructions at any time to update your virtual host configuration files. This change will work with Apache 2.2, so you can make it ahead of time. You can also do it right after you upgrade to Apache 2.4 to make your sites work again.

  1. Use the mv command to rename each virtual host file in your /etc/apache2/sites-available/ directory to include the .conf extension:

    mv /etc/apache2/sites-available/example.com /etc/apache2/sites-available/example.com.conf
    
  2. Use the a2ensite command to add the virtual host. Make sure you include the .conf extension:

    a2ensite example.com.conf
    
  3. Use the a2dissite command to disable the old virtual host. Make sure you do not include the .conf extension:

    a2dissite example.com
    
  4. Repeat Steps 1-3 for all of your virtual hosts.

  5. Reload Apache:

    service apache2 reload
    

Your sites have now been added to Apache. Now follow the instructions in the next section to make your sites available.

All Distros: Permissions

If you are utilizing access control rules within your virtual host files, you will need to follow these instructions to update your permissions for Apache 2.4. You cannot add the Require all granted line in Apache 2.2, or you’ll get a 500 Internal Server Error. Make this change just after updating to Apache 2.4.

  1. Open your website’s virtual host configuration file with your favorite text editor. For Ubuntu and Debian, this is typically a file like /etc/apache2/sites-available/example.com.conf. On CentOS and Fedora, this is typically /etc/httpd/conf.d/vhost.conf.

    Ubuntu and Debian (replace example.com.conf with your own file name):

    nano /etc/apache2/sites-available/example.com.conf
    

    CentOS and Fedora:

    nano /etc/httpd/conf.d/vhost.conf
    
  2. Within the VirtualHost block for this website, locate or create the Directory block for your website’s public directory. Add the line Require all granted. (If the line Require all denied is already there, update it to Require all granted). View a sample file below (replace /path/to/public/website/ with your website’s public directory):

    /etc/apache2/sites-available/example.com.conf or /etc/httpd/conf.d/vhost.conf
    1
    2
    3
    4
    5
    6
    7
    
    <VirtualHost *:80>
      ...
      <Directory /path/to/public/website/>
         Require all granted
      </Directory>
      ...
    </VirtualHost>
  3. Save your changes.

  4. Repeat Steps 1-3 for all of your virtual hosts.

  5. Reload Apache.

    Ubuntu and Debian:

    service apache2 reload
    

    CentOS:

    /etc/init.d/httpd reload
    

    Fedora:

    systemctl reload httpd.service
    

    Note

    For more information on how you can enable or restrict access to your websites with various Require lines, see the Apache website. Most users will want to use the Require all granted line, but there may be exceptions.

Check your websites. If you have completed these steps correctly, they should now be working again.

Default Virtual Host

If your Apache configuration file is replaced during the upgrade, the location of your default virtual host will change from /var/www to /var/www/html. You may have to disable the default virtual host again, if you don’t want it.

Module Configurations

If you have any Apache module configurations in your main configuration file that are incompatible with Apache 2.4, this can prevent the software from starting or running. In Apache 2.4, module configurations are no longer included in the main Apache configuration file. Instead, they each have their own configuration files, located in the mods-available/ or mods-enabled/ directories, and named something like module_name.conf.

The apache.org upgrade page is a good place to start when checking for incompatible modules.

Errors From Non-Updated Settings

The following symptoms may indicate that you need to make the changes to your Apache 2.4 configuration that are described in this article. Note that other causes can also produce these symptoms, so if you didn’t recently upgrade from Apache 2.2 to 2.4, you should pursue additional troubleshooting avenues.

Symptom: When you try to visit your website, you see the default It works! Apache web page.

Solution: Add the .conf extensions to your virtual host configuration files and re-add your sites, as detailed above. You can also make any desired changes to the Apache default site behavior. If you want to disable the default site, you must do so again.

Symptom: When you use the Apache a2ensite command, you receive the error Site example.com does not exist!

Solution: Make sure you have the .conf extension at the end of your configuration file name, and that you also use the .conf extension with the a2ensite command.

Symptom: When you try to visit your website, you see a 403 Forbidden message.

Solution: Add the Require all granted line to each of your virtual host configuration files, as detailed above.

Symptom: Apache fails to start or run.

Solution: Check for incompatible settings and modules in your Apache configuration files.

Apache Upgrade Dates by Distribution

Different distributions make Apache 2.4 the norm at different times. When you upgrade to one of the distributions in this chart, you will also be upgrading to Apache 2.4 by default.

Distribution Version Release Date
Ubuntu 13.10 out
Ubuntu 14.04 LTS April 17, 2014
Debian 8.0 late 2015 ?
CentOS ? ?
Fedora 19 out
Fedora 20 out
Gentoo NA ?
Arch NA in the AUR

Use this information to prepare for a smooth upgrade.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

  • apache.org

Join our Community

Find answers, ask questions, and help others.

This guide is published under a CC BY-ND 4.0 license.

How VPS

How VPS

Related Posts

How to Scan for Vulnerabilties with ClamAV
Securing VPS/Servers

How to Scan for Vulnerabilties with ClamAV

November 2, 2018
Securing VPS/Servers

Upgrading glibc for the GHOST Vulnerability

November 2, 2018
Create a Self-Signed TLS Certificate
Securing VPS/Servers

Create a Self-Signed TLS Certificate

November 2, 2018
Next Post

10 fdisk Commands to Manage Linux Disk Partitions

Set Date and Time for Each Command You Execute in Bash History

Use Public Key Authentication with SSH

Use Public Key Authentication with SSH

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Follow Us

  • 121 Followers
  • 87.2k Followers

Recommended

How to Install MODX Revolution on a FreeBSD 11 FAMP VPS

4 years ago

CentOS 7 and RHEL 7 Boot Process Overview and Troubleshooting

3 years ago

How To Install Just Cause 2 (JC2-MP) Server on CentOS 7

3 years ago

Securing SSH on Ubuntu 14.04

3 years ago

Instagram

    Please install/update and activate JNews Instagram plugin.

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

Topics

Apache Web Server Bluehost Review 2019 Bluehost Review 2020 Bluehost Review 2021 Centmin Mod CentminMod centos install htop fsck htop install HTTP DoS attack Install Snort on an Ubuntu install Zabbix on CentOS install Zabbix on CentOS 7 Linux Commands linux guide linux install htop linux vps setup guide MariaDB MariaDB Error Mysql mysqld error optimize MariaDB optimize Mysql snort Ubuntu
No Result
View All Result

Highlights

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Webmin Reviews

Virtualmin Reviews

CentOS Web Panel Reviews

Ajenti Reviews

ISPConfig Reviews

Trending

Failed to download metadata for repo 'appstream' on Centos 8
CentOS

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

by How VPS
February 25, 2022
0

I tried to update some extensions by use yum on centOs which I specified in Dockerfile. After...

How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020
Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

Top Free Web Hosting Control Panels To Manage VPS/Dedicated Servers

February 17, 2020
Webmin Reviews

Webmin Reviews

February 17, 2020
How VPS – How to use/setup VPS

We bring you the best Premium WordPress Themes that perfect for news, magazine, personal blog, etc. Visit our landing page to see all features & demos.
LEARN MORE »

Recent News

  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8 February 25, 2022
  • How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”? November 17, 2020
  • How to optimize Mysql or MariaDB November 3, 2020

Categories

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel

[mc4wp_form]

© 2018 JNews - City News Magazine WordPress theme. All rights belong to their respective owners.
JNews is a top selling 2018 WordPress News, Blog, Newspaper & Magazine Theme.

No Result
View All Result
  • Home

© 2023 JNews - Premium WordPress news & magazine theme by Jegtheme.