Problem mit vhosts

Irgendwelche Probleme mit XAMPP für Mac OS X? Dann ist hier genau der richtige Ort um nachzufragen.

Problem mit vhosts

Postby heinetz » 08. January 2009 15:31

Hallo Forum,

ich bin vor kurzem aus dem Windoof-Lager zu Apple abgewandert und versuche mir eine
lokale Entwicklungsumgebung aufzubauen. Auf meinem Macbook habe ich mir deshalb
xampp installiert. Ich bin folgndermassen vorgegangen, um einen vhost zum Test zu definieren:

In der httpd.conf:

Code: Select all
# Virtual hosts
Include /Applications/xampp/etc/extra/httpd-vhosts.conf


In der httpd-vhosts.conf:

Code: Select all
<VirtualHost *:80>
    DocumentRoot "/Applications/xampp/xamppfiles/htdocs"
    ServerName test.leopold.net
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common
</Virtual
Host>

In der /ets/hosts:

Code: Select all
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##

127.0.0.1 root.home.net
127.0.0.1 test.leopold.net[/code]

.... funktioniert soweit. Unter http://test.leopold.net wird
der Inhalt von '/Applications/xampp/xamppfiles/htdocs'
angezeigt. Ich möchte meine Webprojekte aber unter:

/Users/meinverzeichnis/Sites/

... ablegen un habe deshalb die httpd-vhosts.conf angepasst:

Code: Select all
<VirtualHost *:80>
    DocumentRoot "/Users/martinhein/Sites/test"
    ServerName daimler-bkk26.leopold.net
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>


