In my development machine I always like to move the default /var/www directory to my home directory, e.g. /home/tareq/www . It’s very simple to do. Open the /etc/apache2/sites-available/default file with administrator previledge and change the document root as you want
$ sudo gedit /etc/apache2/sites-available/default
Now change the file like this:
DocumentRoot /home/tareq/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/tareq/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Now restart your apache
$ sudo /etc/init.d/apache2 restart
Update
According to Nasim vai, there is a more elegant solution with a single line command :-
$ sudo rm -r /var/www; sudo ln -s /home/${USER}/www /var/www
sudo chown -R $USER /var/www; ln -s /var/www /home/${USER}/www
That’s all you need!
@nsmgr8 I am using my home directory in a separate partition. If somehow my ubuntu installation gets corrupted, my home directory will be safe and I can install the system without much trouble. So I prefer to move the www directory to home instead a symbolic link
@tareq Then try the other way around
sudo rm -rf /var/www; sudo ln -s /home/${USER}/www /var/www
The point is not to touch default settings. Of course, there are thousand other ways to do it.
@tareq
Then try the other way around
sudo rm -r /var/www; sudo ln -s /home/${USER}/www /var/www
The point is not to touch default settings. Of course, there are thousand other ways to do it.
@nsmgr8 Thins one seems nice indeed
The symlink (second) way is better imo as it avoids changing config files. You should ad a caveat to your comment though warning people that they are deleting their current doc root and all files within using that method.