Forum Moderators: phranque

Message Too Old, No Replies

apache not serving with virtual host

         

tlgates

3:14 pm on Jan 20, 2005 (gmt 0)

10+ Year Member



I am using apache2 on redhat linux. I am trying to setup virtual hosts to serve. My pages display correctly using localhost and test.example.com but when I try to use my test.example_bs.com virtual host, the images, css, etc files that apache serves don't display. What am I doing wrong?

Here's my /etc/hosts file:
127.0.0.1 localhost.localdomain localhost
69.***.252.166 test.example.com

Here's my httpd.conf file:
Listen 69.***.252.166:80
Listen 127.0.0.1:80
ServerName test.example.com
NameVirtualHost *:80

<VirtualHost *:80>
ServerName localhost
ServerAlias test.example.com
DocumentRoot /var/www/html
</VirtualHost>

<VirtualHost *:80>
ServerName test.example_bs.com
DocumentRoot /var/www/html/example_bs
</VirtualHost>

I really need to get this working today. Your help is greatly appreciated!

[edited by: jdMorgan at 11:19 pm (utc) on Jan. 24, 2005]
[edit reason] No personal URLs/domains, please. [/edit]

mfroese

7:59 pm on Jan 20, 2005 (gmt 0)

10+ Year Member



While I'm not an expert on apache and virtual hosts, the following setup should get both sites displayed without errors. I have this setup running 30 vhosts on a single apache install.

Listen 69.***.252.166:80
Listen 127.0.0.1:80

#ServerName test.example.com <--commented on purpose
NameVirtualHost 69.***.252.166

<VirtualHost test.example.com>
ServerName test.example.com
ServerAlias 69.***.252.166
ServerAlias localhost
DocumentRoot /var/www/html
ErrorLog /var/log/test.example.com-error_log
CustomLog /var/log/test.example.com-access_log combined
</VirtualHost>

<VirtualHost test.example_bs.com>
ServerName test.example_bs.com
DocumentRoot /var/www/html/example_bs
ErrorLog /var/log/test.example_bs.com-error_log
CustomLog /var/log/test.example_bs-access_log combined
</VirtualHost>

The following configuration will also create vhost specific access and error logs unique to each domain for debugging purposes. Omit those to use the default access_log and error_log specified in your httpd.conf.

After making changes to httpd.conf, use the command 'apachectl configtest' before restarting the webserver. The output of errors should guide you to the problems, if all is ok then you will see 'Syntax OK'.

~MF

[edited by: jdMorgan at 11:22 pm (utc) on Jan. 24, 2005]
[edit reason] Obscured specifics per TOS. [/edit]

tlgates

10:29 pm on Jan 24, 2005 (gmt 0)

10+ Year Member



I tried what you said and it still doesn't display my images or css. I have checked the permissions and ownership of the directories and files and have set them to 755 and <username>:apache as the owner. I'm not sure what else to try.

PLEASE HELP!