Nun lässt sich der Apache nicht mehr vernünftig starten (Internal Server Error).
Ich habe eine Ahnung, dass das mit den Rechten zuammenhängt, weiss
allerdings nicht, wie ich das anpassen kann ;(

Kann mir jemand einen Tipp geben ?

danke und

beste gruesse,
heinetz
heinetz
 
Posts: 88
Joined: 02. January 2004 12:37

Re: Problem mit vhosts

Postby glitzi85 » 08. January 2009 15:40

Internal Server Error ist normalerweise eine Ausgabe des Apachen, wenn dieser bereits läuft. Also entweder er startet nicht oder er läuft und bringt diese Fehlermeldung.

Zuer Fehlersuche poste bitte den Inhalt der Datei /Applications/xampp/logs/dummy-host.example.com-error_log hier.

Wenn du außerdem möchtest, dass die Domain daimler-bkk26.leopold.net ebenfalls auf deinen Apachen läuft, dann musst du diese ebenfalls in der hosts-Datei eintragen.

mfg glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Re: Problem mit vhosts

Postby heinetz » 08. January 2009 17:23

Ok, dann läuft er offenbar, wenn 'Internel Server Error' eine Ausgabe des Apachen ist.

Zu 'daimler-bkk26.leopold.net'
-------------------------
genau um den vhost geht es eigentlich. Ich hatte das nur versucht zu 'schwärzen' und gegen 'test'
ersetzt. Es geht also definitv um 'daimler-bkk26.leopold.net' und ist wie folgt konfiguriert:

httpd-vhosts.conf:
Code: Select all
#
# 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@dummy-host.example.com
#    DocumentRoot "/Applications/xampp/xamppfiles/docs/dummy-host.example.com"
#    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>
#
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host2.example.com
#    DocumentRoot "/Applications/xampp/xamppfiles/docs/dummy-host2.example.com"
#    ServerName dummy-host2.example.com
#    ErrorLog "logs/dummy-host2.example.com-error_log"
#    CustomLog "logs/dummy-host2.example.com-access_log" common
#</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/Users/martinhein/Sites/daimler-bkk26"
    ServerName daimler-bkk26.leopold.net
    ErrorLog "logs/dummy-host.example.com-error_log"
    CustomLog "logs/dummy-host.example.com-access_log" common
</VirtualHost>


/etc/hosts
Code: Select all
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   root.home.net
127.0.0.1   daimler-bkk26.leopold.net
127.0.0.1   localhost
255.255.255.255   broadcasthost
::1             localhost
fe80::1%lo0   localhost


dummy-host.example.com-error_log:
Code: Select all
[Thu Jan 08 17:05:32 2009] [alert] [client 127.0.0.1] /Users/martinhein/Sites/daimler-bkk26/.htaccess: Options not allowed here


OK, 'Options not allowed' in der .htaccess. Die ist ... bzw war also das Problem, dass sich auch
beheben liess, wenn nachdem ich sie geleert hatte. Trotzdem frage ich mich, warum die unter
OS X nicht, statt dessen aber auf meiner Windoof-Umgebung und dem Live-Server funktioniert.

.htaccess
Code: Select all
Options +FollowSymLinks

Options -Indexes

ErrorDocument 404 /_content/index.php

RewriteEngine On

RewriteBase /

#und hier folgen Rewriterules, die nicht funkltionieren können, weil z.B. eine Umleitung
#nach https erzwungen wird usw.


Wenn ich 'Options +FollowSymLinks' und 'Options -Indexes' auskommentiere funktioniert
sie. Was ist daran falsch, bzw. was ist die Misskonfiguration in meiner httpd.conf

httpd.conf:
Code: Select all
#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned. 
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
# with ServerRoot set to "/Applications/xampp/xamppfiles" will be interpreted by the
# server as "/Applications/xampp/xamppfiles/logs/foo.log".

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to point the LockFile directive
# at a local disk.  If you wish to share the same ServerRoot for multiple
# httpd daemons, you will need to change at least LockFile and PidFile.
#
ServerRoot "/Applications/xampp/xamppfiles"

#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 80

#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_dbd_module modules/mod_authn_dbd.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule file_cache_module modules/mod_file_cache.so
LoadModule cache_module modules/mod_cache.so
LoadModule disk_cache_module modules/mod_disk_cache.so
LoadModule mem_cache_module modules/mod_mem_cache.so
LoadModule dbd_module modules/mod_dbd.so
LoadModule bucketeer_module modules/mod_bucketeer.so
LoadModule dumpio_module modules/mod_dumpio.so
LoadModule echo_module modules/mod_echo.so
LoadModule case_filter_module modules/mod_case_filter.so
LoadModule case_filter_in_module modules/mod_case_filter_in.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule include_module modules/mod_include.so
LoadModule filter_module modules/mod_filter.so
LoadModule charset_lite_module modules/mod_charset_lite.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule cern_meta_module modules/mod_cern_meta.so
LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
LoadModule ident_module modules/mod_ident.so
LoadModule usertrack_module modules/mod_usertrack.so
LoadModule unique_id_module modules/mod_unique_id.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule ssl_module modules/mod_ssl.so
LoadModule mime_module modules/mod_mime.so
LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule asis_module modules/mod_asis.so
LoadModule info_module modules/mod_info.so
LoadModule suexec_module modules/mod_suexec.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule cgid_module modules/mod_cgid.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule imagemap_module modules/mod_imagemap.so
LoadModule actions_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
#LoadModule php5_module        modules/libphp5.so
#LoadModule php4_module        modules/libphp4.so

<IfDefine PHP4>
LoadModule php4_module        modules/libphp4.so
</IfDefine>
<IfDefine PHP5>
LoadModule php5_module        modules/libphp5.so
</IfDefine>


AddType application/x-httpd-php .php .php3 .php4 .php5
AddType application/x-httpd-php-source .phps
AddHandler cgi-script .cgi .pl

<IfModule !mpm_netware_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch. 
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User nobody
Group admin
</IfModule>

# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#

#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin you@example.com

#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName www.example.com:80

#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/Applications/xampp/xamppfiles/htdocs"

#
# 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 "/Applications/xampp/xamppfiles/htdocs">
    #
    # 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
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks ExecCGI Includes

    #
    # 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 AuthConfig

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

</Directory>

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html index.php index.htmls index.htm
</IfModule>

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>

#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog logs/error_log

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common

    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>

    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    CustomLog logs/access_log common

    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    #CustomLog logs/access_log combined
</IfModule>

<IfModule alias_module>
    #
    # Redirect: Allows you to tell clients about documents that used to
    # exist in your server's namespace, but do not anymore. The client
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://www.example.com/bar

    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.

    #
    # ScriptAlias: This controls which directories contain server scripts.
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client.  The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    #
    ScriptAlias /cgi-bin/ "/Applications/xampp/xamppfiles/cgi-bin/"

</IfModule>

<IfModule cgid_module>
    #
    # ScriptSock: On threaded servers, designate the path to the UNIX
    # socket used to communicate with the CGI daemon of mod_cgid.
    #
    #Scriptsock logs/cgisock
</IfModule>

#
# "/Applications/xampp/xamppfiles/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
Alias /phpmyadmin /Applications/xampp/xamppfiles/phpmyadmin
<Directory "/Applications/xampp/xamppfiles/phpmyadmin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>

<Directory "/Applications/xampp/xamppfiles/cgi-bin">
    AllowOverride None
    Options None +ExecCGI
    Order allow,deny
    Allow from all
</Directory>

Alias /phpsqliteadmin /Applications/xampp/xamppfiles/phpsqliteadmin
<Directory "/Applications/xampp/xamppfiles/phpsqliteadmin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>



#
# DefaultType: the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType text/plain

<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig /Applications/xampp/etc/mime.types

    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi

    # For type maps (negotiated resources):
    #AddHandler type-map var

    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    AddType text/html .shtml
    AddOutputFilter INCLUDES .shtml
</IfModule>

#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type.  The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
#MIMEMagicFile /Applications/xampp/etc/magic

#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://www.example.com/subscription_info.html
#

#
# EnableMMAP and EnableSendfile: On systems that support it,
# memory-mapping or the sendfile syscall is used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted
# filesystems or if support for these functions is otherwise
# broken on your system.
#
#EnableMMAP off
#EnableSendfile off

# Supplemental configuration
#
# The configuration files in the /Applications/xampp/etc/extra/ directory can be
# included to add extra features or to modify the default configuration of
# the server, or you may simply copy their contents here and change as
# necessary.

# Server-pool management (MPM specific)
#Include /Applications/xampp/etc/extra/httpd-mpm.conf

# Multi-language error messages
#Include /Applications/xampp/etc/extra/httpd-multilang-errordoc.conf

# Fancy directory listings
#Include /Applications/xampp/etc/extra/httpd-autoindex.conf

# Language settings
#Include /Applications/xampp/etc/extra/httpd-languages.conf

# User home directories
Include /Applications/xampp/etc/extra/httpd-userdir.conf

# Real-time info on requests and configuration
#Include /Applications/xampp/etc/extra/httpd-info.conf

# Virtual hosts
Include /Applications/xampp/etc/extra/httpd-vhosts.conf

# Local access to the Apache HTTP Server Manual
#Include /Applications/xampp/etc/extra/httpd-manual.conf

# Distributed authoring and versioning (WebDAV)
#Include /Applications/xampp/etc/extra/httpd-dav.conf

# Various default settings
#Include /Applications/xampp/etc/extra/httpd-default.conf

# Secure (SSL/TLS) connections
#Include /Applications/xampp/etc/extra/httpd-ssl.conf

<IfDefine SSL>
   Include /Applications/xampp/etc/extra/httpd-ssl.conf
</IfDefine>


#
# Note: The following must must be present to support
#       starting without SSL on platforms with no /dev/random equivalent
#       but a statically compiled-in mod_ssl.
#
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>


Und noch etwas ist mir unklar:

Warum zeigt nun httpd://localhost den Inhalt von daimler-bkk26.leopold.net an ?

schönen Abend und

beste gruesse,
heinetz
heinetz
 
Posts: 88
Joined: 02. January 2004 12:37

Re: Problem mit vhosts

Postby glitzi85 » 08. January 2009 17:33

Ah, das hatte ich vergessen. Die Einstellungen, was alles gesetzt werden darf in der .htaccess ist für das htdocs-Verzeichnis konfiguriert. Wenn du nun deine Seite woanders abspeicherst, musst du noch einen entsprechende Block setzen. Die Seite hätte im htdocs-Verzeichnis funktioniert. Hier dein vHosts-Einstellungen:

Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
  DocumentRoot "/Applications/xampp/xamppfiles/htdocs"
  ServerName localhost
</VirtualHost>

<VirtualHost *:80>
  DocumentRoot "/Users/martinhein/Sites/daimler-bkk26"
  ServerName daimler-bkk26.leopold.net
  ErrorLog "logs/dummy-host.example.com-error_log"
  CustomLog "logs/dummy-host.example.com-access_log" common
  <Directory "/Users/martinhein/Sites/daimler-bkk26">
    AllowOverride All
    Order allow,deny
    allow from all
  </Directory>
</VirtualHost>


außerdem noch diese zwei Zeilen in der hosts-Datei löschen oder auskommentieren:

Code: Select all
::1             localhost
fe80::1%lo0   localhost


außer du verwendest explizit IPv6.

mfg glitzi

PS: Sobald du VirtualHosts aktivierst, musst du auch einen vHost-Block für localhost erstellen!
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Re: Problem mit vhosts

Postby heinetz » 08. January 2009 21:55

Super!
Danke für die kompetente Hilfestellung.

Ich arbeite nun seit fast 10 Jahren mit xampp bzw. wamp und habe
das alles irgendwie nur noch benutzt, ohne wirklich zu wissen, was
da alles so in der httpd.conf definiert ist. Ich war froh, wenn's dann
lief und hab mich nicht weiter interessiert.

Das will ich jetzt anders machen und beim Aufsetzen meiner Entwicklungs-
umgebung unter OS X alles besser durchdenken. Deshalb setze ich Deinen
Vorschlag nicht einfach um, obwohl ich davon überzeugt bin, dass er funktioniert,
sondern frage nach:

1 - localhost )
Was mir immernoch irgendwie komisch vorkommt, ist dass locahost
auf den Inhalt des vhost zeigt. Was würde z.B. passieren, wenn ich einen
weiteren vhost (darunter) definiere. Wird dann localhost auf den Inhalt
zeigen ? Nach meinem Verständnis müsste http://127.0.0.1 doch auf
das DocumentRoot des Servers zeigen. Was sorgt dafür, dass diese
Direktive (?) durch die Definition des vhost überschrieben wird ? Ist
es der Stern ('<VirtualHost *:80>') ? Dann dürfte sich das doch eigentlich
genauso verhalten, wenn ich den localhost-vhost nach dem anderen
definiere.

