On system (in my case is Ubuntu server) with have multiple user and each user permit to have their own home directory, then you need to install mod_userdir on your apache. So you can have the address like this: www.anyurl.com/~username/. Each user will have their own subdirectory specified by UserDir driective in the configuration.
To install userdir module in apache on ubuntu server is not hard. Only need a couple steps and change directory permission.
Follow these steps below:
- Open your terminal and login as root
- Go to apache directory, in Ubuntu default setting it would be in /etc/apache
- Now you need to install userdir module, type this command to install:
a2enmod userdir
- Then now edit the file userdir.conf, it would be in /etc/apache/mods-enabled directory
- Copy and paste this setting:
<ifModule mod_userdir.c> UserDir public_html UserDir disabled root <directory /home/*/public_html> #AllowOverride FileInfo AuthConfig Limit Indexes suPHP_Engine on AllowOverride All Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec FollowSymLinks <limit GET POST OPTIONS> Order allow,deny Allow from all </limit> <limitExcept GET POST OPTIONS> Order deny,allow Deny from all </limitExcept> </directory> </ifModule>
- Up to this step, you already activate userdir module. Now open another terminal with normal user. Then create public_html in home directory. Then change the directory group owner to www-data, with this command:
chgrp www-data public_html/
- Back to root terminal, then restart apache with this command:
/etc/init.d/apache restart
- Now open your browser and type: http://localhost/~username/ , you should see “It Works” if you got it right.
That’s it for now, leave me any comment if you find this article is helpful or if you want to ask anything. Thank you for visiting and have a nice day.
this is no good without suPHP installed and I don't want that as it wants to install the cgi php which is not what I want
this is no good without suPHP installed and I don't want that as it wants to install the cgi php which is not what I want
There is a little less complicated decision at http://ubuntuforums.org/showthread.php?t=1521010&page=1
Thanks mate
i have no permision to made mods-enabled… please help me how we change the permission??
You have to have root permission. if you don't have ask your administrator.
it works! thank you so much. Your document just solve my problem. !!
no worries 🙂
I have had to remove the line of code "suPHP_Engine on" from the userdir.conf file so apache could start again. An now without it php does not work when browsing to a users public_html folder. But it does still work in /var/www/
Please help
what is the apache error log? probably you should recompile php and suPhp.
Install the module on the terminal: sudo apt-get install libapache2-mod-suphp it's do work!
Good Look
thanks, i will try it.
I was struggling since the first days I started using Kubuntu as my operating system, I really wanted something similar to cpanel installations in my development environment.
Your article did the trick, good luck 😉
Hi, I followed your instructions but when I visit the http://localhost/~username/ page, it triggers a download and I get the following download error in a window: "/tmp/SeJ0SBf_.phtml-1.part could not be opened, because the associated helper application does not exist. Change the association in your preferences."
I looked online but could not find any solution . What can possibly be wrong ?
I've tried this (and just about everything else) but still get this error
Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
Fatal error: Unknown: Failed opening required '/home/lonetree/public_html/index.php' (include_path='.:/inc:./inc:../inc:../../inc:../../../inc:../../../../inc:/usr/share/php') in Unknown on line 0
Please help
I opened the /etc/apache2/mods-enabled directory, then see the php5.conf
<IfModule mod_php5.c>
<FilesMatch ".ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
To re-enable php in user directories comment the following lines
# (from <IfModule …> to </IfModule>.) Do NOT set it to On as it
#prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_value engine Off
</Directory>
</IfModule>
</IfModule>
So, I followed the instruction, voila!
I opened the /etc/apache2/mods-enabled directory, then see the php5.conf
<IfModule mod_php5.c>
<FilesMatch ".ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch ".phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
To re-enable php in user directories comment the following lines
# (from <IfModule …> to </IfModule>.) Do NOT set it to On as it
#prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_value engine Off
</Directory>
</IfModule>
</IfModule>
So, I followed the instruction, voila!