0

This is what I'm trying to do: change the default directory of apache2 from /var/www/html to /media/pi/storage/root_folder/

I have followed this tutorial > https://help.ubuntu.com/community/ApacheMySQLPHP#Virtual_Hosts

under section virtual hosts, I created a test html at /home/pi/Desktop/ and it works because of correct permissions.

Now when I do the exact same thing at /media/pi/storage/root_folder/ and reload the webpage, I get forbidden error message, suggesting that I have permission issues on my hard drive.

Will something like this work?

sudo chown -R USER:USER /media/pi/storage/root_folder/

And finally, how do I get these permissions to be applied for any new subdirectories and files in the future so that I don't run into the same forbidden error ever again?

I appreciate any help, thanks guys..

4
  • I know because, only one thing changed in my setup, that is only the directory, and forbidden simply tells me that's it's a permission issue, I haven't gone in depth with it but I think it's a pretty safe assumption. Also, it's a dead giveaway if the test html worked but not the one in my hard drive.
    – johndoe666
    Commented Dec 17, 2017 at 2:34
  • Output of ps aux | grep apache2 : root 469 0.0 0.4 7716 4044 ? Ss 03:18 0:00 /usr/sbin/apache2 -k start www-data 470 0.0 0.3 230116 3500 ? Sl 03:18 0:00 /usr/sbin/apache2 -k start www-data 471 0.0 0.3 230116 3500 ? Sl 03:18 0:00 /usr/sbin/apache2 -k start pi 994 0.0 0.0 4344 552 pts/0 S+ 03:27 0:00 grep --color=auto apache2
    – johndoe666
    Commented Dec 17, 2017 at 3:29
  • And output of groups is: pi adm dialout cdrom sudo audio video plugdev games users input netdev gpio i2c spi
    – johndoe666
    Commented Dec 17, 2017 at 3:33
  • This has been solved in my other post at ubuntu: askubuntu.com/questions/986999/…
    – johndoe666
    Commented Dec 17, 2017 at 7:01

1 Answer 1

0

Yes, changing the ownership of the filesystem tree rooted in /media/pi/storage/root_folder/ to (the user under which Apache Httpd runs, generally apache) should work as long as the user can access that filesystem tree (i.e. it must be able to "execute" the directories media, pi and storage.

However, if selinux is enable, the files may need to have additional permissions.

Run selinuxenabled && echo enabled to see whether it is enabled.

If so, run

chcon -vR --type=httpd_sys_content_t /media/pi/storage/root_folder

to change the SELinux context of the files under /media/pi/storage/root_folder (I'm not SELinux guru, but that works for me).

3
  • bash: selinuxenabled: command not found What else should I do?
    – johndoe666
    Commented Dec 17, 2017 at 2:41
  • Will something like chgrp -R www-data /username/ chmod -R 2750 /username/ work? Or something to do with the www-data group? Help me, I don't know what command to use, all I need is so that apache can access my hard drive located at /media/pi/storage/root_folder/ shouldln't be that hard, but I couldn't figure it out, I've been trying for a day now..
    – johndoe666
    Commented Dec 17, 2017 at 2:46
  • my permissions for root_folder in my hard drive is drwxrwxr-x 10 pi pi 4096 Dec 16 20:24 root_folder and the /var/www/html/ folder is drwxr-xr-x 2 root root 4096 Dec 16 21:33 html
    – johndoe666
    Commented Dec 17, 2017 at 2:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .