View Full Version : Symbolic link to htdocs on localhost?
loclarkey
February 12th, 2007, 03:18 AM
Hi community. I set up a LAMP server on my ubuntu box to test websites locally, courtesy of the people at XAMPP. It works like a charm, but my web root is located at //opt/lampp/htdocs. I would like for my web root to be at ~/Websites. In other words, I start the server, type http://localhost into a browser, and the contents of ~/Websites is displayed. I have never used symbolic links but I get the feeling that those could do the job. How do I do this?
kidders
February 12th, 2007, 03:34 AM
Hi there,
It sounds like the best thing to do might be to alter apache's config so the webroot is /home/loclarkey/Websites. If you wanted to, you could symlink /opt/lampp/htdocs to ~/Websites, but your stuff would still technically be in /opt, not /home.
This doesn't apply to your particular situation, but it's worth mentioning that afaik apache will refuse to follow symlinks below the webroot (for security reasons) unless you instruct it to do so. (Just in case you try it and wonder what's going on.)
Edit: What you want to do just dawned on me! You were asking about turning /opt/lampp/htdocs into a symlink, right? You can do that if you'd like to, either. In fact, /var/www (where my webroot is) is a symlink at the moment.
loclarkey
February 12th, 2007, 03:56 AM
Thanks for the prompt reply, kidders.
1) I tried the first approach you mentioned, and went into httpd.conf and changed the following values:
ServerRoot "/home/loclarkey/Websites"
DocumentRoot "/home/loclarkey/Websites"
<Directory "/home/loclarkey/Websites">
and restarted the server, but it is still using /opt/lampp/htdocs as the webroot. What am I missing?
2) Regarding the second option (creating symlinks), how do I do that specifically? I would like to use this as a learning opportunity. :)
kidders
February 12th, 2007, 04:08 AM
ServerRoot "/home/loclarkey/Websites"
DocumentRoot "/home/loclarkey/Websites"
<Directory "/home/loclarkey/Websites">Odd. Something is probably overriding those settings. On my apache installation, for instance, I have an /etc/apache2/sites-available directory that contains all my hosts. This fragmented config file style can be handy, but it's hell when you're trying to track something down!
If you've got something similar (lots of config files, all included in eachother), see if you can find the offending setting with something like find /etc/apache2 -type f -print -exec grep -i documentroot {} \; ... that will list all apache's configuration files, and show you any "DocumentRoot" lines along the way. If you only have one site, you should only see one "DocumentRoot", I suppose. I suspect though, that more than one will turn up.
Regarding the second option (creating symlinks), how do I do that specifically?Use ln to create links ... the man page has all the details. Basically, you would do something like ln -s /home/loclarkey/Websites /opt/lampp/htdocs.
loclarkey
February 12th, 2007, 04:42 AM
Okay, got it. I reverted httpd.conf to its original configuration. I don't know what was overriding that configuration.
Anyway, I put a symlink in htdocs pointing to the folder in my home directory. It didn't work at first because my permissions were too restrictive. But, I changed that and got it working. I can now keep all my www folders in my home folder.
Thanks for your help! Gotta love the ubuntu community.
vBulletin® v3.8.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.