Chinaunix首页 | 论坛 | 博客
  • 博客访问: 58023
  • 博文数量: 25
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 30
  • 用 户 组: 普通用户
  • 注册时间: 2013-09-13 21:20
文章分类
文章存档

2014年(14)

2013年(11)

我的朋友

分类: BSD

2013-12-07 13:31:44

其实安装方法在官方的wiki就可找到,详细:

1.$ cd /usr/ports/lang/php5
# make install clean
按回车的时候,

选择 [X] FASTCGI    Enable fastcgi support (CGI only)

Be sure to check the "use as FastCGI" option in the configuration screen. If you don't see the configuration screen, you're either using an old version of ports tree, or need to execute "make config". If you're using PHP 4 or an early version of PHP 5, you may have to use www/php4-cgi or a similar port instead of the new master port.

2 安装lighttpd

cd /usr/ports/www/lighttpd/
make install clean

按回车的时候,选择

[X] OPENSSL    Enable SSL support

其他选项,看个人需要。

3.由于lighttpd的配置文件/usr/local/etc/lighttpd.conf很直观,仔细看下,基本的选项还是比较容易理解。现在只需要搞几个地方就可以整合php了。

以下2步就可以做一个简单的步骤,就可以搭设成php环境:
  (1)在/usr/local/etc/lighttpd.conf 里找到server.modules里的"mod_fastcgi",把"#"注释去掉.

server.modules = (
                   "mod_fastcgi",
                 )

 
(2)接下来找到fastcgi.server  ,把socket 和bin-path两项参数写好:

fastcgi.server             = ( ".php" =>
                               ( "localhost" =>
                                 (
                                   "socket" => "/var/run/lighttpd/php-fastcgi.socket",
                                   "bin-path" => "/usr/local/bin/php-cgi"
                                 )
                               )
                            )

由于socket文件不存在,所以你需要mkdir /var/run/lighttpd; touch /var/run/lighttpd/php-fastcgi.socket; chown www:www /var/run/lighttpd/php-fastcgi.socket .
(3)## for PHP don't forget to set cgi.fix_pathinfo = 1 in the php.ini
把cgi.fix_pathinfo = 1 写如php.ini (去掉注释,改为1就可以了)
现在可以启动lighttpd了,但是由于没有以下文件,所以还需要建立2个文件,且修改权限。

touch /var/log/lighttpd.error.log
touch /var/log/lighttpd.access.log
chown www:www /var/log/lighttpd.*

设置SSL支持
创建证书
cd /etc/ssl/private/
#openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes
4.5.2 打开SSL支持
#### SSL engine
ssl.engine = “enable”
ssl.pemfile = “/opt/etc/server.pem”

设置自动启动
vi /etc/rc.conf
lighttpd_enable=”YES”
5.2 手工启动
/usr/local/etc/rc.d/lighttpd.sh start
注意,如果没有在/etc/rc.conf添加 /etc/rc.conf ,是不能启动的。所以需要先添加。


 
安装php5-extension还是一样,进入/usr/ports/lang/php52-extensions/ ,选择自己所需要的扩展就可。遇到的问题:
安装好extension后,在命令行下打下: php -v ,出现以下等错误
PHP Warning:  PHP Startup: Unable to load dynamic library './ctype.so' - Cannot open "./ctype.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './pcre.so' - Cannot open "./pcre.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './simplexml.so' - Cannot open "./simplexml.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './spl.so' - Cannot open "./spl.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './dom.so' - Cannot open "./dom.so" in Unknown on line 0
PHP Warning:  PHP Startup: Unable to load dynamic library './filter.so' - Cannot open "./filter.so" in Unknown on line 0
解决方法:在/usr/local/etc/php.ini里找到extension-dir,修改路径为你的extension的目录就可。比如
; Directory in which the loadable extensions (modules) reside.
extension_dir = "/usr/local/lib/php/20060613/"
阅读(1464) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~