Howto Lighttpd 1.4.18 + PHP5 + MYSQL

Author: F4RR3LL|sven
E-Mail: sven.richter@nixhelp.de
Stand: 06.04.2008


1.0 Start

Bei CentOS ist Lighttpd nicht in den normalen Quellen per yum enthalten, auch phpmyadmin werdet ihr dort nicht finden. Darum müssen wir uns das ein bisschen anpassen

cd /usr/src
wget http://dag.wieers.com/rpm/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rpm -Uhv rpmforge-release-0.3.6-1.el5.rf.i386.rpm
rm -rf rpmforge-release-0.3.6-1.el5.rf.i386.rpm

Ab jetzt lässt sich Lighttpd auch per yum installieren.

1.1 Installation der nötigen Pakete

yum install lighttpd lighttpd-fastcgi \
php-cli php-mysql php-gd php-pear php-xml php-xmlrpc \
mysql mysql-server phpmyadmin openssl

1.2 Einrichten von Lighttpd

mkdir /var/run/lighttpd
chown lighttpd:lighttpd /var/run/lighttpd
cd /etc/lighttpd
mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighttpd.conf.OLD 
mkdir /srv/www/port80
mkdir /srv/www/port443
rm -rf /srv/www/lighttpd
chown -R lighttpd:lighttpd /srv/www

cat > /etc/lighttpd/lighttpd.conf << "EOF"
server.username             = "lighttpd"
server.groupname            = "lighttpd"
server.document-root        = "/srv/www/port80/"
server.name                 = "www.DEINEDOMAIN.TLD"
server.errorlog             = "/var/log/lighttpd/error.log"
accesslog.filename          = "/var/log/lighttpd/access.log"
server.follow-symlink       = "enable"
server.dir-listing          = "disable"
server.max-keep-alive-idle  = 10
server.pid-file             = "/var/run/lighttpd.pid"
server.indexfiles = (
  "index.xhtml",
  "index.html",
  "index.htm",
  "index.php",
)
server.modules              = (
                              "mod_rewrite",
                              "mod_redirect",
                              "mod_alias",
                              "mod_access",
                              "mod_auth",
                              "mod_status",
                              "mod_fastcgi",
                              "mod_evasive",
                              "mod_accesslog" 
                                )
mimetype.assign             = (
  ".rpm"          =>      "application/x-rpm",
  ".pdf"          =>      "application/pdf",
  ".sig"          =>      "application/pgp-signature",
  ".spl"          =>      "application/futuresplash",
  ".class"        =>      "application/octet-stream",
  ".ps"           =>      "application/postscript",
  ".torrent"      =>      "application/x-bittorrent",
  ".dvi"          =>      "application/x-dvi",
  ".gz"           =>      "application/x-gzip",
  ".pac"          =>      "application/x-ns-proxy-autoconfig",
  ".swf"          =>      "application/x-shockwave-flash",
  ".tar.gz"       =>      "application/x-tgz",
  ".tgz"          =>      "application/x-tgz",
  ".tar"          =>      "application/x-tar",
  ".zip"          =>      "application/zip",
  ".mp3"          =>      "audio/mpeg",
  ".m3u"          =>      "audio/x-mpegurl",
  ".wma"          =>      "audio/x-ms-wma",
  ".wax"          =>      "audio/x-ms-wax",
  ".ogg"          =>      "application/ogg",
  ".wav"          =>      "audio/x-wav",
  ".gif"          =>      "image/gif",
  ".jpg"          =>      "image/jpeg",
  ".jpeg"         =>      "image/jpeg",
  ".png"          =>      "image/png",
  ".xbm"          =>      "image/x-xbitmap",
  ".xpm"          =>      "image/x-xpixmap",
  ".xwd"          =>      "image/x-xwindowdump",
  ".css"          =>      "text/css",
  ".html"         =>      "text/html",
  ".htm"          =>      "text/html",
  ".js"           =>      "text/javascript",
  ".asc"          =>      "text/plain",
  ".c"            =>      "text/plain",
  ".cpp"          =>      "text/plain",
  ".log"          =>      "text/plain",
  ".conf"         =>      "text/plain",
  ".text"         =>      "text/plain",
  ".txt"          =>      "text/plain",
  ".dtd"          =>      "text/xml",
  ".xml"          =>      "text/xml",
  ".mpeg"         =>      "video/mpeg",
  ".mpg"          =>      "video/mpeg",
  ".mov"          =>      "video/quicktime",
  ".qt"           =>      "video/quicktime",
  ".avi"          =>      "video/x-msvideo",
  ".asf"          =>      "video/x-ms-asf",
  ".asx"          =>      "video/x-ms-asf",
  ".wmv"          =>      "video/x-ms-wmv",
  ".bz2"          =>      "application/x-bzip",
  ".tbz"          =>      "application/x-bzip-compressed-tar",
  ".tar.bz2"      =>      "application/x-bzip-compressed-tar",
  # default mime type
  ""              =>      "application/octet-stream",
 )
 static-file.exclude-extensions = ( 
                                   ".php", 
                                   ".pl", 
                                   ".fcgi" 
 )
