Apache

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Apache and the translation is 80% complete.
Outdated translations are marked like this.

Der Apache HTTP Server ist ein effizienter und erweiterbarer Web-Server. Es ist einer der am häufigsten eingesetzten Web-Server im Internet.

Installation

Hinweis
Wenn Sie eine Aktualisierung durchführen möchten, sei an dieser Stelle auf die Anleitung Apache upgraden hingewiesen.

USE-Flags

USE flags for www-servers/apache The Apache Web Server

debug Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
gdbm Add support for sys-libs/gdbm (GNU database libraries)
ldap Add LDAP support (Lightweight Directory Access Protocol)
selinux !!internal use only!! Security Enhanced Linux support, this must be set by the selinux profile or breakage will occur
split-usr Enable behavior to support maintaining /bin, /lib*, /sbin and /usr/sbin separately from /usr/bin and /usr/lib*
ssl Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security)
static Link in apache2 modules statically rather then plugins
suexec Install suexec with apache
suexec-caps Install suexec with capabilities instead of SUID
suexec-syslog Log suexec to syslog instead of to a separate file
systemd Enable use of systemd-specific libraries and features like socket activation or session tracking
threads Add threads support for various packages. Usually pthreads

Emerge

Multi-Processing Module

If you want to use the Apache event or worker MPM, enable the Apache threads USE flag:

DATEI /etc/portage/package.useApache threads support
www-servers/apache threads

If you want to use the Apache event MPM, then add the following to make.conf:

DATEI /etc/portage/make.confApache event MPM
APACHE2_MPMS="event"

If you want to use the Apache worker MPM, then add the following to make.conf:

DATEI /etc/portage/make.confApache worker MPM
APACHE2_MPMS="worker"

If no Multi-Processing Module (MPM) is selected, the default MPM is used. The default MPM depends on platform capabilities (like threads support), read more in the official Apache docs.


Dann emergen Sie Apache:

root #emerge --ask www-servers/apache

Globale Unterstützung

Enabling the apache2 global USE flag provides support for Apache in other packages. This may cause www-servers/apache to be installed automatically if a package depending on Apache has been emerged.

DATEI /etc/portage/make.confAdding Apache to system USE flags
USE="apache2"

Nach dem setzen der globalen USE-Flags sollte das System aktualisiert werden, damit die Änderungen im System übernommen werden:

root #emerge --ask --changed-use --deep @world

Konfiguration

Dateien

Es existieren zwei Hauptkonfigurationsdateien, welche das Verhalten des Apache2-Servers auf dem System beeinflussen:

  • Gentoo's Apache2-Init-Skript Konfigurationsdatei /etc/conf.d/apache2
  • Übliche Apache2-Server Konfigurationsdatei /etc/apache2/httpd.conf

/etc/conf.d/apache2

The apache2 file located in /etc/conf.d is Gentoo's init script configuration file. The only active line in this file is the APACHE2_OPTS variable line:

DATEI /etc/conf.d/apache2
APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D SSL -D SSL_DEFAULT_VHOST -D LANGUAGE"

Diese Zeile definiert Optionen, die durch verschiedenen Konfigurationsdateien mit der <IfDefine option-name> Anweisung interpretiert werden, um einen Teil der gesamten Konfiguration zu aktivieren oder zu deaktivieren. Darauf wird im weiteren Verlauf des Artikels noch eingegangen.

/etc/apache2/httpd.conf

