Linux-Noob Forums

Full Version: Different document root within apache
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

Hi all, I'm a linux/apache noob, so i figure this is the best place for me :)

 

Anyhow, I just got a dedicated server with godaddy, using their "Simple Control Panel". It's running CentOS with apache 2, php4, mysql4.

 

My question is this: I want to be able to set my own document root. I add a domain name through the simple control panel, and it forces docroot for that domain to be /home/<username>/public_html/. Then it forces me to create a username, one that does not already exist.

 

I have over 50 domain names I will be migrating to this server, and a lot of them are located in subdirectories of my main domain. So my main domain, smartstreets.net is located in, say, /home/smartstreets/public_html/, I want MyOtherDomain.com to go to /home/smartstreets/public_html/members/<unique_member_id>/

 

I've tried using virtual hosts, and it doesnt make any difference, after restarting apache. Here's what I put for my virtual host:

 



Code:
<VirtualHost *>
ServerAdmin admin@smartstreets.net
DocumentRoot /var/www/html
ServerName trashylife.org
ServerAlias www.trashylife.org trashylife.org
ErrorLog /var/log/error.log
CustomLog /var/log/access.log common
</VirtualHost>




 

 

Note that im trying to make trashylife.org go to /var/www/html just to get it to work, thats one of my domains i dont care about being down. So because of the simple control panel stuff, its forced to be in /home/trashylife/public_html/ which has an index.html file that says "not working". I want it to go to /var/www/html/ which has an html file that says "its working" (or something like that).

 

So uhh, what am i doing wrong? Is there some sort of permissions i have to set on either /home/trashylife, or on /var/www/html? (note, i've tried to point that domain to other directories in /home/smartstreets/ with no luck.

 

Please let me know what I can do, if anybody can be of any help. I've got to get this stuff done within like a week, and I have a LOT of domains and databases and files to transfer over to this new server. Greatly appreciated, thank you!

 

 

---edit!---

Ok, totally accidentally, i found out that the simple control panel has a vhost conf file of its own. So i went in there and edited the document root for the trashylife.org domain to point to /home/smartstreets/public_html/ which has an index.html with simple text. NOW i get a 403 forbidden error. I'm assuming this is a permissions error, but what permissions should i give it, or how should i set the permissions on this directory so that it can serve the site? I want to keep it as secure as possible...

 

Thanks, I'm getting there!

 

--edit again--

got it! made the virtual host in /var/www/someFolder, which works. yay.


The permissions need to be set so the user apache can read the directory (and you need execute on the directory as it means 'allow the user to traverse this directory').

 

Try doing this:

 



Code:
ls -lh /var/www




 

If you get a response with a line like:

 

drwxr-xr-x 13 peter apache 4.0K Jun 7 22:33 someFolder

 

(the important bit here is the presence of the last r and x)

 

If not, then you can change the permissions. As root:

 



Code:
chmod o+r+x /var/www/someFolder




 

If everything appears fine with the filesystem permissions and the problem persists, it may be an Apache configuration problem. I recommend trying to access the site, then examining the last line of the error log.

 



Code:
tail -n 1 /var/log/httpd/error_log




 

Good luck with it! :)