Hinweis: Sie sind auf den Seiten der Moodle 1.9 Dokumentation. Die Dokumentation der aktuellsten Moodle-Version finden Sie hier: Apache.

Baustelle.png Diese Seite ist noch nicht vollständig übersetzt.

Siehe en:Apache

Wenn von Apache die Rede ist, meinen die meisten das "Apache HTTP Server Project". Tatsächlich ist Apache die "Apache Software Foundation", die eine Menge von Projekten betreut, von denen eins das HTTP Server Projekt ist - wahrscheinlich das bekannteste.

The Apache HTTP Server enables web pages to be published on the internet (or an intranet or even on a single test machine). The PHP scripting language, in which Moodle is developed, is tightly integrated with the Apache HTTP Server. A web server is a required component of a Moodle installation. There are two distinct developments of the Apache HTTP Server, version 1 and version 2. Although version 2 should have replaced version 1, the architectures are so different that they both continue to be supported. Either are fully supported by PHP and Moodle.

The Apache HTTP Server Project describes itself thus:

"The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows NT. The goal of this project is to provide a secure, efficient and extensible server that provides HTTP services in sync with the current HTTP standards.

Apache has been the most popular web server on the Internet since April 1996. The November 2005 Netcraft Web Server Survey found that more than 70% of the web sites on the Internet are using Apache, thus making it more widely used than all other web servers combined."

Installing Apache

Usually Apache is installed alongside PHP and MySQL in a combination known as XAMPP or MAMP. See information about XAMPP(Windows cross platforms) and for information about MAMP (Mac OS platforms).

Example, Debian/Ubuntu:

apt-get install apache2

See the documentation for your particular distro for the instructions. Apache is straightforward to build from source if required and the PHP documentation contains an article on building both Apache and PHP together.

Performance

Caching

Apache can be tuned to make pages load faster by specifying how the browser should cache the various page elements. How to do this varies slightly between OSes but there are two basic steps

  1. Install and enable mod_expires - refer to documentation or man pages
  2. Add this code to the virtual server config file within the section for the root directory (or within the .htaccess file if AllowOverrides is On):
<IfModule mod_expires.c>
 ExpiresActive On
 ExpiresDefault "access plus 1 seconds"
 ExpiresByType text/html "access plus 1 seconds"
 ExpiresByType image/gif "access plus 120 minutes"
 ExpiresByType image/jpeg "access plus 120 minutes"
 ExpiresByType image/png "access plus 120 minutes"
 ExpiresByType text/css "access plus 60 minutes"
 ExpiresByType text/javascript "access plus 60 minutes"
 ExpiresByType application/x-javascript "access plus 60 minutes"
 ExpiresByType text/xml "access plus 1 seconds"
</IfModule>

The effect is to make everything stay in the cache except HTML and XML, which change dynamically. It's possible to gain a several hundred percent decrease in load times this way

More info: www.metaskills.net

Servers

Apache serves webpages by spawning new child processes (smaller sub-programs) to deal with each connection. The number of these that you allow to run and to be kept in reserve has a big impact on how fast your server will run. The risk (especially on a server with a small amount of memory, such as a VPS) is that the available RAM will run out and the system will end up using the far slower hard disk as swap memory instead. To prevent this, you need to tell Apache only to have a certain number. Here is a sample set of configuration directives for a VPS server with 128MB of RAM (with up to 384 burstable), which apparently works quite well (more info here)

Make a back up of your httpd.conf first. It’s generally found at /etc/httpd/conf/httpd.conf, then open the file with your editor e.g.

nano /etc/httpd/conf/httpd.conf

Then look for these values, which may be spread about a little and change them:

Timeout 200
KeepAlive On
MaxKeepAliveRequests 200
KeepAliveTimeout 3
MinSpareServers 5
MaxSpareServers 15
StartServers 5
MaxClients 20
MaxRequestsPerChild 2000
HostnameLookups Off

If you find that you are running out of memory (type

top

if using Linux and look at the swap figure), just lower some of the numbers. Similary, if you have extra memory, you can afford to raise them a bit. Remember to combine tuning of Apache with tuning of your database app.

SSL

Wenn Sie Ihr Moodle besser schützen wollen, dann sollten Sie die SSL-Verschlüsselung aktivieren. Dann wird das Kennwort beim Anmelden verschlüsselt übertragen und kann nicht mitgelesen werden (wie es normalerweise bei Internetvernbindungen der Fall wäre). Es gibt zwei Möglichkeiten:

  • Entweder Sie generieren ein selbstsigniertes Zertifikat, mit dem Netzwerk-Sniffing unterbunden wird, das aber mit hinreichend großem Aufwand komprimittiert werden kann,
  • oder Sie kaufen ein Zertifikat bei einer Zertifizierungsstelle (ab $US 35 pro Jahr).

Nachfolgend finden Sie beispielhaft eine Anleitung für die Installation eines selbstsignierten Zertifikats unter Debian und Apache2.

1. Generieren Sie ein Zertifikat:

     apache2-ssl-certificate
Für Debian Etch müssen Sie folgenden Befehl verwenden:
     make-ssl-cert /usr/share/ssl-cert/ssleay.cnf /etc/apache2/ssl/apache.pem

2. Ändern Sie die Konfigurationsdatei /etc/apache2/ports.conf wie folgt:

     Listen 80
     Listen 443

3. Kopieren Sie die Datei /etc/apache2/sites-available/default nach /etc/apache2/sites-available/default-ssl und ändern Sie die Datei /etc/apache2/sites-available/default wie folgt:

     NameVirtualHost *:80
     <VirtualHost *:80>
     ...
     </VirtualHost>

4. Ändern Sie die Datei /etc/apache2/sites-available/default-ssl wie folgt:

     NameVirtualHost *:443
     <VirtualHost *:443>
     ...
             SSLEngine on
             SSLCertificateFile /etc/apache2/ssl/apache.pem
     ...
     </VirtualHost>

5. Setzen Sie einen symbolischen Link auf die SSL-Datei:

     a2ensite default-ssl

6. Setzen Sie einen symbolischen Link auf das SSL-Modul:

     a2enmod ssl

7. Starten Sie den Webserver neu und testen Sie die Verbindung (z.B. https://localhost/):

     /etc/init.d/apache2 restart

Siehe auch