2 - DocumentRoot )
Wenn DocumentRoot die .htaccess-Optionen gesetzt sind und ich
diese Definition dann für vhosts ausserhalb des DocumentRoot
dann in den vhosts selbst definieren muss, habe ich jetzt verstanden,
warum es das DocumentRoot gibt und warum es Sinn macht, die
DocumtRoots der vosts darunter liegen sollten - weil man dann
die Möglichkeit hat, alles global zu definieren und diese Definition
für Einzelfälle innerhalb der vhosts zu überschreiben.

Ich werde mal das DocumentRoot anpassen und nach /Users/martinhein/Sites/
zeigen lassen.

Und noch etwas hinterher, worüber ich mir schon seit einiger Zeit Gedanken mache:
------------------------------------------------------------------

Meine Windoof-Entwicklungsumgebung sah so aus, dass xampp auf einem
W2K-Server (192.168.1.150) lief und ich mit verschiedenen Workstations im
LAN darauf zugreifen konnte. Dazu habe ich, um nicht die hosts-Dateien auf
allen Workstations pflegen zu müssen, auf dem W2K-Server den Nameserver
eingerichtet und die vhosts dort definiert. So musste ich auf den Workstations
nur 192.168.1.150 als primären DNS eintragen.

Obwohl nun ja Workstation und Server eine Maschine sind und ein Nameserver
daher eigentlich keinen Vorteil gegenüber der hosts-Datei hat, würde mich mal
interessieren, ob ich das auf dem Macbook auch so machen kann - oder ist das
supersinnlos ;)

