I'm just trying to make a public_html folder under my username on a Red Hat Linux Server
(and it's all been a bit of a headache).
I made the folder and set the permissions to 755.
I wasn't sure how to deal with Apache (and admittedly finding the httpd.conf file was a nightmare, thanks to an unconventional directory layout), but now I've found it, I'm not sure what to do.
I've seen this question; Setting up individually accessible public_html for each user of a linux machine, but I don't understand the answer. How can I 'use mod_userdir' (I'm quite new to all of this).
I've looked at this;
http://httpd.apache.org/docs/2.0/mod/mod_userdir.html
Am I supposed to append something for the 'httpd..conf file?
I tried appending 'UserDir enabled username' to the top, and restart Apache, but still I can't find a page at;
domain.com/~username/
What could the problem be?
Am I using mod_userdir incorrectly? (I don't even know HOW to use it)
Thanks!
Best Answer
What RedHat version do you have installed? On RedHat 6.x it's pretty straightforward:
1) let's assume I have a user
ec2-user
created with home directory/home/ec2-user
2) create a directory
/home/ec2-user/public_html
and make sure that directory/home/ec2-user
and/home/ec2-user/public_html
have set permissions at least 0711 (executable bit set on other means thatapache
user under which apache2 web server is running will have permission to enter these directories). Additionally, any content of that directory has to be readable by theapache
user.3) enable
UserDir
module in apache2 web server configuration which is available in the file/etc/httpd/conf/httpd.conf
. Comment out the lineUserDir disabled
and uncomment the lineUserDir public_html
:4) test apache2 web server configuration with
httpd -t
, it should returnSyntax OK
otherwise something went wrong5) restart apache2 web server with
service httpd restart
and optionally, enable the service withchkconfig httpd on
on boot6) finally, if you have selinux enabled in
enforcing
mode - you can check it withsestatus
- you have to run this commandsetsebool -P httpd_read_user_content=on
to allow apache2 web server to read user content7) test it, e.g. from the server run
w3m http://localhost/~ec2-user
, if there are any errors they should be logged to the log file/var/log/httpd/error_log