Need some apache vhosts help

Issues related to applications and software problems

Need some apache vhosts help

Postby dzhax » 2012/06/02 08:08:34

I am trying to get my apache2 server setup so I can go to example.com and pool.example.com and bring up different sites

In my httpd.conf i have the following
Code: Select all
### Section 3: Virtual Hosts

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin admin@garrett-innovations.com
    DocumentRoot /var/www/html
    RewriteEngine On
    RewriteRule ^/.* /var/www/html/index.php
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin admin@garrett-innovations.com
    DocumentRoot /var/www/vhost/pool.example.com
    ServerName www.pool.example.com
    ServerPath /pool/
    RewriteEngine On
    RewriteRule ^(/pool/.*) /var/www/vhost/pool.example.com
</VirtualHost>


When I type into the browser example.com it loads the site in the /var/www/html directory
When I type into the browser pool.example.com it loads "404 - Server not found"

Can anyone tell me what I am doing wrong?

I got the above configuration from Apache 2 - Virtual Host Examples. Scroll down to the last example "Using the ServerPath directive".

I only decided on this approach because it was the only one on the page that seemed to take sub-domains.


EDIT:
Was browsing youtube and decided to try another configuration
Code: Select all
### Section 3: Virtual Hosts

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin admin@garrett-innovations.com
    DocumentRoot /var/www/html
    ServerName example.com
    ServerAlias www.example.com
    CustomLog /var/www/logs/example.com-access.log combined
    ErrorLog /var/www/logs/example.com.co-error.log
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin admin@garrett-innovations.com
    DocumentRoot /var/www/vhost/pool.example.com
    ServerName pool.example.com
    ServerAlias www.pool.example.com
    CustomLog /var/www/logs/pool.example.com-access.log combined
    ErrorLog /var/www/logs/pool.example.com-error.log
</VirtualHost>


:-( however still have the same result
dzhax
 
Posts: 2
Joined: 2012/02/21 10:59:01

Re: Need some apache vhosts help

Postby alexm » 2012/06/05 17:25:29

This config:

ServerAdmin admin@garrett-innovations.com
DocumentRoot /var/www/vhost/pool.example.com
ServerName pool.example.com
ServerAlias www.pool.example.com
CustomLog /var/www/logs/pool.example.com-access.log combined
ErrorLog /var/www/logs/pool.example.com-error.log


looks better than your original one. For one thing, the ServerPath directive was incorrectly formatted (it's supposed to be a URL, iirc). Make sure that the /var/www/logs/pool.example.com-access.log and /var/www/logs/pool.example.com-error.log files actually exist (run the "touch" command to create them (touch /var/www/logs/pool.example.com-error.log; touch /var/www/logs/pool.example.com-access.log)).

OK, this may be an obvious question, but it needs to be asked: do you have an index.htm or index.html file in the /var/www/vhost/pool.example.com/ directory? If not, the web server won't be able to find the proper index file, and will generate a 404 error.

Another thing: are the directory structure permissions set to properly allow read and execute access for all users? For instance, an ls command at /var/www/vhost should look something like this:

drwxr-xr-x {##} {owner} {group} {dir size} {date} pool.example.com

If the permissions (drwxr-xr-x) don't look like this, the web server will not be allowed to access the pages for the user. The files in the directory need to be readable also (something like -rwxr--r--).

If this stuff doesn't help, try looking in your error log (/var/www/logs/pool.example.com-error.log), it may give you all the information that you need to fix the problem.

Good luck!
alexm
 
Posts: 20
Joined: 2012/06/04 21:04:55


Return to CentOS 6 - Software Support

Who is online

Users browsing this forum: No registered users and 1 guest