virtueller Server - aber wie gehts richtig??

Alles, was den Apache betrifft, kann hier besprochen werden.

virtueller Server - aber wie gehts richtig??

Postby allido » 28. May 2008 19:22

Moin,
Ich habe einen vserver mit suse 10.1, wo ich mir grad alles am Einrichten bin. Da ich verschiedene domains auf dem Server laufen lassen will, bieten sich natürlich die virtuellen Server von apache an, allerdings hab ich da grad ein Problem.

Momentan hab ich erst mal nur eine Domain, hier jetzt mal www.example.com. Diese und dazu kommenden Domains werden auf der selben IP laufen, nehmen wir jetzt halt mal 192.168.123.168.

Nachdem bei mir in der httpd.conf

httpd.conf
# |
# |-- uid.conf . . . . . . . . . . . . . . UserID/GroupID to run under
# |-- server-tuning.conf . . . . . . . . . sizing of the server (how many processes to start, ...)
# |-- sysconfig.d/loadmodule.conf . . . . . [*] load these modules
# |-- listen.conf . . . . . . . . . . . . . IP adresses / ports to listen on
# |-- mod_log_config.conf . . . . . . . . . define logging formats
# |-- sysconfig.d/global.conf . . . . . . . [*] server-wide general settings
# |-- mod_status.conf . . . . . . . . . . . restrict access to mod_status (server monitoring)
# |-- mod_info.conf . . . . . . . . . . . . restrict access to mod_info
# |-- mod_usertrack.conf . . . . . . . . . defaults for cookie-based user tracking
# |-- mod_autoindex-defaults.conf . . . . . defaults for displaying of server-generated directory listings
# |-- mod_mime-defaults.conf . . . . . . . defaults for mod_mime configuration
# |-- errors.conf . . . . . . . . . . . . . customize error responses
# |-- ssl-global.conf . . . . . . . . . . . SSL conf that applies to default server _and all_ virtual hosts
# |
# |-- default-server.conf . . . . . . . . . set up the default server that replies to non-virtual-host requests
# | |--mod_userdir.conf . . . . . . . . enable UserDir (if mod_userdir is loaded)
# | `--conf.d/apache2-manual?conf . . . add the docs ('?' = if installed)
# |
# |-- sysconfig.d/include.conf . . . . . . [*] your include files
# | (for each file to be included here, put its name
# | into APACHE_INCLUDE_* in /etc/sysconfig/apache2)
# |
# `-- vhosts.d/ . . . . . . . . . . . . . . for each virtual host, place one file here
# `-- *.conf . . . . . . . . . . . . . (*.conf is automatically included)


steht, hab ich in apache2/vhosts.d/ example.conf angelegt, und folgendes aus dem template da übernommen:
<VirtualHost *:80>
ServerAdmin admin@example.com
ServerName example.com

# 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 /srv/www/vhosts/example/htdocs

# if not specified, the global error log is used
#ErrorLog /var/log/apache2/dummy-host.example.com-error_log
#CustomLog /var/log/apache2/dummy-host.example.com-access_log combined

# don't loose time with IP address lookups
HostnameLookups Off

# needed for named virtual hosts
UseCanonicalName On

# configures the footer on server-generated documents
ServerSignature On


# Optionally, include *.conf files from /etc/apache2/conf.d/
#
# For example, to allow execution of PHP scripts:
#
# Include /etc/apache2/conf.d/mod_php4.conf
#
# or, to include all configuration snippets added by packages:
Include /etc/apache2/conf.d/*.conf


# ScriptAlias: This controls which directories contain server scripts.
# ScriptAliases are essentially the same as Aliases, except that
# documents in the realname 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/ "/srv/www/vhosts/example/cgi-bin/"

# "/srv/www/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have one, and where ScriptAlias points to.
#
<Directory "/srv/www/vhosts/example/cgi-bin">
AllowOverride None
Options +ExecCGI -Includes
Order allow,deny
Allow from all
</Directory>


# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.
#
# To disable it, simply remove userdir from the list of modules in APACHE_MODULES
# in /etc/sysconfig/apache2.
#
<IfModule mod_userdir.c>
# Note that the name of the user directory ("public_html") cannot simply be
# changed here, since it is a compile time setting. The apache package
# would have to be rebuilt. You could work around by deleting
# /usr/sbin/suexec, but then all scripts from the directories would be
# executed with the UID of the webserver.
UserDir public_html
# The actual configuration of the directory is in
# /etc/apache2/mod_userdir.conf.
Include /etc/apache2/mod_userdir.conf
</IfModule>


#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "/srv/www/vhosts/example/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

#
# 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>
</VirtualHost>


www.example.com leitet er jetzt auch einwandfrei um - allerdings auch die ip 192.168.123.168. Jetzt will ich aber, dass, wenn man die IP direkt eingibt, man auf die "normalen" standart htdocs kommt.
Was mach ich hier falsch? Ich hab mir die Dokumentation durchgelesen, aber da werd ich nicht schlauer draus...
Ich hoffe ihr könnt mir helfen,
Gruß, CS
allido
 
Posts: 9
Joined: 28. May 2008 19:08

Postby DJ DHG » 28. May 2008 19:26

Moin Moin!

http://httpd.apache.org/docs/2.2/vhosts/name-based.html

Unter dem Punkt "Der Hauptserver verschwindet:".

mfg DJ DHG
User avatar
DJ DHG
AF Moderator
 
Posts: 2455
Joined: 27. December 2002 13:50
Location: Kiel

Postby allido » 28. May 2008 19:52

hm, iwas mach ich falsch, des haut immernoch nicht hin. in der httpd.conf hab ich jetzt folgendes (also das dicke) eingefügt:


[...]

<VirtualHost *:80>
ServerName 192.168.123.168
DocumentRoot "/srv/www/htdocs"
</VirtualHost>

Include /etc/apache2/vhosts.d/*.conf


muss ich da noch mehr angeben, oder iwie was anderes beim servername?
allido
 
Posts: 9
Joined: 28. May 2008 19:08

Postby allido » 29. May 2008 12:59

Ok, mal anders gefragt, angenommen ich hätte da noch nix mit virtual server zeug rumgespielt, was würdet ihr machen, damit www.example1.com, www.example2.com etc auf das jeweiliges DocumentRoot (also www/vhosts/example[1-x]) zeigt, man bei der direkten Eingabe der IP allerdings, die alle Domains gemeinsam haben, auf das "standart" htdoc kommt?
allido
 
Posts: 9
Joined: 28. May 2008 19:08

gelöst

Postby allido » 29. May 2008 13:08

Ok, ich habs jetzt mit weng rumprobieren geschaft^^
Wirklich kapiert hab ichs zwar immernoch nicht, aber naja, hauptsache es klappt.

@DJ DHG Danke für den Link, der hat mich auf jeden Fall weiter gebracht =)
Gruß, CS
allido
 
Posts: 9
Joined: 28. May 2008 19:08


Return to Apache

Who is online

Users browsing this forum: No registered users and 6 guests