I have installed Apache(LAMP) web server on my ubuntu machine and I want to do the above mentioned thing.I have tried creating symbolic links in the /var/www directory but it only shows files but not directories inside the directory linked.I want to redirect /var/www to my home folder so that I can access all the files and directories contained therein.Please help me.

  • this is a very dangerous security hole you are aiming to open. Perhaps there is another way to achieve what you want and you could edit the question to let us know. – nass Nov 19 '13 at 16:28
  • I agree @nass's comment. There are at least a way to achieve what you wish but you may receive a better support if you reword your question in order to tell us what exactly is the task you wish to solve with this solution. Thank you! – Geppettvs D'Constanzo Nov 19 '13 at 16:55
  • @GeppettvsD'Constanzo suppose I have created a symbolic link (/var/www/one) to my home folder (/home/my_user).When I open my domain using my static ip address on another computer ,I can access folders contained in the home folder.But I cannot see any folders inside the folders of home folder, even when they are there.I can see the files inside the folders of home folder.I have given execute permissions to www-data user.What is the problem? – chanzerre Nov 19 '13 at 17:07
  • You need to give recursive permissions to the folders inside the home folder. Something like sudo chmod 755 * -R from within the home folder in a terminal. And, what's the purpose to gain access to these files? Maybe you wish to try ssh instead. – Geppettvs D'Constanzo Nov 19 '13 at 17:18
  • @GeppettvsD'Constanzo You're right, I should use ssh. – chanzerre Nov 19 '13 at 17:43

I must warn you that what you wish to do is very risky and I don't suggest you to do it so.

But if you yet wish to do it AT YOUR OWN RISK:

You can change your default folder for www content by editing the information provided inside the /etc/apache2/sites-available/default file. By dropping sudo gedit /etc/apache2/sites-available/default and changing any occurrence of the /var/www and setting the folder that you wish to use.

The contents of the file will look like this:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /home/geppettvs/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    <Directory /home/geppettvs/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from ::1/128


In this case I am using my /home/geppettvs/www folder in order to place the files that will be exposed to the public via http connections (port 80).

Give this a try. I hope this help you.

Please note that you may experience some issues when attempting to do certain things in some files or folders from the root directory if you don't give them the proper permissions but that's worth another question.

Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.