Vhost Config issues

Jasper Frumau jasperfrumau at gmail.com
Fri Sep 3 03:04:21 PDT 2010


On Fri, Sep 3, 2010 at 1:54 PM, Ryan Schmidt <ryandesign at macports.org>wrote:

> On Sep 3, 2010, at 04:48, Jasper Frumau wrote:
>
> > OK I have activated virtualhosts by uncommenting this line in
> /opt/local/apache2/httpd.conf:
> >
> > $ cat httpd.conf | grep httpd-v
> > Include conf/extra/httpd-vhosts.conf
> >
> > in httpd-vhosts.conf I have:
> >
> > $ sudo cat httpd-vhosts.conf
> > #
> > # Virtual Hosts
> > #
> > # If you want to maintain multiple domains/hostnames on your
> > # machine you can setup VirtualHost containers for them. Most
> configurations
> > # use only name-based virtual hosts so the server doesn't need to worry
> about
> > # IP addresses. This is indicated by the asterisks in the directives
> below.
> > #
> > # Please see the documentation at
> > # <URL:http://httpd.apache.org/docs/2.2/vhosts/>
> > # for further details before you try to setup virtual hosts.
> > #
> > # You may use the command line option '-S' to verify your virtual host
> > # configuration.
> >
> > #
> > # Use name-based virtual hosting.
> > #
> > NameVirtualHost *:80
> >
> > #
> > # VirtualHost example:
> > # Almost any Apache directive may go into a VirtualHost container.
> > # The first VirtualHost section is used for all requests that do not
> > # match a ServerName or ServerAlias in any <VirtualHost> block.
> > #
> > <VirtualHost *:80>
> >     ServerAdmin webmaster at dummy-host.example.com
> >     DocumentRoot "/opt/local/www/"
> > #    ServerName dummy-host.example.com
> > #    ServerAlias www.dummy-host.example.com
> > #    ErrorLog "logs/dummy-host.example.com-error_log"
> > #    CustomLog "logs/dummy-host.example.com-access_log" common
> > </VirtualHost>
> > #
> > # Pull in all my virtual hosts, which are filename format of
> hostname.example.com.conf
> > # ie: ends in .conf
> > Include conf/extra/vhosts/*.conf
> > # -- END --
> > #
> > #<VirtualHost *:80>
> > #    ServerAdmin webmaster at dummy-host2.example.com
> > #    DocumentRoot "/opt/local/apache2/htdocs/apt1"
> > #    ServerName apt1
> > #</VirtualHost>
> >
> >
> > So all new VirtualHost configurations in conf/extra/vhosts/ should be
> loaded, right?
>
> Yes, you could do it like that if you want.
>
> Note that if your virtual hosts are located in subdirectories of
> /opt/local/www (as you showed us for your wordpress virtual host in the last
> email), then your default virtual host should definitely not have the
> document root /opt/local/www, otherwise anybody could access e.g. your
> wordpress via http://somehost/wordpress (where "somehost" is a hostname or
> IP address that points to your machine but is not mentioned specifically in
> a VirtualHost block) and could conceivably read files they should not have
> access to. Instead, set your default virtual host's document root to another
> subdirectory of /opt/local/www, for example /opt/local/www/default.
>
>
> > On Fri, Sep 3, 2010 at 1:16 PM, Jasper Frumau wrote:
> >
> >> So I d not need these lines:
> >>
> >>
> >> ##
> >> > 127.0.0.1    localhost
> >> > 127.0.0.1       jaspersmbp
> >> > 127.0.0.1       dev-wordpress.com
> >> > 255.255.255.255    broadcasthost
> >> > ::1             localhost
> >> > fe80::1%lo0    localhost
> >>
> >>  in my HOSTS file as long as I have vhost files to takae care of it? I
> see it still only understand a tiny bit...
>
> You do still need to define entries in /etc/hosts for every fake hostname
> you want to use. You can take a shortcut and put them all on one line if you
> like:
>
> 127.0.0.1 localhost jaspersmbp dev-wordpress.com
>

Did that. Now dev-wordpress.com goes to the root (/opt/local/www) and not to
opt/local/www/wordpress as indicated in
/opt/local/apache2/conf/extra/vhosts/wordpress.conf:

# START example.com
<VirtualHost *:80>
       DocumentRoot "/opt/local/www/wordpress/"
       ServerAdmin user at example.com
       ServerName dev-wordpess.com
       ServerAlias www.dev-wordpress.com
       DirectoryIndex index.php

       # php setttings
      # php_admin_value open_basedir "/opt/local/www/clients/last.first/
example.com/:/private/var/tmp/:"
       #php_value engine off

       <Directory "/opt/local/www/wordpress/">
               Options FollowSymLinks
               AllowOverride All
               Order allow,deny
               allow from all
       </Directory>
</VirtualHost>
# END example.com

I wonder if:

# Pull in all my virtual hosts, which are filename format of
hostname.example.com.conf
> # ie: ends in .conf
> Include conf/extra/vhosts/*.conf

in /opt/local/apache2/confextra/httpd-vhosts.conf is the correct path?

httpd.conf should be loading virtual hosts now using:

# Virtual hosts
Include conf/extra/httpd-vhosts.conf

right?

This all seems harder then I thought...
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macports-users/attachments/20100903/cfa68b5c/attachment.html>


More information about the macports-users mailing list