安装Lighttpd与PHP5和MySQL支持Fedora 8

在Fedora 8上安装带有PHP5和MySQL支持的Lighttpd

版本1.0
作者:Falko Timme

Lighttpd是一款安全,快速,符合标准的Web服务器,专为速度至关重要的环境而设计。 本教程将介绍如何在具有PHP5支持(通过FastCGI)和MySQL支持的Fedora 8服务器上安装Lighttpd。

我不会保证这将为您工作!

1初步说明

在本教程中,我使用IP地址为192.168.0.100的hostname server1.example.com 。 这些设置可能会有所不同,因此您必须在适当的情况下更换它们。

2安装MySQL 5.0

首先我们像这样安装MySQL 5.0:

yum install mysql mysql-server

然后,我们为MySQL创建系统启动链接(以便每当系统启动时,MySQL自动启动)并启动MySQL服务器:

chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start

为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可以作为Fedora软件包使用,因此我们可以这样安装它:

yum install lighttpd

然后我们创建Lighttpd的系统启动链接(以便Lighttpd在系统引导时自动启动)并启动它:

chkconfig --levels 235 lighttpd on
/etc/init.d/lighttpd start

现在直接浏览器到http://192.168.0.100 ,你应该看到Lighttpd占位符页面:

Lighttpd的默认文件根是Fedora上的/ srv / www / lighttpd ,配置文件为/etc/lighttpd/lighttpd.conf

4安装PHP5

我们可以通过FastCGI使PHP5在Lighttpd中工作。 所以我们安装软件包lighttpd-fastcgiphp-cli

yum install lighttpd-fastcgi php-cli

5配置Lighttpd和PHP5

要在Lighttpd中启用PHP5,我们必须修改两个文件/etc/php.ini/etc/lighttpd/lighttpd.conf 。 首先我们打开/etc/php.ini并在文件末尾添加行cgi.fix_pathinfo = 1

vi /etc/php.ini
[...]
cgi.fix_pathinfo = 1

然后我们打开/etc/lighttpd/lighttpd.conf并取消注释“mod_fastcgi”,server.modules节中:

vi /etc/lighttpd/lighttpd.conf
[...]
server.modules              = (
#                               "mod_rewrite",
#                               "mod_redirect",
#                               "mod_alias",
                                "mod_access",
#                               "mod_cml",
#                               "mod_trigger_b4_dl",
#                               "mod_auth",
#                               "mod_status",
#                               "mod_setenv",
                                "mod_fastcgi",
#                               "mod_proxy",
#                               "mod_simple_vhost",
#                               "mod_evhost",
#                               "mod_userdir",
#                               "mod_cgi",
#                               "mod_compress",
#                               "mod_ssi",
#                               "mod_usertrack",
#                               "mod_expire",
#                               "mod_secdownload",
#                               "mod_rrdtool",
                                "mod_accesslog" )
[...]

然后,进一步下来的文件,有一个fastcgi.server节,我们取消注释:

[...]
#### fastcgi module
## read fastcgi.txt for more info
## for PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini
fastcgi.server             = ( ".php" =>
                               ( "localhost" =>
                                 (
                                   "socket" => "/var/run/lighttpd/php-fastcgi.socket",
                                   "bin-path" => "/usr/bin/php-cgi"
                                 )
                               )
                            )
[...]

然后我们重新启动Lighttpd:

/etc/init.d/lighttpd restart
赞(52) 打赏
未经允许不得转载:优客志 » 系统运维
分享到:

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