Query: CentOS 6.2 Apache 2.2.15 Virtual Host Set-up
I've tried to set up a virtual host under Apache and I think I have some success, but I need to ask:
When I type a URL that includes the index file name, I get the proper web page. (http://xDrupalDocs.com/index.html). But when I just type in the domain name (http://xDrupalDocs.com), I get an error page from my ISP. Is this the proper behaviour? I've tried using the physical IP of the machine in place of the "*", but I get the same results. Here are the files: I omitted the domain name entirely in the /etc/hosts file. httpd.conf: Code:
#NameVirtualHost 192.168.1.149:80 |
You should have a DirectoryIndex directive in your httpd.conf, so you would add index.html to that, but if not you can add it to your virtual host definition, just after the line '<Directory "/home/DrupalDocs/htdocs">':
Code:
DirectoryIndex index.html |
Quote:
- There was already such a line in the httpd.conf file. - Adding the line under the <Directory> directive caused the display of the ISP's error page regardless of whether "xDrupalDocs.com/index.html" or simply "xDrupalDocs.com" was entered as a URL. - Removing all the DirectoryIndex directives also produces the ISP's error page regardless of the entry. - Same result if the outer directive is removed and only the inner directive is kept. |
Ahhh...now I'm in trouble. All the results changed when I undid the DirectoryIndex directive changes. Only one exists in the file, but now this is what happens:
- www.xDrupalDocs.com and xDrupalDocs.com/index.html go to the ISP error page. - xDrupalDocs.com goes to the default web page for Apache (var/www/html/index.html |
You mention your ISPs error page - do you know the actual HTTP error code returned?
Also, I notice you have two separate Options lines - I would combine them into one, without mixing the '+' and non-'+' options, so it looks like this: Code:
Options +Includes +FollowSymLinks +Indexes Code:
Options Includes FollowSymLinks Indexes |
I would also add, since you already have a DirectoryIndex line in your httpd.conf that specifies index.html, take it out of your vhost definition.
|
Quote:
The ISP error page is a large list of ads really, but has no error number. It says: "We did not find results for: www.xdrupaldocs.com". Here is the httpd.conf file: Code:
#NameVirtualHost 192.168.1.149:80 - www.xdrupaldocs.com and www.xdrupaldocs.com/index.html - bring up the ISP error page. - xdrupaldocs.com/index.html brings up /home/DrupalDocs/htdocs/index.html - this is the desired result. - simply xdrupaldocs.com - brings up the default Apache page /var/www/html/index.html. This is the original behaviour; I don't understand why it changed and then reverted back. I was careful to restart httpd in each case. |
Just to show you how dumb things get sometimes, I followed this guide: http://linuxconfig.org/configure-apa...host-on-fedora
Here are the steps: Step 1:Create a directory to contain your new website: # mkdir /var/www/example.net # echo Hello Web > /var/www/example.net/index.html # chmod -R 755 /var/www/example.net # chown -R apache.apache /var/www/example.net Step 2: Add virtual host configuration to the bottom of /etc/httpd/conf/httpd.conf : <VirtualHost *:80> DocumentRoot /var/www/example.net ServerName www.example.net # Other Apache config directives, logs etc. </VirtualHost> Step 3: Confirm the VirtualHost sytax before restarting httpd service: # httpd -S Step 4: Restart apache : # /etc/init.d/httpd restart Step 5: If your example domain is already pointing to your server you should be ready to go. Make sure that your domain resolves an IP address of your server. For testing it is also handy to modify /etc/hosts file. For example if this is done just locally add : # echo 127.0.0.1 www.example.net example.net >> /etc/hosts This is the end of the example. I carried out the steps - exactly as you see them. With this exact VirtualHost definition. <VirtualHost *:80> DocumentRoot /var/www/example.net ServerName www.example.net # Other Apache config directives, logs etc. </VirtualHost> I then went to the browser and entered the URL www.example.net and it came up with the text "Hello Web" as set in step 1. It worked perfectly! So mine is just too complex. HAHAHAHA. Seriously. I think it has to do with the domain name I chose; it must be a full normal name as in "www.domainname.com". I just chose "xDrupalDocs.com and not "www.xDrupalDocs.com". I'll try that. |
OK. I tried it and here are some results:
There was a permissions problem. All the files from /home/DrupalDocs on into the tree had to have their owner and group changed to "apache". Also, their permissions had to be changed to 755 as in: # chmod -R 755 /home/DrupalDocs # chown -R apache.apache /home/DrupalDocs Another important part was adding the domain names to the /etc/hosts file as the localhost IP of 127.0.0.1. Just some notes, though. - A URL of xdrupaldocs.com produces an ISP error page. - Yet a URL of example.net brings up the default Apache web page. This difference puzzles me. The final httpd.conf excerpt is: Code:
#NameVirtualHost 192.168.1.149:80 |
Quote:
Also, I don't think you can use wildcards in a ServerAlias. I would use this: Code:
ServerName xDrupalDocs.com |
Quote:
|
I think you're right slugmax. But this is purely for my own home LAN use. I had planned just to try to build web sites and then move them to hosting company. The current goal was just to be able to install and use both Drupal and Joomla dn see how they work.
Thanks for your time. I have to figure out how to mark the thread as solved. |
All times are GMT -5. The time now is 06:49 PM. |