平台:debian7 x86_64
用的php-fpm管理fastcgi
更新系统
apt-get update
apt-get upgrade -y
安装php-fpm和lighttpd
apt-get install -y lighttpd php5 php5-fpm php5-gd php5-common php5-intl php5-xmlrpc php-pear php5-mysql php5-curl libcurl3 php5-mcrypt php5-mhash php5-xcache vim vim-runtime
sed -i 's/expose_php = On/expose_php = Off/g' /etc/php5/fpm/php.ini
sed -i 's/;date.timezone =/date.timezone = PRC/g' /etc/php5/fpm/php.ini
sed -i 's/disable_functions =.*/disable_functions = passthru,exec,system,chroot,scandir,chgrp,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server/g' /etc/php5/fpm/php.ini
简单配置
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=1/g' /etc/php5/fpm/php.ini
mkdir /var/www/html
chown www-data:www-data /var/www/html/
vi /etc/lighttpd/lighttpd.conf
server.document-root = "/var/www/html"
server.username = "www-data"
server.groupname = "www-data"
vi /etc/php5/fpm/pool.d/www.conf
;listen = /var/run/php5-fpm.sock
listen = 127.0.0.1:9000
cd /etc/lighttpd/conf-available/
cp 15-fastcgi-php.conf 15-fastcgi-php.conf.bak
vi /etc/lighttpd/conf-available/15-fastcgi-php.conf
修改fastcgi.server
fastcgi.server += ( ".php" =>
((
"host" => "127.0.0.1",
"port" => "9000",
"broken-scriptfilename" => "enable",
))
)
若用Unix socket做如下修改
fastcgi.server += ( ".php" =>
((
"socket" => "/var/run/php5-fpm.sock",
"broken-scriptfilename" => "enable",
))
)
开启fastcgi模块
lighttpd-enable-mod fastcgi
lighttpd-enable-mod fastcgi-php
重启服务
service php5-fpm restart
service lighttpd force-reload
测试
echo "<?php phpinfo(); ?>" > /var/www/html/index.php
http://IP/看到phpinfo结果即搭建成功