-   Linux - Software (
-   -   apache2 (

Pedroski 05-04-2013 03:17 AM

Is it not possible to have multiple virtual sites enabled in apache2 in /etc/apache2/sites-enabled?

On my computer I have

pedro@peterpu:/etc/apache2/sites-available$ ls
babypage babypage~ default default-ssl


pedro@peterpu:/etc/apache2/sites-enabled$ ls
babypage babypage~

Question: is it not possible to have more than one virtual site in /etc/apache2/sites-enabled?? I disabled 000default, because my page would not start. Now it does.

If it is possible to have more than one site 'available', how do I address babypage in my browser when sites-enabled has more than one entry?? When I enter peterpu I always get the default page (when it is enabled) in /var/www It would be good to keep the default for, well, defaults, but also address babypage.

sundialsvcs 05-04-2013 12:38 PM

Take a look at what these files actually contain, and you will see that they are <virtualhost> entries. The master httpd.conf file, at some point, includes the content of that directory, thereby textually incorporating all of the other entries as though it all were one great big, drawn out file. (The directory is scanned in alphabetic order, I believe.)

Any computer can host any number of sites. The DNS system must map all of the various domain-names to the same IP-address (yours ...), then the different <virtualhost> entries in the various files will enable Apache to sort them all out. It examines the HTTP headers to figure out what domain-name is being addressed, associates them with one of those entries, and does what that entry says to do.

You might have to set up an /etc/hosts file on your local box, to send these particular domain-names (via loopback to back to your Apache instance ... your computer will refer to that file before making a DNS inquiry for the domain-name. However you do it, that domain-name must wind up being sent to the IP-address and port where Apache is listening.

Each entry must be sufficient to cause Apache to correctly dispatch the incoming HTTP messages to the appropriate site definitions. Check the Apache log-files.

Apache must be (soft-) restarted after any file changes are made. (Also consider apachectl configtest, which scans the configuration for syntax errors.)

Pedroski 05-04-2013 07:14 PM

Thanks for that.

Now, I have babypage in sites-enabled, and after restarting apache, I enter peterpu in Firefox and get my webpage.

I had to actively disable the default, or that was the only page I got. So if I have 3 entries in sites-available, just out of interest, what must I enter in the browser to get a specific page? What must I enter elswhere to make say 3 different pages available?

Lets say I have the entries page1 page2 page3 in sites available, and I have done a2ensite for each one, and restarted apache2. This computer has the name peterpu How do I then choose which page??

All times are GMT -5. The time now is 03:22 PM.