在Debian Etch上安装带有PHP5和MySQL的Lighttpd
Lighttpd是一款安全,快速,符合标准的Web服务器,专为速度至关重要的环境而设计。 本教程将介绍如何通过PHP5支持(通过FastCGI)和MySQL支持在Debian Etch服务器上安装Lighttpd。
我不会保证这将为您工作!
1初步说明
在本教程中,我使用IP地址为192.168.0.100的hostname server1.example.com 。 这些设置可能会有所不同,因此您必须在适当的情况下更换它们。
2安装MySQL 5.0
首先我们像这样安装MySQL 5.0:
apt-get install mysql-server mysql-client
为MySQL用户root创建密码(将yourrootsql密码替换为您要使用的密码):
mysqladmin -u root password yourrootsqlpassword
然后检查
netstat -tap | grep mysql
MySQL正在监听哪个地址。 如果输出如下所示:
tcp 0 0 localhost.localdo:mysql *:* LISTEN 2713/mysqld
这意味着MySQL只监听localhost.localdomain ,那么你以前设置的密码是安全的。 但如果输出如下所示:
tcp 0 0 *:mysql *:* LISTEN 2713/mysqld
您也应该为您的主机名设置一个MySQL密码,因为否则任何人都可以访问您的数据库并修改数据:
mysqladmin -h server1.example.com -u root password yourrootsqlpassword
3安装Lighttpd
Lighttpd可以作为Debian软件包使用,因此我们可以这样安装:
apt-get install lighttpd
现在直接浏览器到http://192.168.0.100 ,你应该看到Lighttpd占位符页面:
Lighttpd的默认文档根目录是Debian上的/ var / www ,配置文件为/etc/lighttpd/lighttpd.conf 。
4安装PHP5
我们可以通过FastCGI使PHP5在Lighttpd中工作。 幸运的是,Debian提供了一个支持FastCGI的PHP5软件包,我们安装如下:
apt-get install php5-cgi
5配置Lighttpd和PHP5
要在Lighttpd中启用PHP5,我们必须修改两个文件/etc/php5/cgi/php.ini和/etc/lighttpd/lighttpd.conf 。 首先我们打开/etc/php5/cgi/php.ini ,并在文件末尾添加行cgi.fix_pathinfo = 1 :
vi /etc/php5/cgi/php.ini[...]
cgi.fix_pathinfo = 1
然后我们打开/etc/lighttpd/lighttpd.conf并将“mod_fastcgi”添加到server.modules节:
vi /etc/lighttpd/lighttpd.conf[...]
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"
)
[...]
然后在文件末尾,我们添加以下节:[...]
fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/php5-cgi",
"socket" => "/tmp/php.socket"
)))
然后我们重新启动Lighttpd:
/etc/init.d/lighttpd restart