1、安装lighttpd
进入系统,直接安装:
sudo apt-get install lighttpd
安装完,查看lighttpd目录:
a***@a***:/usr/bin$ whereis lighttpd
lighttpd: /usr/sbin/lighttpd /etc/lighttpd /usr/lib/lighttpd /usr/share/lighttpd /usr/share/man/man8/lighttpd.8.gz
确认lighttpd状态:
a****@a***:/usr/bin$ sudo /etc/init.d/lighttpd status
* lighttpd is running
2、安装php
sudo apt-get install php5-cgi
安装完,查看php目录:
a***@a***:/usr/bin$ whereis php5
php5: /etc/php5 /usr/lib/php5 /usr/share/php5
a***@a***:/usr/bin$ whereis php5-cgi
php5-cgi: /usr/bin/php5-cgi /usr/share/man/man1/php5-cgi.1.gz
安装完,查看php版本:
a***@a***:/usr/bin$ /usr/bin/php5-cgi -v
PHP 5.3.2-1ubuntu4.28 with Suhosin-Patch (cgi-fcgi) (built: Oct 29 2014 11:54:36)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
3、配置lighttpd支持php:
/etc/lighttpd/lighttpd.conf是lighttpd的主要配置文件,需要将文件做如下两步修改:
1)、 增加"mod_fastcgi", "mod_cgi"两项
修改前:
server.modules = (
"mod_access",
"mod_alias",
"mod_accesslog",
"mod_compress",
)
修改后:
server.modules = (
"mod_access",
"mod_fastcgi",
"mod_cgi",
"mod_alias",
"mod_accesslog",
"mod_compress",
)
2)在文件尾增加:
fastcgi.server = ( ".php" =>
( "localhost" =>
(
"socket" => "/tmp/php.socket",
"bin-path" => "/usr/bin/php5-cgi"
)
)
)
4、重启lighttpd服务器:
a***@a***:/usr/bin$ sudo /etc/init.d/lighttpd restart
[sudo] password for a***:
Syntax OK
* Stopping web server lighttpd [ OK ]
Syntax OK
* Starting web server lighttpd [ OK ]
这下在var/www/下新增一个php文件就可以读出来了。
参考文档:
http://blog.chinaunix.net/uid-20761674-id-276003.html
http://blog.csdn.net/l0605020112/article/details/10104233
http://www.linuxidc.com/Linux/2011-12/48808.htm
http://zhidao.baidu.com/link?url=Wy8_Mx_bduKs3F7_kBKYiQ7m0s_-zCPSQFvglZL3xJMsva9oVX8XKm7yWjoHGyLVl2lrMgKhpX-ukmiKG4hT5K