Need to migrate your e-mails to a new server? Free and paid versions of our online tool available.
Hero Image

Configure Apache Virtual Hosts on Arch Linux

Configure Apache Virtual Hosts on Arch Linux

Step 1 – Create document root

mkdir -p /var/www/example.com/html
echo '<h1>Works!</h1>' > /var/www/example.com/html/index.html
chown -R www-data:www-data /var/www/example.com 2>/dev/null || chown -R apache:apache /var/www/example.com 2>/dev/null || true

Step 2 – Create /etc/httpd/conf/extra/example.com.conf

<VirtualHost *:80>
    ServerName   example.com
    ServerAlias  www.example.com
    DocumentRoot /var/www/example.com/html
    <Directory /var/www/example.com/html>
        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted
    </Directory>
    ErrorLog  /var/log/apache2/example.com_error.log
    CustomLog /var/log/apache2/example.com_access.log combined
</VirtualHost>

Step 3 – Enable

Add Include conf/extra/example.com.conf to /etc/httpd/conf/httpd.conf, then:

systemctl reload httpd
apachectl configtest && systemctl reload apache2 2>/dev/null || apachectl configtest && rcctl reload apache2

Step 4 – Test

curl -H 'Host: example.com' http://localhost