openwrt php-fpm,Centos 6.5 上yum安装lighttpd+php-fpm

平台:Centos 6.5 x86_64

据说Lighttpd对动态网页和图片处理很强,安装试试,以php-fpm方式管理fastcgi

1,安装lighttpd

rpm -Uvh http://mirrors.yun-idc.com/epel/6/x86_64/epel-release-6-8.noarch.rpm

yum update -y

yum install -y lighttpd lighttpd-fastcgi

2,安装php

rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

yum install -y php55w php55w-common php55w-cli php55w-mysql php55w-gd php55w-fpm php55w-intl php55w-mcrpt php55w-mbstring php55w-mcrypt php55w-pdo php55w-pear php55w-soap php55w-tidy php55w-xml php55w-xmlrpc  php55w-opcache php55w-devel

sed -i 's/expose_php = On/expose_php = Off/g' /etc/php.ini

sed -i 's/;date.timezone =/date.timezone = PRC/g' /etc/php.ini

sed -i 's/disable_functions =.*/disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,popen,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server/g' /etc/php.ini

3,简单配置(2G vps)

sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=1/g' /etc/php.ini

sed -i 's/user = apache/user = lighttpd/g' /etc/php-fpm.d/www.conf

sed -i 's/group = apache/group = lighttpd/g' /etc/php-fpm.d/www.conf

sed -i 's/pm.max_children = 50/pm.max_children = 100/g' /etc/php-fpm.d/www.conf

sed -i 's/pm.start_servers = 5/pm.start_servers = 10/g' /etc/php-fpm.d/www.conf

sed -i 's/pm.min_spare_servers = 5/pm.min_spare_servers = 10/g' /etc/php-fpm.d/www.conf

sed -i 's/pm.max_spare_servers = 35/pm.max_spare_servers = 70/g' /etc/php-fpm.d/www.conf

sed -i 's/;pm.max_requests = 500/pm.max_requests = 10240/g' /etc/php-fpm.d/www.conf

sed -i 's/;rlimit_files = 1024/rlimit_files = 51200/g' /etc/php-fpm.d/www.conf

chkconfig --level 235 php-fpm on

service php-fpm start

ulimit -HSn 65535

chown -R lighttpd:lighttpd /var/lib/php/session/

sed -i 's/server.use-ipv6 = "enable"/server.use-ipv6 = "disable"/g' /etc/lighttpd/lighttpd.conf

sed -i 's/#server.max-fds = 2048/server.max-fds = 4096/g' /etc/lighttpd/lighttpd.conf

sed -i 's/server.max-connections = 1024/server.max-connections = 2048/g' /etc/lighttpd/lighttpd.conf

sed -i 's/server.stat-cache-engine = "simple"/server.stat-cache-engine = "fam"/g' /etc/lighttpd/lighttpd.conf

mkdir -p /var/www//htdocs

chown -R lighttpd:lighttpd /var/www//htdocs

chkconfig --levels 235 lighttpd on

sed -i 's%#include "conf.d/fastcgi.conf"%include "conf.d/fastcgi.conf"%g' /etc/lighttpd/modules.conf

mkdir -p /var/cache/lighttpd/compress

chown -R lighttpd:lighttpd /var/cache/lighttpd/compress

sed -i 's%#include "conf.d/compress.conf"%include "conf.d/compress.conf"%g' /etc/lighttpd/modules.conf

sed -i 's%compress.filetype          = ("text/plain", "text/html")%compress.filetype          = ("text/plain", "text/html","application/x-javascript", "text/css", "application/javascript", "text/javascript")%g' /etc/lighttpd/conf.d/compress.conf

cat  >>  /etc/lighttpd/conf.d/fastcgi.conf<

fastcgi.server += ( ".php" =>

((

"host" => "127.0.0.1",

"port" => "9000",

"broken-scriptfilename" => "enable",

"check-local" => "disable",

))

)

EOF

若用unix socket

vi /etc/php-fpm.d/www.conf 将

listen 127.0.0.1:9000改为

listen /var/run/php-fpm/php-cgi.sock

touch /var/run/php-fpm/php-cgi.sock

chown lighttpd:lighttpd /var/run/php-fpm/php-cgi.sock

cat  >>  /etc/lighttpd/conf.d/fastcgi.conf<

fastcgi.server += ( ".php" =>

((

"socket" => "/var/run/php-fpm/php-cgi.sock",

"broken-scriptfilename" => "enable",

"check-local" => "disable",

))

)

service php-fpm restart

service lighttpd restart

4,测试

echo '<?php phpinfo(); ?>' > /var/www//htdocs/index.php

http://yourserverip

看到phpinfo结果即完成

用php-cgi管理fastcgi,配置Lighttpd如下:

mkdir -p /var/www//html

chown -R lighttpd:lighttpd /var/www/html

chkconfig --levels 235 lighttpd on

# vi /etc/lighttpd/lighttpd.conf

server.document-root = server_root + "/html"

sed -i 's/server.use-ipv6 = "enable"/server.use-ipv6 = "disable"/g' /etc/lighttpd/lighttpd.conf

sed -i 's/#server.max-fds = 2048/server.max-fds = 2048/g' /etc/lighttpd/lighttpd.conf

sed -i 's/server.stat-cache-engine = "simple"/server.stat-cache-engine = "fam"/g' /etc/lighttpd/lighttpd.conf

1. vim /etc/php.ini

找到cgi.fix_pathinfo,将其值置为1,结果为:"cgi.fix_pathinfo=1"

2. vim /etc/lighttpd/modules.conf

找到include "conf.d/fastcgi.conf",将其前面的注释删除。

3.Configure php as fastcgi

# For a large server set max-procs, PHP_FCGI_CHILDREN, and PHP_FCGI_MAX_REQUESTS as per your setup ##

cat >> /etc/lighttpd/conf.d/fastcgi.conf<

fastcgi.server    = ( ".php" =>

((

"bin-path" => "/usr/bin/php-cgi",

"socket" => "/tmp/php-cgi.socket." + var.PID,

"max-procs" => 1,

"idle-timeout" => 30,

"bin-environment" => (

"PHP_FCGI_CHILDREN" => "1",

"PHP_FCGI_MAX_REQUESTS" => "50"

),

"bin-copy-environment" => (

"PATH",

"SHELL",

"USER"

),

"broken-scriptfilename" => "enable"

))

)

EOF

service lighttpd restart

echo '<?php phpinfo(); ?>' > /var/www//html/index.php

http://yourserverip

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值