Apache 2 Webserver 10.5

topic posted Thu, November 1, 2007 - 10:37 AM by  Pink
Share/Save/Bookmark
Advertisement
I deleted my previous thread because it was unreadable.

So I almost have my Virtual Server on Leopard running. The configuration is different with Apache 2 in that:

1) the httpd.conf file lives at
/etc/apache2/httpd.conf

instead of

/etc/httpd/httpd.conf

2) virtual hosts are enabled by uncommenting this line in /etc/apache2/httpd.conf
Include /private/etc/apache2/extra/httpd-vhosts.conf


I understand all that.

So in this file Include /private/etc/apache2/extra/httpd-vhosts.conf I cut and pasted my old Virtual Host configurations from my Tiger install.

When I do that it breaks and I get a Server Can't be Found Error. This is what that configuration looks like:


#
# Use name-based virtual hosting.
#
NameVirtualHost *

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#
Listen 80
<VirtualHost *:80>
DocumentRoot "/Users/pink/Sites"
ServerName localhost
</VirtualHost>

<VirtualHost *:80>
ServerName bardotagogo.dev
DocumentRoot "/Users/pink/Sites/bardotagogo.dev"
<Directory "/Users/pink/Sites/bardotagogo.dev">
Options All
AllowOverride All
</Directory>
</VirtualHost>

Listen 9020
<VirtualHost *:9020>
# ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/Users/pink/Sites/bardotagogo.dev"
<Directory "/Users/pink/Sites/bardotagogo.dev">
Options All
AllowOverride All
</Directory>
</VirtualHost>


<VirtualHost *:80>
ServerName frankenstein.dev
DocumentRoot "/Users/pink/Sites/frankenstein.dev"
<Directory "/Users/pink/Sites/frankenstein.dev">
Options All
AllowOverride All
</Directory>
</VirtualHost>


Listen 9000
<VirtualHost *:9000>
# ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/Users/pink/Sites/frankenstein.dev"
<Directory "/Users/pink/Sites/frankenstein.dev">
Options All
AllowOverride All
</Directory>
</VirtualHost>


Now if I remove this from that configuration:

Listen 80
<VirtualHost *:80>
DocumentRoot "/Users/pink/Sites"
ServerName localhost
</VirtualHost>

Then the virtual domains bardotagogo.dev and frankenstein.dev work fine. That is with a hosts file that looks like this:


##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost

127.0.0.1 frankenstein.dev
127.0.0.1 bardotagogo.dev




However, http:// localhost and http://127.0.0.1 go to the "bardotagogo.dev" folder. I actually want those requests to point to /Users/pink/Sites/ , which is how it worked with Tiger.

So apparently I know enough to get me in trouble. I sort of understand what is going on, but not enough to fix it how I want it. Any help would be appreciated.


PS

I also made this modification in the apache2/httpd.conf file:

DocumentRoot "/Users/pink/Sites"
#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
#
# First, we configure the "default" to be a very restrictive set of
# features.
#
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>

#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#

#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/Users/pink/Sites">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# httpd.apache.org/docs/2.2/...ml#options
# for more information.
#
Options Indexes FollowSymLinks MultiViews

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None

#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all

</Directory>

If I disable the virtual host include, then localhost, 127.0.0.1 and the airport IP address of the computer work fine, I just can'/t get to the virtual hosts.
posted by:
Pink
Los Angeles
Advertisement
Advertisement
  • Re: Apache 2 Webserver 10.5

    Thu, November 1, 2007 - 11:06 AM
    VirtualHosts are much easier to setup in Apache2, although I haven't done it on Leopard yet. I do run Apache2 on my Ubuntu-based webserver.

    All configs for Apache2 are typically in /etc/apache2/. Inside that dir you'll find more directories, such as:

    sites-available
    sites-enabled

    The beauty with this setup is that you can have configured VirtualHosts organized however you want within ./sites-available/ but they aren't enabled until you create a symlink to it in ./sites-enabled/ and restart Apache.

    So, as an example, I have a VirtualHost configuration setup for each of my domains and then, in ./sites-enabled/ is a symlink, prefixed with a 3-digit number, so I can control the order in which it VirtualHosts load.

    The syntax inside the configuration file is just like it was in Apache 1.3.
    • Re: Apache 2 Webserver 10.5

      Thu, November 1, 2007 - 12:14 PM
      Hmmm.

      I don't have a config setup like that. i don't have sites-available or sites-enabled.

      But after fooling around for the last two hours I do have WORKING VIRTUAL DIRECTORIES!!!!!

      Woot.

      So here is what I ended up doing:

      I replaced the Virtual Directories settings in /etc/apache2/extras/httpd-vhosts.conf

      from this:

      Listen 80
      <VirtualHost *:80>
      DocumentRoot "/Users/pink/Sites"
      ServerName localhost
      </VirtualHost>

      <VirtualHost *:80>
      ServerName bardotagogo.dev
      DocumentRoot "/Users/pink/Sites/bardotagogo.dev"
      <Directory "/Users/pink/Sites/bardotagogo.dev">
      Options All
      AllowOverride All
      </Directory>
      </VirtualHost>

      Listen 9020
      <VirtualHost *:9020>
      # ServerAdmin webmaster@dummy-host.example.com
      DocumentRoot "/Users/pink/Sites/bardotagogo.dev"
      <Directory "/Users/pink/Sites/bardotagogo.dev">
      Options All
      AllowOverride All
      </Directory>
      </VirtualHost>


      <VirtualHost *:80>
      ServerName frankenstein.dev
      DocumentRoot "/Users/pink/Sites/frankenstein.dev"
      <Directory "/Users/pink/Sites/frankenstein.dev">
      Options All
      AllowOverride All
      </Directory>
      </VirtualHost>


      Listen 9000
      <VirtualHost *:9000>
      # ServerAdmin webmaster@dummy-host.example.com
      DocumentRoot "/Users/pink/Sites/frankenstein.dev"
      <Directory "/Users/pink/Sites/frankenstein.dev">
      Options All
      AllowOverride All
      </Directory>
      </VirtualHost>


      to this:

      <VirtualHost *:80>
      ServerName localhost
      DocumentRoot "/Users/pink/Sites/"
      <Directory "/Users/pink/Sites/">
      Options All
      AllowOverride All
      </Directory>
      </VirtualHost>

      <VirtualHost *:80>
      ServerName bardotagogo.dev
      DocumentRoot "/Users/pink/Sites/bardotagogo.dev"
      <Directory "/Users/pink/Sites/bardotagogo.dev">
      Options All
      AllowOverride All
      </Directory>
      </VirtualHost>

      <VirtualHost *:80>
      ServerName frankenstein.dev
      DocumentRoot "/Users/pink/Sites/frankenstein.dev"
      <Directory "/Users/pink/Sites/frankenstein.dev">
      Options All
      AllowOverride All
      </Directory>
      </VirtualHost>



      Not only is it cleaner, but it works. The reason that I had the configuration I had before was incase I wanted someone else to access the files over a network. But I never needed that. (Though I would be interested in making that work again...) thus there were unique ports for each virt. host.

      So this is doing everything I want it to do, mainly let each host exist as a root to the webserver so I can have references in my HTML like "/images/pic.jpg"

      I guess there are many different ways to do things.

      No if i can figure out how to install mysql i'll be golden.

Recent topics in "Mac OS X"