Jump to content

[SOLVED] Virtual Hosting Help Needed, Apache2 Ubuntu Intrepid


sjl127

Recommended Posts

Thank you, I'm new...

 

I have on my linux box apache2 and a wordpress install.

 

my /var/www directory is empty except for my website folder, mysitedotcom.

 

I have in my /etc/apache2/sites-available two files, default and mysitedotcom configured using this information:

 

http://linuxhelp.blogspot.com/2006/0...l-machine.html

 

In my /etc/apache2/sites-enabled I have two links named default and mysitedotcom

 

From my host box, it seems I can access everything fine.

 

But, when I'm outside of my lan, and either go to mysite.com or www.mysite.com, I get put into /var/www and not /var/www/mysitedotcom

 

Please help...  ??? ??? ???

This is what's in /var/www/sites-available/mysitedotcom

 

 

# FILE /etc/apache2/sites-available/mysitedotcom

NameVirtualHost mysite.com:80

<VirtualHost  mysite.com:80>
ServerAdmin webmaster@localhost
ServerName mysite.com
DocumentRoot /var/www/mysitedotcom/
<Directory />
	Options FollowSymLinks
	AllowOverride None
</Directory>
<Directory /var/www/mysitedotcom/>
	Options Indexes FollowSymLinks MultiViews
	AllowOverride None
	Order allow,deny
	allow from all
</Directory>

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
	AllowOverride None
	Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
	Order allow,deny
	Allow from all
</Directory>

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

I’ve searched everywhere and could not find a clear-cut way to configure Apache 2’s new design for linux for virtual hosting.

 

Let my trial-and-error help you have an easier time configuring your set-up.

 

My initial problems were learning how the old httpd.conf differed from the new apache2.conf with the addition of the new folders, sites-available and sites-enabled folders for virtual hosting.

 

When I found some other references and configured as told, when I would go to one of my sites, it would put me into my /var/www/ directory, which of course, has nothing in it except my two website folders.

 

Here’s how it worked for me.

 

I have two website that I host through one IP address.  This is my hosting directory structure:

 

/var/www/    contains no files and two folders:

 

/var/www/mysiteone

and

/var/www/mysitetwo

 

my    /etc/apache2/apache2.conf      contains nothing new, I did not touch it.

 

my  ./etc/apache2/sites-available/mysite1dotcom                contains:

    # FILE /etc/apache2/sites-available/mysite1dotcom

    NameVirtualHost *:80

    <VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName mysite1dotcom.com
    DocumentRoot /var/www/mysite1dotcom/
    <Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>
    <Directory /var/www/mysite1dotcom/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory “/usr/lib/cgi-bin”>
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

    Alias /doc/ “/usr/share/doc/”
    <Directory “/usr/share/doc/”>
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

    </VirtualHost>

 

The important things are at the very top of this file:

 

NameVirtualHost *:80
<VirtualHost *:80>

 

This is what each of your virtual host site files should say.  *:80

 

All I did was copy the ‘default’ file in my sites-available folder, pasted it twice and renaming them mysite1dotcom and mysite2dotcom.

 

Edit them, and make the necessary changes and additions:

 

    # FILE NEW VIRTUAL HOST FILE FOR MYSITE1DOTCOM

    NameVirtualHost *:80

    <VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/
    <Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>
    <Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory “/usr/lib/cgi-bin”>
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

    Alias /doc/ “/usr/share/doc/”
    <Directory “/usr/share/doc/”>
    Options Indexes MultiViews FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
    Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

    </VirtualHost>

 

What’s in RED are either additions or changes.

 

Then I created a link to these files in sites-enabled, restarted apache, and it works.

 

I hope this helps!

NameVirtualHost *:80 should only have to be used once /etc/apache2/apache.conf

 

For understanding Apaches file structure under Ubuntu I found the articles from http://articles.slicehost.com/ubuntu-intrepid very helpful.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.