ubuntu9.04安装 Lighttpd PHP5

Lighttpd是一个安全,快捷,符合标准的Web服务器设计的速度至关重要的环境。此教程说明如何可以安装Lighttpd的Ubuntu的9.04服务器把php5支持(通过的FastCGI )和MySQL的支持。
  • 1初步说明:

本指南中使用的主机名server1.example.com的IP地址192.168.0.100 。这些设置可能有所不同,您必须替换他们。我运行的命令都是以root权限来处理的.所以你必需要先修改你的root登录配置.

$sudo su
先要安装 MySQL 5.0 :
#aptitude install mysql-server mysql-client

在安装的过程中系统会提示你要输入MySQL系统的密码.

New password for the MySQL “root” user: <– yourrootsqlpassword
Repeat password for the MySQL “root” user: <– yourrootsqlpassword

  • 3安装 Lighttpd

Lighttpd 也是 Ubuntu 的一个软件包.所以我可以这样安装它:

#aptitude install lighttpd

现在直接将浏览器http://192.168.0.100 ,你应该看到Lighttpd首页:

 

Click to enlarge

 

在ubuntu上Lighttpd的默认文档根目录 /var/www,
配置文档在 /etc/lighttpd/lighttpd.conf.
其它的配置文档在这个目录中 /etc/lighttpd/conf-available directory
这些配置可以启用的 lighttpd-enable-mod 
命令创建一个符号链接的 /etc/lighttpd/conf-enabled 连接到 /etc/lighttpd/conf-available目录下.
你可以禁止配置lighttpd-disable-mod.

 

  • 4 安装 5

 

我们配置 PHP5 它是工作在 Lighttpd 下需要 FastCGI支持.幸运的, Ubuntu 提供了一个FastCGI-enabled PHP5来安装它:

#aptitude install php5-cgi

 

  • 5 配置Lighttpd And PHP5

开启 PHP5 in Lighttpd, 我们必需要修改 /etc/php5/cgi/php.ini 并变成为 cgi.fix_pathinfo = 1 这才是正确的答案:

#vi /etc/php5/cgi/php.ini

[...]
cgi.fix_pathinfo = 1

开启配置 fastcgi (文档存文位置 /etc/lighttpd/conf-available/10-fastcgi.conf), 运行下面的命令:

#lighttpd-enable-mod fastcgi

这将创建一个符号链接 /etc/lighttpd/conf-enabled/10-fastcgi.conf 连接到/etc/lighttpd/conf-available/10-fastcgi.conf:

#ls -l /etc/lighttpd/conf-enabled

root@server1:~#ls-l/etc/lighttpd/conf-enabled
total0
lrwxrwxrwx1rootroot442009-04-3014:3910-fastcgi.conf->/etc/lighttpd/conf-available/10-fastcgi.conf
root@server1:~#

 

然后,我们重载Lighttpd :

 

#/etc/init.d/lighttpd force-reload


  • 6 测试 PHP5 

的文档根目录的默认Web站点是 /var/www. 现在我们将建立一个小型 PHP 文档 info.php) 该目录中,并要求它在浏览器中.该文件将显示很多有用的详细介绍我们的PHP安装,如安装了PHP版本。

#vi /var/www/info.php

<?php
phpinfo();
?>

在IE里输入(e.g. http://192.168.0.100/info.php):

Click to enlarge

 

正如所看到的,把php5是工作,而且它的工作通过的FastCGI, 所显示的服务器的API线。如果你继续向下滚动,你会看到所有的模块,已经启用了把php5 。 MySQL是有没有列出这意味着我们没有支持MySQL把php5没有。

 

  • 7 使用MySQL支持php5

使用MySQL支持php5, 我们可以安装 php5-mysql软件包. 这是一个很好的安装方法.很快就可能安装完成.因为安装PHP5还需要一些模块.那么我们可搜索可用的php5模块:

#aptitude search php5

 

选择那些你需要并安装的:

 

#aptitude install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json

现在重启 Lighttpd:

#/etc/init.d/lighttpd restart

现在重新加载IE http://192.168.0.100/info.php 你可以看到相关的模块了. 您现在应该可以找到很多新的模块,其中包括了 MySQL 模块:

原创文章,转载请注明: 转载自PT Ubuntu Blog

本文链接地址: http://www.ptubuntu.com/2009/05/2581.html

Share

{ 发表评论? }

  1. hone

    thank you!

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


Verify Code   If you cannot see the CheckCode image,please refresh the page again!