schönen Dank und

beste gruesse,
heinetz
heinetz
 
Posts: 88
Joined: 02. January 2004 12:37

Re: Problem mit vhosts

Postby glitzi85 » 08. January 2009 22:42

Das ganze ist etwas komplex, aber ich versuch es mal. Die ganzen Einstellungen des Apachen werden vererbt. Am Anfang hat jede Einstellung einen Default-Wert (kannst du in der Doku nachschauen welcher das ist). In der httpd.conf werden dann gewisse Sachen geändert, unter anderem der DocumentRoot under der ServerName (die zwei wichtigsten).

Wenn du jetzt einen VirtualHost-Block aufmachst, dann werden alle Einstellungen vom Hauptserver übernommen. Der 1. VirtualHosts-Block wird dann allerdings als einziger Server verwendet. Wenn du darin also nun die beiden Einstellungen umbiegst, dann werden die Haupteinstellungen einfach überschrieben (in dieser Instanz).
Sobald du einen zweiten VirtualHost anlegst, werden wieder die Daten aus der Hauptinstanz übernommen, allerdings hast du dann schon einen zweiten Server. Hier mal zur Veranschaulichung:
Code: Select all
ServerName localhost
DocumentRoot /opt/lampp/htdocs

NameVirtualHost *:80

<VirtualHost *:80>
</VirtualHost>

<VirtualHost *:80>
  ServerName test2
  DocumentRoot /home/test/htdocs
</VirtualHost>

<VirtualHost *:80>
  ServerName test
</VirtualHost>