In der Tat ist diese Datei nur ein "Einstiegspunkt", da die gesamte Konfiguration in viele Dateien im Verzeichnis /etc/apache2/ aufgeteilt ist. Sie werden mit Hilfe der Include direktive zusammengesetzt. Die Anweisung Include /etc/apache2/modules.d/*.conf in httpd.conf zielt z. B. darauf ab alle Dateien in /etc/apache2/modules.d/ einzubinden, deren Name mit .conf endet.

Unter Berücksichtigung des oben gesagten und weil die Modul-Konfigurationsdateien (in /etc/apache2/modules.d) fast immer mit dem <IfDefine module-name> beginnen, wird der Inhalt einer Datei in /etc/apache2/modules.d NUR mit dem Rest der Konfiguration zusammengefügt, wenn die passende Option über das -D module-name Flag in der APACHE2_OPTS Variable in der Datei /etc/conf.d/apache2 gesetzt ist. Die Konfigurationsdatei 00_default_settings.conf ist eine Ausnahme von dieser Regel, weil sie nicht mit einer IfDefine Anweisung beginnt und daher immer in der resultierenden Konfiguration eingebunden ist.

Standardwerte

Nach einer Neuinstallation von Apache Server ist die Konfiguration, die aus der Zusammensetzung der verschiedenen Konfigurationsdateien resultiert, wie folgt. Beginnend mit dem Einstiegspunkt /etc/apache2/httpd.conf.

Warnung
Dies sei "nur" als schnelle Referenz zu verstehen und soll einen Überblick gewähren. Benutzern wird nachdrücklich empfohlen sich die Kommentare in den verschiedenen Dateien anzuschauen, um die Besonderheiten der Konfiguration zu verstehen. Bitte beachten Sie auch das Apache Handbuch für ein tiefer gehendes Verständnis der Apache Konfigurationen.
DATEI /etc/apache2/httpd.conf
ServerRoot "/usr/lib64/apache2"
  
#Module loaded unconditionally, assuming the USE flag is no unset in
# /etc/portage/make.conf or in /etc/portage/package.use
LoadModule actions_modulemodules/mod_actions.so
...
#other modules loaded that way : alias_module, auth_basic_module, authn_alias_module,
# authn_anon_module, authn_dbm_module, authn_default_module, authn_file_module, 
# authz_dbm_module, authz_default_module, authz_groupfile_module, authz_host_module, 
# authz_owner_module, authz_user_module, autoindex_module,  cgi_module,  cgid_module, 
# deflate_module, dir_module, env_module, expires_module, ext_filter_module, filter_module,
#  headers_module, include_module,  log_config_module, logio_module, mime_module,  
# mime_magic_module, negotiation_module, rewrite_module, setenvif_module, 
# speling_module,ssl_module, status_module, unique_id_module, usertrack_module, host_alias_module
  
  
#Modules loaded conditionally, assuming matching USE flag is not unset in
# /etc/portage/make.conf or in /etc/portage/package.use (flag to be set in )
<IfDefine AUTHNZ_LDAP>
LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
</IfDefine>
#other modules loaded that way : cache_module, dav_module, dav_fs_module,
# dav_lock_module,disk_cache_module,  file_cache_module, info_module, ldap_module,
# mem_cache_module, userdir_module
  
  
User apache
Group apache
  
# Supplemental configuration
#**************************************************************************************vvv
#this part is included via Include /etc/apache2/modules.d/*.conf 
  
#included from /etc/apache2/modules.d/00_default_settings.conf-------------v
#this is always included as there is not option to deactivate it.
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
UseCanonicalName Off
AccessFileName .htaccess
ServerTokens Prod
TraceEnable off
ServerSignature On 
HostnameLookups Off
EnableMMAP On
EnableSendfile On
FileEtag INode MTime Size
ContentDigest Off
ErrorLog /var/log/apache2/error_log
LogLevel warn
  
<Directory />
	Options FollowSymLinks
	AllowOverride None
	Require all denied
</Directory>
  
<IfModule dir_module>
	DirectoryIndex index.html index.html.var
</IfModule>
<FilesMatch "^\.ht">
	Require all denied
</FilesMatch>
#--------------------------------------------------------------------------^
  
#included from 00_mod_info.conf--------------------------------------------v
<IfDefine INFO>
<Location /server-info>
	SetHandler server-info
	Require host 127.0.0.1
</Location>
</IfDefine>
#--------------------------------------------------------------------------^
  
#--------------------------------------------------------------------------v
#included from 00_languages.conf
# Settings for hosting different languages.
<IfDefine LANGUAGE>
  
	AddLanguage ca .ca
	...
	AddLanguage zh-TW .zh-tw
  
	LanguagePriority en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
  
	ForceLanguagePriority Prefer Fallback
  
	AddCharset us-ascii.ascii	.us-ascii
	AddCharset ISO-8859-1		.iso8859-1 .latin1
	...
	AddCharset shift_jis		.shift_jis .sjis
</IfDefine>
#---------------------------------------------------------------------------^
#**************************************************************************************^^^
  
  
#***************************************************************************************vvv
#this part is included via Include /etc/apache2/vhosts.d/*.conf 
#from 00_default_ssl_vhost.conf-----------------------------------------------------vv
<IfDefine SSL>
	<IfDefine SSL_DEFAULT_VHOST>
		<IfModule ssl_module>
			Listen 443
  
			<VirtualHost _default_:443>
				ServerName localhost
                                #------------------------------------------v
				# this part is included via Include /etc/apache2/vhosts.d/default_vhost.include
				ServerAdmin root@localhost
				DocumentRoot "/var/www/localhost/htdocs"
  
  	
				<Directory "/var/www/localhost/htdocs">
	   				Options Indexes FollowSymLinks
	   				AllowOverride All
	   				Require all granted
				</Directory>
  
				<IfModule alias_module>
	   				ScriptAlias /cgi-bin/ "/var/www/localhost/cgi-bin/"
				</IfModule>
  
				<Directory "/var/www/localhost/cgi-bin">
	   				AllowOverride None
	   				Options None
	   				Require all granted
				</Directory>
        			#end of Include ---------------------------^
  	
				ErrorLog /var/log/apache2/ssl_error_log
  
				<IfModule log_config_module>
					TransferLog /var/log/apache2/ssl_access_log
				</IfModule>
				SSLEngine on
				SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
				SSLCertificateFile /etc/ssl/apache2/server.crt
				SSLCertificateKeyFile /etc/ssl/apache2/server.key
  
				<FilesMatch "\.(cgi|shtml|phtml|php)$">
					SSLOptions +StdEnvVars
				</FilesMatch>
  
				<Directory "/var/www/localhost/cgi-bin">
					SSLOptions +StdEnvVars
				</Directory>
  
				<IfModule setenvif_module>
					BrowserMatch ".*MSIE.*" \
					nokeepalive ssl-unclean-shutdown \
					downgrade-1.0 force-response-1.0
				</IfModule>
  
  
				<IfModule log_config_module>
					CustomLog /var/log/apache2/ssl_request_log \
					"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
					</IfModule>
			</VirtualHost>
		</IfModule>
	</IfDefine>
</IfDefine>
#---------------------------------------------------------------------------------^^
#from 00_default_vhost.conf-------------------------------------------------------vv
<IfDefine DEFAULT_VHOST>
	Listen 80
	NameVirtualHost *:80
  
	<VirtualHost *:80>
		ServerName localhost
  
		#---------------------------------------------------------------v
		# this part is included via Include /etc/apache2/vhosts.d/default_vhost.include
		ServerAdmin root@localhost
		DocumentRoot "/var/www/localhost/htdocs"
  
  	
		<Directory "/var/www/localhost/htdocs">
	   		Options Indexes FollowSymLinks
	   		AllowOverride All
	   		Require all granted
		</Directory>
  
		<IfModule alias_module>
	   		ScriptAlias /cgi-bin/ "/var/www/localhost/cgi-bin/"
		</IfModule>
  
		<Directory "/var/www/localhost/cgi-bin">
	   		AllowOverride None
	   		Options None
	   		Require all granted
		</Directory>
        	#end of Include -----------------------------------------------^
  
		<IfModule mpm_peruser_module>
			ServerEnvironment apache apache
		</IfModule>
	</VirtualHost>
</IfDefine>
#-----------------------------------------------------------------------------------^^
# end of include ****************************************************************************************^^^

Das erste Lebenszeichen

Wie in der initialen Konfiguration oben sichtbar ist, ist der vorinstallierte DocumentRoot des virtuellen Hosts /var/www/localhost/htdocs. Sein Servername ist localhost. Zusätzlich ist eine Datei index.html im DocumentRoot Verzeichnis vorhanden. Um zu prüfen, ob alles korrekt installiert ist oder nicht, surfen sie einem Browser zur Adresse http://localhost/.

Die Nachricht "It works!" auf der Seite erscheinen.

Warnung
Firefox hat eine Funktion, um Anwendern im Falle von Fehleingaben von URLs in der Adresszeile zu helfen. Wenn eine URL nicht aufzulösen ist, nimmt Firefox ein paar Änderungen an der URL vor, um herauszufinden was der Benutzer 'möglicherweise' wirklich beabsichtigt hatten. Beispielsweise durch Anhängen von .com und/oder voranstellen von www. beim Anteil des Host Namens der URL, um zu prüfen ob sie sich dann auflösen lässt.

Diese Funktion, die in den frühen Versionen von Firefox eingeführt wurde, ist etwas nervig für Entwickler. Das bedeutet wenn ein Server auf localhost nicht reagiert, Firefox localhost.com und/oder www.localhost.com versucht und Sie am Ende bei einer nicht gefunden Seite landen könnten.

Um dieses 'Feature' zu deaktivieren:

  1. Geben Sie about:config in die Browser-Leiste ein
  2. Geben Sie browser.fixup.alternate.enabled in das angezeigte Suchfeld ein
  3. Führen Sie einen Rechtsklick auf browser.fixup.alternate.enabled in der gefilterten Liste aus und wählen Sie Toggle, um den Wert auf false zu setzen

mod_security aktivieren

ModSecurity is a rule-based web application firewall that monitors web service traffic, to block attacks exploiting known vulnerabilities.

Installieren Sie www-apache/mod_security:

root #emerge --ask www-apache/mod_security

Enable the SECURITY module in the apache2 file's APACHE2_OPTS variable:

DATEI /etc/conf.d/apache2Das Sicherheitsmodul aktivieren
APACHE2_OPTS="... -D SECURITY"

Das Verhalten des Moduls kann durch anpassen der Dateien /etc/apache2/modules.d/79_modsecurity.conf und /etc/apache2/modules.d/80_modsecurity-crs.conf gesteuert werden. Im Anschluss hieran, muss der Apache-Server neugestartet werden.

PHP Unterstützung aktivieren

Installieren Sie PHP mit dem apache2 USE-Flag und aktivieren Sie das Modul:

Wichtig
With >=app-eselect/eselect-php-0.8.1, the APACHE2_OPTS variable changed to -D PHP instead of -D PHP5. This allows for future major versions to flow smoothly. As of eselect-php-0.9.4-r5, the compatibility shim was dropped after allowing 2 years to convert.
DATEI /etc/conf.d/apache2Das PHP Modul aktivieren
APACHE2_OPTS="... -D PHP"

Vor dem Test ob das PHP Modul funktioniert, prüfen Sie dass die Datei /etc/apache2/modules.d/70_mod_php.conf existiert und die folgende Definition enthält:

DATEI /etc/apache2/modules.d/70_mod_php5.conf
<IfDefine PHP5> 
        # Load the module first 
        <IfModule !mod_php5.c> 
                LoadModule php5_module    modules/libphp5.so 
        </IfModule> 
  
        # Set it to handle the files 
        <IfModule mod_mime.c> 
                AddHandler application/x-httpd-php .php .php5 .phtml 
                AddHandler application/x-httpd-php-source .phps 
        </IfModule> 
  
        DirectoryIndex index.php index.phtml 
</IfDefine>

Wenn die Datei nicht vorhanden ist, erstellen Sie sie.

Um zu verifizieren ob das PHP Modul korrekt funktioniert, erstellen Sie eine Testseite:

DATEI /var/www/localhost/htdocs/index.phpPHP Testseite
<html>
 <body>
  <?php phpinfo(); ?>
 </body>
</html>

Löschen oder Ändern Sie den Namen der Datei /var/www/localhost/htdocs/index.html und öffnen Sie im Anschluss hieran die Testseite: http://localhost/

A table describing the PHP settings should be visible.

Modify PHP versions

To change the version of PHP handled by Apache, first list the available versions for the apache2 Server Application Programming Interface (SAPI):

root #eselect php list apache2
 [1]   php5.3
 [2]   php5.4 *
 [3]   php5.5

Ändern Sie sie in die gewünschte Version:

root #eselect php set apache2 N

Substitute N in the example above to the requested number in the output of eselect php list apache2 as displayed earlier on.

Virtuelle Hosts

Erstellen Sie für jeden virtuellen Host ein DocumentRoot Verzeichnis, das für den Apache-Daemon erreichbar und zugänglich ist. Fügen Sie eine Konfigurationsdatei (VirtualHost.conf) für den virtuellen Host im Verzeichnis /etc/apache2/vhosts.d hinzu, welches dieses DocumentRoot verwendet und den virtuellen Host Servernamen. Vergessen Sie außerdem nicht, einen Eintrag für diesen Domainnamen in /etc/hosts hinzuzufügen.

Um die Apache user/group Zugehörigkeit der virtuellen Host Dateien zuzuweisen, verwenden Sie chown wie in folgendem Beispiel:

root #chown apache:apache /var/www/sitename

Es folgen zwei Beispiel-Definitionen für Virtuelle Hosts. Eine für domainname1.com und eine weitere für domainname2.com. Beachten Sie die unterschiedlichen DocumentRoot und ServerName Anweisungen, auch wenn der Host selbst (*:80) der gleiche bleibt:

CODE Beispiel-Definition eines Virtuellen Hosts
<VirtualHost *:80>
    ServerAdmin email@site.com
    DocumentRoot /var/www/website1
    ServerName domainname1.com
</VirtualHost>
  
<VirtualHost *:80>
    ServerAdmin email@site.com
    DocumentRoot /var/www/website2
    ServerName domainname2.com
</VirtualHost>

Es wird empfohlen, ebenfalls eine IP-basierte Virtuelle Host Definition anzubieten. Dies ermöglicht es dem Administrator eine Nachricht für Benutzer aufzusetzen, die versuchen eine Website durch ihre IP-Adresse zu erreichen:

CODE IP-basierter Virtueller Host
<VirtualHost *:80>
    ServerAdmin email@site.com
    DocumentRoot /var/www/html
    ServerName xxx.xxx.xxx.xxx
</VirtualHost>

Nach dem Einfügen Virtueller Hosts muss der Server neu gestartet werden, damit die neuen Seiten aktiv werden.

PHP aktivieren durch fcgid

Installiere www-apache/mod_fcgid und dev-lang/php. Das PHP Paket benötigt das cgi USE-flag:

root #emerge --ask www-apache/mod_fcgid dev-lang/php

Bearbeiten Sie die Datei mod_fcgid.conf:

DATEI /etc/apache2/modules.d/20_mod_fcgid.conf
<IfDefine FCGID>
LoadModule fcgid_module modules/mod_fcgid.so
SocketPath /var/run/fcgidsock
SharememPath /var/run/fcgid_shm
  
AddHandler php-fcgid .php
AddType application/x-httpd-php .php
Action php-fcgid /fcgid-bin/php-fcgid-wrapper
# max request 128mb
FcgidMaxRequestLen 134217728
<Location /fcgid-bin/>
        SetHandler fcgid-script
        Options +ExecCGI
</Location>
</IfDefine>

Erstellen Sie das benötigte Verzeichnis:

root #mkdir /var/www/localhost/htdocs/fcgid-bin

Erstellen Sie für den PHP-Wrapper einen symbolischen Link:

root #ln -s /usr/bin/php-cgi /var/www/localhost/htdocs/fcgid-bin/php-fcgid-wrapper

Aktivieren Sie das fcgid-Modul:

DATEI /etc/conf.d/apache2Das fcgid-Modul aktivieren
APACHE2_OPTS="... -D FCGID"

Starten Sie abschließend den Apache Server neu und überprüfen Sie die zuvor erzeugte phpinfo() Seite. Der Wert von Server API sollte CGI/FastCGI sein.

PHP-FPM durch mod_proxy_fcgi in Apache 2.4 aktivieren

Die folgenden Voraussetzungen müssen erfüllt sein, um PHP-FPM über mod_proxy_fcgi zu aktivieren:

  • >= PHP 5.3
  • >= Apache 2.4

Furthermore, there are a few restrictions on the availability of functionality within Apache 2.4:

Die folgende Methode beruht auf der FilesMatch Richtlinie und sitzt innerhalb der Konfiguration des Hauptservers oder der Virtuellen Hosts. Die Lage des UNIX Socket wird durch die Listen Direktive in php-fpm.conf bestimmt. Dies erlaubt die Angabe separater Pools pro Seite/Funktion.

Im folgenden Beispiel wird FilesMatch in der PHP-Modulkonfigurationsdatei von Apache platziert:

DATEI /etc/apache2/modules.d/70_mod.phpPHP-FPM benutzen (empfohlen für Apache 2.4.10 und neuer)
<IfDefine PHP>
        <FilesMatch "\.php$">
                SetHandler "proxy:unix:/var/run/php-fpm/www.sock|fcgi://localhost"
        </FilesMatch>
  
	# Set it to handle the files
	<IfModule mod_mime.c>
		AddHandler application/x-httpd-php .php .php5 .phtml
		AddHandler application/x-httpd-php-source .phps
	</IfModule>

	DirectoryIndex index.php index.phtml
 </IfDefine>

 

DATEI /etc/apache2/modules.d/70_mod_php.confUsing PHP-FPM (recommended for Apache 2.4.8 and older)
<IfDefine PHP>
        # Send all requested PHP files to PHP-FPM via fcgi://PHP_FPM_LISTEN_ADDRESS:PHP_FPM_LISTEN_PORT/DOCUMENT_ROOT/$1
        ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/localhost/htdocs/$1
  
	# Set it to handle the files
	<IfModule mod_mime.c>
		AddHandler application/x-httpd-php .php .php5 .phtml
		AddHandler application/x-httpd-php-source .phps
	</IfModule>
  
	DirectoryIndex index.php index.phtml
 </IfDefine>

By default the listen directive is not set to a socket. First create the directory for the socket file:

root #mkdir /var/run/php-fpm

Als nächstes aktualisieren Sie die Datei php-fpm.conf wie folgt:

DATEI php-fpm.confUpdating listen directive
; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
;                 mode is set to 0666
listen.owner = apache
listen.group = apache
;listen.mode = 0666
 
 ; The address on which to accept FastCGI requests.
 ; Valid syntaxes are:
 ;   'ip.add.re.ss:port'    - to listen on a TCP socket to a specific address on
 ;                            a specific port;
 ;   'port'                 - to listen on a TCP socket to all addresses on a
 ;                            specific port;
 ;   '/path/to/unix/socket' - to listen on a unix socket.
 ; Note: This value is mandatory.
 ;listen = 127.0.0.1:9000
listen = /var/run/php-fpm/www.sock

Aktivieren Sie dann sowohl das PHP- als auch das PROXY-Modul:

DATEI /etc/conf.d/apache2Aktivierung PHP- und Proxy-Modul
APACHE2_OPTS="... -D PHP -D PROXY"

Web-Frameworks und Apache

Einige der Web-Frameworks, die mit Apache arbeiten können, werden im Wiki behandelt:

HTTPS mit TLS-Zertifikaten von Let's Encrypt

It is important that any public-facing web server provide "secure" HTTPS access. Often, sites providing HTTPS will be configured to redirect HTTP requests to the HTTPS equivalent URL.

Let’s Encrypt is a not-for-profit certificate authority that issues free TLS certificats. certbot is a utility available in the Gentoo repository for easily requesting and installing TLS certificates, and automatically setting up HTTPS access for Apache.

See the Let’s Encrypt article for information about using certbot. The EFF also have specific instructions on using certbot on Gentoo to configure Apache.

Bedienung

Dienste

OpenRC

Starten des Apache-Servers:

root #/etc/init.d/apache2 start

Apache zum Default-Runlevel hinzufügen:

root #rc-update add apache2 default

Neustarten des Apache-Services:

root #/etc/init.d/apache2 restart

Apache Konfigurationsdateien erneut laden:

root #/etc/init.d/apache2 reload

systemd

Starten des Apache-Servers:

root #systemctl start apache2

Apache zum Default-Runlevel hinzufügen:

root #systemctl enable apache2

Neustarten des Apache-Services:

root #systemctl restart apache2

Fehlersuche

Ressourcen

The Apache server can be difficult to configure properly. Below are some resources that may be helpful when issues occur:

Testen

Überprüfen des IP Interfaces und des Ports, welcher apache2 zugewiesen wurde und auf dem dieser hört:

root #netstat -tulpen | grep apache
tcp     0     0 0.0.0.0:80      0.0.0.0:*     LISTEN     0     10932720     4544/apache2        
tcp     0     0 0.0.0.0:443     0.0.0.0:*     LISTEN     0     10932716     4544/apache2        

Überprüfen ob die Verbindung zum Apache-Server auf localhost funktioniert:

user $telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

Der Verbindungstest kann mit der Tastenkombination Ctrl+c und Enter unterbrochen werden.

apr_sockaddr_info_get() failed for <System_Hostname>

Fehler:

apache2: apr_sockaddr_info_get() failed for System_Hostname

Auflösung:

Sollte dies geschehen, fügen Sie den Hostnamen in die /etc/hosts Datei ein:

DATEI /etc/hostsHinzufügen eines Hostnamens für Apache
127.0.0.1 localhost System_Hostname

Siehe auch

Weblinks