Erstellt am: 21.02.2008 | Editiert am: 30.03.2008

Lighttpd mit SysCP unter Debian

Lighttpd mit php5, php5-xcache und mysql-vhost unter Syscp

Lighttpd, php5 und mysql-vhost installieren

aptitude install lighttpd lighttpd-mod-mysql-vhost python-mysqldb php5-cgi php5-xcache

Lighttpd

Nun muss die Lighttpd Config verändert werden.

nano /etc/lighttpd/lighttpd.conf

Server Modules anpassen:

server.modules              = (
            "mod_access",
            "mod_alias",
            "mod_accesslog",
            "mod_fastcgi",
            "mod_rewrite",
            "mod_redirect",
#           "mod_status",
#           "mod_evhost",
#           "mod_compress",
#           "mod_usertrack",
#           "mod_rrdtool",
#           "mod_webdav",
#           "mod_expire",
#           "mod_flv_streaming",
#           "mod_evasive"
 )

PHP5-CGI

Um PHP5 mit Lighttpd zu benutzen muss nun noch eine Einstellung in der php.ini verändert werden.

nano /etc/php5/cgi/php.ini

Suche "; cgi.fix_pathinfo = 0" und editiere es mit "cgi.fix_pathinfo = 1"

 

Damit Lighttpd auch weiß das PHP5-CGI benutzt wird, muss natürlich eine Config Datei erstellt werden. Für PHP4-CGI existiert jedoch bereits eine Konfiguration, also liegt es nahe diese einfach wie folgt zu bearbeiten. Die Datei findest du unter /etc/lighttpd/conf-available/10-fastcgi.conf

## FastCGI programs have the same functionality as CGI programs,
## but are considerably faster through lower interpreter startup
## time and socketed communication
##
## Documentation: /usr/share/doc/lighttpd-doc/fastcgi.txt.gz
##                http://www.lighttpd.net/documentation/fastcgi.html

server.modules   += ( "mod_fastcgi" )

## Start an FastCGI server for php5 (needs the php5-cgi package)
fastcgi.server    = ( ".php" =>
        ((
                "bin-path" => "/usr/bin/php5-cgi",
                "socket" => "/tmp/php.socket",
                "max-procs" => 2,
                "idle-timeout" => 20,
                "bin-environment" => (
                        "PHP_FCGI_CHILDREN" => "4",
                        "PHP_FCGI_MAX_REQUESTS" => "10000"
                ),
                "bin-copy-environment" => (
                        "PATH", "SHELL", "USER"
                ),
                "broken-scriptfilename" => "enable"
        ))
)
 

Nun noch abspeichern und mit lighty diese aktivieren, sowie Lighttpd neu starten:

lighty-enable-mod fastcgi

/etc/init.d/lighttpd force-reload

 

php5-XCache

XCache beschleunigt die Performance von PHP scripten, indem diese im Precompiled Zustand in den Speicher gelegt werden.

Nachdem XCache installiert ist, muss dieser nur aktiviert werden. Dazu wird folgendes am ende von /etc/php5/cgi/php.ini eingefügt:

[xcache-common]
zend_extension = /usr/lib/php5/20060613+lfs/xcache.so

[xcache.admin]
; Change xcache.admin.user to your preferred login name
xcache.admin.auth = On
xcache.admin.user = “admin”

; Change xcache.admin.pass to the MD5 fingerprint of your password
; Use md5 -s “your_secret_password” to find the fingerprint
xcache.admin.pass = “md5 of admin”

[xcache]
; Change xcache.size to tune the size of the opcode cache
xcache.size = 24M
xcache.shm_scheme = “mmap”
xcache.count = 2
xcache.slots = 8K
xcache.ttl = 0
xcache.gc_interval = 0

; Change xcache.var_size to adjust the size of variable cache
xcache.var_size = 8M
xcache.var_count = 1
xcache.var_slots = 8K
xcache.var_ttl = 0
xcache.var_maxttl = 0
xcache.var_gc_interval = 300
xcache.test = Off
xcache.readonly_protection = On
xcache.mmap_path = “/tmp/xcache”
xcache.coredump_directory = “”
xcache.cacher = On
xcache.stat = On
xcache.optimizer = Off

[xcache.coverager]
xcache.coverager = On
xcache.coveragedump_directory = “”

Nachdem abspeichern nun php-cgi überprüfen: php-cgi -v

PHP 5.2.5-0.dotdeb.2 with Suhosin-Patch 0.9.6.2 (cgi-fcgi) (built: Dec 10 2007 08:39:26)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
    with XCache v1.2.1, Copyright (c) 2005-2007, by mOo
 

MySQL-Vhost

Damit Lighttpd automatisch die Daten von SysCP über die existierenden Vhosts bekommt, kann dieses Modul verwendet werden. Wenn Lighttpd gestartet wird lädt es die entsprechende Tabelle in den Speicher. Falls Daten in SysCP über eine Domain geändert werden, muss Lighttpd neu gestartet werden.
Damit das Modul die Daten findet wird zu erst eine Config Datei erstellt:

nano /etc/lighttpd/conf-available/10-mysql-vhost.conf

Diese sieht wie folgt aus:

server.modules += ( "mod_mysql_vhost" )

mysql-vhost.db = "syscp"
mysql-vhost.user = "DB-BENUTZER"
mysql-vhost.pass = "DB-PASSWORT"
mysql-vhost.sock = "/var/run/mysqld/mysqld.sock"
mysql-vhost.sql = "SELECT documentroot FROM panel_domains WHERE domain='?';"

Abspeichern und diese Lighttpd mit lighty zur Verfügung stellen, sowie lighttpd neu starten:

lighty-enable-mod mysql-vhost

/etc/init.d/lighttpd force-reload

 

 

 


Database: 0,0080 s, 17 Anfragen, PHP: 0,1599 s, total: 0,1679 s