Thursday, October 16, 2025

How to create apache2 alias myapp to directing to user myuser under directory /home/myuser/public

Note: FOR DEVELOPMENT NOT PRODUCTION!

Use root or sudo for sign with #

Use user myuser for sign $

Enable alias module

# a2enmod

Edit /etc/apache2/sites-available/000-default.conf

....
/etc/apache2/sites-available/000-default.conf
    Alias "/myapp" "/home/myuser/public"
    <Directory "/home/myuser/public">
        Options Indexes FollowSymLinks MultiVIews
        AllowOverride None
        Require all granted
    </Directory>
</VirtualHost>

Create directory public

$ mkdir public

Change the group ownership 

# chown -R myuser:www-data /home/myuser/public

Give the www-data group read and execute permissions. 

# chmod -R g+rx /home/myuser/public

Adjust the permissions for the home directory itself (not recommended for production, use ACL)

# chmod a+x /home/myuser

Test configuration

# apache2ctl configtest
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK

Restart service

# systemctl reload apache2

Open in your browser http://localhost/myapp