url.access-deny             = ( "~", ".inc" )
$HTTP["url"] =~ "\.pdf$" {
  server.range-requests = "disable"
}
fastcgi.server             = ( ".php" =>
                               ( "localhost" =>
                                 (
                                   "socket" => "/var/run/lighttpd/php-fastcgi.socket",
                                   "bin-path" => "/usr/bin/php-cgi"
                                 )
                               )
                            )

$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.pemfile = "/etc/lighttpd/ssl/lighttpd.pem"
$HTTP["host"] == "www.domain.de:443" {
server.document-root = "/srv/www/port443/"
accesslog.filename = "/var/log/lighttpd/admin.log"
status.status-url = "/server-status"
status.config-url = "/server-config"
     }
}
EOF
Nun widmen wir uns dem ssl Teil
mkdir -p /etc/lighttpd/ssl
openssl req -new -nodes -x509 -keyout /etc/lighttpd/ssl/lighttpd.pem -out /etc/lighttpd/ssl/lighttpd.pem -days 365
chown lighttpd:lighttpd /etc/lighttpd/ssl/lighttpd.pem
chmod 600 /etc/lighttpd/ssl/lighttpd.pem

Nun muss noch die php.ini angepasst werden.

nano /etc/php.ini
In der letzten Zeile muss folgender Code eingefügt werden.
cgi.fix_pathinfo = 1
Nun müssen wir noch dafür sorgen das der Lighttpd auch nach einem Reboot wieder startet, anschließend starten wir den lighty gleich→
chkconfig –-level 235 lighttpd on
/etc/init.d/lighttpd start

1.2 Einrichten von mysql

Phpmyadmin erreichbar machen

ln -s /usr/share/phpmyadmin/ /srv/www/port443/phpmyadmin
chown -R lighttpd:lighttpd /usr/share/phpmyadmin/
Jetzt müssen wir noch dafür sorgen das wir auch uns später auch einloggen können→
nano  /usr/share/phpmyadmin/config.inc.php
hier sucht ihr
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
und ändert das in
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';

Auch mysql startet nicht automatisch neu. Also werden wir auch hier die entsprechenden Einstellungen vornehmen und es dann gleich starten.

chkconfig –-level 235 mysqld on
/etc/init.d/mysqld start
Nun setzen wir das root Passwort für mysql
mysqladmin -u root password deinpasswort

2.0 Test

Um zu testen ob alles passt kannst du Dir php infos anschaun.

cat >/srv/www/port80/info.php << "EOF"
<?php
phpinfo();
?>
EOF

mit http://deinserver/info.php hast Du nun die Übersicht ;)

Viel Spaß damit,
Sven

Zurück zum Index

 
howto/centos_lighttpd_1.4.18.txt · Zuletzt geändert: 2010/05/16 20:48 von sven
Recent changes RSS feed Creative Commons License Driven by DokuWiki Made on Mac