Score:0

Can't set UserDir to ~/Home/public_html in Multipass on MacOS host

za flag

I'm on MacOS host, running a Multipass instance which I'm using as a LAMP server. Multipass maps ~/Home directory to the MacOS user directory and inside that directory I wanna have the public_html directory so I can develop from MacOS and the changes can be reflected in the Ubuntu LAMP.

Well, I've successfully enabled UserDir by running sudo a2enmod userdir, commenting out:

<IfModule mod_userdir.c>
    <Directory /home/*/public_html>
        php_admin_flag engine Off
    </Directory>
</IfModule>

from /etc/apatche2/mods-enabled/php8.1.conf

and replacing:

export APACHE_RUN_USER=www-data
export APACHE_RUN_GROUP=www-data

with

export APACHE_RUN_USER=ubuntu
export APACHE_RUN_GROUP=ubuntu

in /etc/apache2/envvars

With all of this, I now have a ~/public_html in which I can put html and php files and it works fine but if I edit /etc/apache2/mods-enabled/userdir.conf from /home/*/public_html to /home/*/Home/public_html it doesn't work! I'm getting the 403.

The permissions for the public_html and a file inside is as follows:

ubuntu@primary:~$ ls -la ~/Home/public_html/
total 12
drwxr-xr-x 1 ubuntu ubuntu   96 Jan 16 18:19 .
drwxr-xr-x 1 ubuntu ubuntu 1792 Jan 16 17:52 ..
-rwxr-xr-x 1 ubuntu ubuntu   17 Jan 16 18:19 test.php

What am I doing wrong? What's the way to achieve the desired result which I explained in the beginning?

in flag
When you say “it doesn’t work” do you mean that you’re receiving 500s? 404s? 403s? Fatal errors? Something else? Can I also confirm that on your MacOS host the full source directory is something like `/Users/kristijan/Home/public_html`?
Kristijan Zic avatar
za flag
I'm getting the 403. I've updated the post with the permissions info for the whole path.
in flag
Is the Ubuntu instance using AppArmor? If so, then you’ll need to add a rule to allow this different directory. AppArmor will prevent applications from accessing directories they shouldn’t have access to, which could be the reason for the 403.
Kristijan Zic avatar
za flag
I really have no idea why it doesn't work but I've realized that just symlinking whatever directory I want back into the ~/public_html like so: `ln -s ~/Home/public_html/ ~/public_html/public_html` works around the issue.
Kristijan Zic avatar
za flag
But yes, apparmor seems to be loaded: `$ sudo aa-status` `apparmor module is loaded. \ 33 profiles are loaded. \ 33 profiles are in enforce mode.`
Score:0
za flag

Just symlinking whatever directory you want back into the ~/public_html like so: ln -s ~/Home/public_html/ ~/public_html/public_html fixes the issue.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.