PDA

View Full Version : [ubuntu] really simple problem from Apache newbie



jcorden
April 30th, 2010, 09:03 AM
Hi
I have just completed a LAMP installation on my Ubuntu (9.10) pc. Everything seems to be working fine and I can open test pages and interact with mySQL using phpmyadmin.

Currently I can only view html files (using Firefox) that are saved in the following directory on my pc.

/var/www

using the following url

http://localhost/

the html files that I would like to view are in this directory on my pc

home/james/webdevel

How do I redirect Apache (or what url do I use) so that I can view and process html and php files that reside in the webdevel directory? Am I correct in thinking I need to edit my httpd.conf file and where does this live?

Thanks

Bachstelze
April 30th, 2010, 09:14 AM
Am I correct in thinking I need to edit my httpd.conf file and where does this live?

Not necessarily. Apache cannot normally access files that are outside its DocumentRoot. There are several ways to achieve what you want, some of which don't require editing the Apache config file

-> If you don't use /var/www, you can just change your DocumentRoot to the directory your files are in. Of course make sure you give Apache permission to access it.

-> You can also create a subdirectory of /var/www (e.g. /var/www/webdevel) and do a mount -o bind /home/james/webdevel /var/www/webdevel. This will make the directory accessible by both names, and you should be able to access it at http://localhost/webdevel. Obviously, you can also do mount -o bind /home/james/webdevel /var/www.

-> Creating an alias in your Apache config file, like:


Alias /webdevel /home/james/webdevel

This will also make your files accessible at http://localhost/webdevel.

And a lot of others, but you probably want to look at one of those three.

jcorden
April 30th, 2010, 09:31 AM
Thanks for your help. I will try these.

Will there also be problems accessing mySQL from the webdevel directory?

Basically I want my webdevel directory to replicate the home directory on the webserver that I eventually use to host the site, so that when I copy the files to the webserver I can just upload the entire contents of the webdevel directory. Will this influence the best approach?

Bachstelze
April 30th, 2010, 11:15 AM
Will there also be problems accessing mySQL from the webdevel directory?

No, MySQL is totally independent of your Web server structure, and it not affected in any way by the location of the PHP file that accesses it.

krodrigue
May 1st, 2010, 08:52 AM
Why not just copy the files to /var/www

cp -r /home/james/webdevel /var/www

Kellemora
May 1st, 2010, 06:26 PM
Hi JC

Here is what I was instructed to do as being the safest method.

Open gedit and navigate your way to /var/www
then simply type sudo ln -s /home/me/webfiles/nameofyourfile.......
This will link the folder in your /home/me/webfiles directory to /var/www...
Works GREAT and keeps the BLOAT out of your system file area too!
And if you back up your /home directory, you've also saved all your web page work at the same time!

TTUL
Gary