Theoretisch sollte das als httpd.conf funktionieren. Ganz oben werden also der ServerName und der DocumentRoot definiert. Im ersten VirtualHosts-Block werden diese Einstellungen also einfach übernommen. Im zweiten werden beide Einstellungen geändert und im dritten nur der ServerName. Wichtig ist nun zu erkennen, dass der dritte den DocumenRoot von ganz oben erbt, nicht vom VirtualHost-Block davor! Das ganze würde nun so aussehen:
Code: Select all
localhost: /opt/lampp/htdocs
test2: /home/test/htdocs
test: /opt/lampp/htdocs


Jetzt ist zur Sicherheit aber noch bei jeder Standardinstallation das hier in der httpd.conf eingebaut:

Code: Select all
<Directory />
  AllowOverride None
  Order allow,deny
  deny from all
</Directory>


Das Grundprinzip vom Apachen ist: Alles ist zugänglich, außer es ist explizit gesperrt. Der obige Code dreht das ganze um und definiert: Alles ist gesperrt, außer es ist explizit freigegeben. In der XAMPP-Installation ist jetzt der Zugriff auf das Verzeichnis /opt/lampp/htdocs freigegeben (<Directory /opt/lampp/htdocs>-Block in der httpd.conf). Daher kommen auch die vielen Anfragen hier, warum das ganze nicht mehr klappt wenn man den DocumentRoot verschiebt. Und genau aus diesem Grund muss bei dir im zweiten VirtualHost-Block ebenfalls dieser Directory-Block drin sein. Theoretisch könntest du den Directory-Block auch in die Hauptdirektive mit aufnehmen, dann erben diese Freigabe aber wiederum alle VirtualHosts, wass bei deiner Konfiguration wieder unnötig ist. Immer das Prinzip: So wenig wie möglich, so viel wie nötig freigeben.

Zum Nameserver: Sinnlos ist es irgendwie schon, aber selbstverständlich möglich. Richtig sinnlos wird's aber erst, wenn du die Domains im Nameserver auf 127.0.0.1 konnektierst, weil dann gibt's keinen Unterschied mehr zur hosts-Datei :D

mfg glitzi

Edit: Sind jetzt halt Linux-Pfade, sollte ja aber egal sein.
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Re: Problem mit vhosts

Postby heinetz » 09. January 2009 01:03

Erstmal danke für die umfassende Erklärung !

Mittlerweile glaube ich an garnichts mehr.
Opera zeigt etwas anderes an, als Firefox. :shock:

Ich sollte mich besaufen,
dann wär mir wenigstens
klar, warum :wink:

gute nacht,
heinetz
heinetz
 
Posts: 88
Joined: 02. January 2004 12:37

Re: Problem mit vhosts

Postby glitzi85 » 09. January 2009 01:44

In dem Fall ist das wichtigste, dass du den Browser Cache komplett leerst. Sonst wird es recht ungemütlich beim testen, da dann ständig irgendwelche Teile aus dem Cache gezogen werden.

mfg glitzi
User avatar
glitzi85
 
Posts: 1920
Joined: 05. March 2004 23:26
Location: Dahoim

Re: Problem mit vhosts

Postby heinetz » 09. January 2009 22:38

schon klar - ich quäl' mich halt seit nem halben jahr in mein neues OS X und bei
auf Windows-Rechnern wird auf Shift-Reload immer eine 'frische' Seite ausgeliefert.
Für OS X gibt es sicher auch so einen Trick. Man muss ihn halt nur kennen ;)

Ich hab's gestern nacht um 3 auch tatsächlich noch hinbekommen, nachdem
ich den Rechner neu gestartet und xampp ganz frisch installiert habe ... und
mein vhost-Verzeichnis unterhalb des DocumentRoot abgelegt habe.

Genauso wie Du sagstest, funktionierte es dann auch:

Alle Optionen, die in der httpd.conf für das DocumentRoot definiert wurden,
galten für den virtuellen host, weil unterhalb liegt.

Jetzt bin ich aber immernoch nicht weiter mit meiner Frage, ob ich das
von xampp vorgesehene DocumentRoot:

"/Applications/xampp/xamppfiles/htdocs"

verwenden, oder es nach:

"/Users/martinhein/Sites"

... umbiegen soll. Ich kann mir vorstellen, dass es sinnvoll ist, so eine
xampp-Default-Konfiguration der httpd.conf weitestgehend unberührt
zu lassen, und alle Anpassungen in der httpd-vhosts.conf vorzunehmen.
Um das zu realsieren könnte ich mir so eine Konstruktion vorstellen:

httpd-vhosts.conf:
Code: Select all
<Directory "/Users/martinhein/Sites">
    Options Indexes FollowSymLinks ExecCGI Includes
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

<VirtualHost *:80>
    ServerAdmin martinhein@meinvhost1.leopold.net
    DocumentRoot "/Users/martinhein/Sites/meinvhost1"
    ServerName meinvhost1.leopold.net
    ErrorLog "logs/meinvhost1.leopold.net-error_log"
    CustomLog "meinvhost1.leopold.net-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin martinhein@meinvhost2.leopold.net
    DocumentRoot "/Users/martinhein/Sites/meinvhost2"
    ServerName meinvhost2.leopold.net
    ErrorLog "logs/meinvhost2.leopold.net-error_log"
    CustomLog "meinvhost2.leopold.net-access_log" common
</VirtualHost>


Ich habe hier einfach global Einstellungen für das Directory vorgenommen,
indem alle vhosts liegen sollen. Wenn ich den Aufbau der httpd.conf richtig
verstanden habe, sollte das gehen, oder ?

beste gruesse,
heinetz
heinetz
 
Posts: 88
Joined: 02. January 2004 12:37

Re: Problem mit vhosts

Postby kleinweby » 09. January 2009 22:48

heinetz wrote:schon klar - ich quäl' mich halt seit nem halben jahr in mein neues OS X und bei
auf Windows-Rechnern wird auf Shift-Reload immer eine 'frische' Seite ausgeliefert.
Für OS X gibt es sicher auch so einen Trick. Man muss ihn halt nur kennen ;)


Im Safari kannst du eine Seite mit cmd + R neuladen ohne dabei den Cache zu beruecksichtigen.

heinetz wrote:Jetzt bin ich aber immernoch nicht weiter mit meiner Frage, ob ich das
von xampp vorgesehene DocumentRoot:

"/Applications/xampp/xamppfiles/htdocs"

verwenden, oder es nach:

"/Users/martinhein/Sites"

... umbiegen soll.


Ich hoffe ich habe nichts ueberlesen. Aber wenn du http://localhost/~martinhein aufrufst landest du in /Users/martinhein/Sites. Von daher wuerde ich es so lassen wie es ist.

Grueße,
kleinweby
User avatar
kleinweby
AF Moderator
 
Posts: 393
Joined: 03. August 2005 19:52
Location: Magdeburg
Operating System: Mac OS X 10.7

Re: Problem mit vhosts

Postby heinetz » 09. January 2009 23:10

kleinweby wrote:Im Safari kannst du eine Seite mit cmd + R neuladen ohne dabei den Cache zu beruecksichtigen.


Danke für den Tipp. Hätte man ja auch drauf kommen können ;)

kleinweby wrote:Ich hoffe ich habe nichts ueberlesen. Aber wenn du http://localhost/~martinhein aufrufst landest du in /Users/martinhein/Sites. Von daher wuerde ich es so lassen wie es ist.

Grueße,
kleinweby


Stimmt, allerdings ich verstehe Deinen Einwand nicht. Die Tatsache,
dass ich über http://localhost/~martinhein in dem Verzeichnis
lande, ist doch so gewollt ... von Steve Jobs. Ich wüsste noch nicht,
was ich dafür oder dagegen haben sollte.

gruesse,
heinetz
heinetz
 
Posts: 88
Joined: 02. January 2004 12:37

Re: Problem mit vhosts

Postby Wiedmann » 10. January 2009 02:25

Die Tatsache, dass ich über http://localhost/~martinhein in dem Verzeichnis
lande, ist doch so gewollt ... von Steve Jobs.

"Steve Jobs" hat das weder so gewollt noch hat er etwas damit zu tun. Dies ist einfach das "Standardverhalten" des Apache wenn Userdirs aktiviert sind. Diese werden über die Datei "httpd-userdir.conf" aktiviert und konfiguriert.

Was deine VHosts angeht: Du solltest die Directive "CustomLog" nochmals überprüfen.
Wiedmann
AF Moderator
 
Posts: 17102
Joined: 01. February 2004 12:38
Location: Stuttgart / Germany

Re: Problem mit vhosts

Postby heinetz » 10. January 2009 20:03

aha, ok ! habe verstanden. Ist es denn problematisch, dass in meinem
Userdir vhosts definiert sind ?

Danke für den Hinweis auf die Custom_logs !

beste gruesse,
heinetz
heinetz
 
Posts: 88
Joined: 02. January 2004 12:37


Return to XAMPP für macOS

Who is online

Users browsing this forum: No registered users and 6 guests