在ubuntu 11.04 上安装 lighttpd+php5+mysql网站服务器

Lighttpd很少听说,先来说一说Lighttpd,Lighttpd 是一个德国人领导的开源Web服务器软件,其根本的目的是提供一个专门针对高性能网站,安全、快速、兼容性好并且灵活的web server环境。具有非常低的内存开销,cpu占用率低,效能好,以及丰富的模块等特点。
Lighttpd是众多OpenSource轻量级的web server中较为优秀的一个。支持FastCGI, CGI, Auth, 输出压缩(output compress), URL重写, Alias等重要功能,而Apache之所以流行,很大程度也是因为功能丰富,在lighttpd上很多功能都有相应的实现了,这点对于apache的用户是非常重要的,因为迁移到lighttpd就必须面对这些问题。
此教程和不久前不发的”Ubuntu 11.04 安装 Nginx+Php5+Mysql 的Web服务器“算是姐妹篇,出自同一个网站howtoforge.com
一、安装前说明
在本教程中使用的主机名server1.example.com与IP地址192.168.0.100。这些设置可能会与你的设置有所不同,所以你必须在适当情况下更换。
很多操作都需要使用超级用户名,所以避免麻烦,我们先切换到超级用户名下操作,终端输入命令:
sudo su
二、安装MySQL 5
在终端输入命令安装:
apt-get install mysql-server mysql-client
安装过程中需要你设置mysql超级root用户密码,输入两次如图所示:

三、安装lighttpd
lighttpd在ubuntu软件库中也有,与安装apache、nginx一样,一个命令就可以了:
apt-get install lighttpd
然后直接在浏览器中输入http://192.168.0.100/index.lighttpd.html,就应该看到lighttpd页面,如图所示,看到了一下界面,说明安装成功并运行正常:

这里说明一下,Lighttpd在ubuntu中默认根目录为/var/www,配置文件/etc/lighttpd/lighttpd.conf,默认网站配置文件:/etc/lighttpd/conf-available,lighttpd可以开启配置命令:lighttpd-enable-mod ,lighttpd禁用配置命令:lighttpd-disable-mod
四、安装PHP5
可以通过安装PHP5 FastCGI来和lighttpd 一起运行。Ubuntu库里面提供了FastCGI功能PHP5解决方案,我们这样的安装:
apt-get install php5-cgi
五、配置lighttpd和PHP5
配置php5启用lighttpd,修改/ etc/php5/cgi/php.ini 和注释行cgi.fix_pathinfo = 1:
vi / etc/php5/cgi/php.ini
如下代码配置:

; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP’s
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting
; of zero causes PHP to behave as before. Default is 1. You should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://php.net/cgi.fix-pathinfo
cgi.fix_pathinfo=1

要启用FastCGI配置,运行以下命令:

lighttpd-enable-mod fastcgi
lighttpd-enable-mod fastcgi-php

创建链接符/etc/lighttpd/conf-enabled/10-fastcgi.conf指向/etc/lighttpd/conf-available/10-fastcgi.conf和/etc/lighttpd/conf-enabled/15-fastcgi-php.conf。指向/etc/lighttpd/conf-available/15-fastcgi-php.conf:
ls -l /etc/lighttpd/conf-enabled
如下显示:
root@server1:~# ls -l /etc/lighttpd/conf-enabled
total 0
lrwxrwxrwx 1 root root 33 2011-05-12 13:46 10-fastcgi.conf -> ../conf-available/10-fastcgi.conf
lrwxrwxrwx 1 root root 37 2011-05-12 13:46 15-fastcgi-php.conf -> ../conf-available/15-fastcgi-php.conf
root@server1:~#
然后,重新加载lighttpd:
/etc/init.d/lighttpd force-reload
六、测试PHP5 /获取关于PHP5安装细节
创建一个info.php文件进行调试,看看那些模块在运行。
vi /var/www/info.php
添加如下代码,因为这个是函数,在wordpress里面回运行,所以你需要把双引号改为单引号:

《?php
phpinfo();

现在在浏览器中输入http://192.168.0.100/info.php,我们会看到:

如果你看到如上截图,PHP5工作正常,继续向下滚动,看看你已经启动的PHP5模块。MySQL是没有列出,这意味着我们有没有在PHP5中添加MySQL模块支持。
七、在PHP5中获得MySQL支持
需要安装一些模块,我们先检测一下:
apt-cache search php5
然后再输入下面的命令:
apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
然后重启Lighttpd:
/etc/init.d/lighttpd restart

然后再检测一下看看有没有mysql模块,刷新你的页面:http://192.168.0.100/info.php

相关网站链接:
lighttpd的:http://www.lighttpd.net/
PHP:http://www.php.net/
MySQL的:http://www.mysql.com/
Ubuntu的:http://www.ubuntu.com/
原文

投稿作者 作者网站

评论

 
 

发表评论

 
你的昵称*
电子邮件*
网址(选填)
我的评论*
  • 发表评论
  • 为您推荐


    请支持IMCN发展!

    谁在捐赠

    微信捐赠 支付宝捐赠
    微信捐赠 支付宝捐赠
    ta的个人站点

    发表文章4156篇

    关注我的头条 不要放弃,百折不挠,坚强、自信。





    微信公众号二维码

    归档