php5.6完全yum安装LAMP环境并加载fastcgi模块
1、前言
公司开发要求使用php5.6版本,由于笔者不想通过编译安装,故引入remi的yum源来完成此项任务,跟之前的lamp环境加载fastcgi的方式大致一样,只是有一点点差异。
原文:http://cmdschool.blog.51cto.com/2420395/1708237
2、实验部分
2.1、实验环境
lampSer:
hostname=lamp-fcgi
ipaddress=10.168.0.177
client:
hostnmae=client
ipaddress=10.168.0.8
2.2、yum源的安装
yum-yinstallhttp://rpms.famillecollet.com/enterprise/remi-release-6.rpmyum-yinstallhttpdmod_proxy_fcgiphp56-php-fpmmysqlmysql-serverphp-mysqlyum-yinstallpolicycoreutils-python
2.3、配置部分
2.3.1、step1
注:如果你不想了解fastcgi的加载方式本步骤请直接跳过
检查是否引入fastcgi模块(默认开启),主配置文件:
grep^Include/etc/httpd/conf/httpd.conf
包含如下内容:
Includeconf.d/*.conf
查看fastcgi支持模块配置文件:
grepLoadModule/etc/httpd/conf.d/mod_proxy_fcgi.conf
包含如下内容:
LoadModuleproxy_fcgi_modulemodules/mod_proxy_fcgi.so
2.3.2、step2
1)启动php-fpm、httpd&mysqld服务:
/etc/init.d/php56-php-fpmstartchkconfigphp56-php-fpmon/etc/init.d/httpdstartchkconfighttpdon/etc/init.d/mysqldstartchkconfigmysqldon
注:关于mysql的安全设置请运行以下指令,这里不再详述!
mysql_secure_installation
2)确认php-fpm服务启用
netstat-anp|grepphp
应当显示如下:
tcp00127.0.0.1:90000.0.0.0:*LISTEN2547/php-fpmunix3[]STREAMCONNECTED346652547/php-fpmunix3[]STREAMCONNECTED346642547/php-fpm
2.3.3、step3
1)vim编辑/etc/httpd/conf/httpd.conf
启用并更改ServerName(去掉ServerName前面的#)
启用NameVirtaulHost(去掉ServerName前面的#)
ServerNamewww.cmdschool.org:80NameVirtualHost*:80
2)新建虚拟目录:
mkdir/var/www/www.cmdschool.org
3)添加测试页面:
echo'<?phpphpinfo();?>'>/var/www/www.cmdschool.org/index.php
4)确保selinux是Enforcing状态:
getenforce
5)恢复预设的selinux type:
restorecon-RFvv/var/www/www.cmdschool.org/
显示如下:
restoreconreset/var/www/www.cmdschool.orgcontextunconfined_u:object_r:httpd_sys_content_t:s0->system_u:object_r:httpd_sys_content_t:s0restoreconreset/var/www/www.cmdschool.org/index.phpcontextunconfined_u:object_r:httpd_sys_content_t:s0->system_u:object_r:httpd_sys_content_t:s0
6)检查当前的selinux type:
ll-dZ/var/www/www.cmdschool.org/
7)开启虚拟目录对fastcgi的支持并设置虚拟目录:
vim编辑/etc/httpd/conf.d/www.cmdschool.org.conf
DirectoryIndex/index.phpindex.php<VirtualHost*:80>ProxyPassMatch^/(.*\.php(/.*)?)$fcgi://127.0.0.1:9000/var/www/www.cmdschool.org/$1DocumentRoot/var/www/www.cmdschool.orgServerNamewww.cmdschool.org</VirtualHost><Directory/var/www/www.cmdschool.org>OptionsAllAllowOverrideall</Directory>
8)重启php-fpm&httpd服务:
/etc/init.d/php56-php-fpmrestart/etc/init.d/httpdrestart
2.3.4、step4
设置防火墙:
vim编辑/etc/sysconfig/iptables
-AINPUT-mstate--stateNEW-mtcp-ptcp--dport80-jACCEPT
重启防火墙:
/etc/init.d/iptablesrestart
2.4.5、step5
In client
测试服务器
1)vim编辑/etc/hosts
确保包含www.cmdschool.org的指向10.168.0.171的唯一值:
10.168.0.171www.cmdschool.org
2)curl测试
curlwww.cmdschool.org
3)浏览器测试
参阅资料:
http://www.linuxidc.com/Linux/2013-08/88571.htm
官方参阅资料:
http://wiki.apache.org/httpd/PHP-FPM
其他参考:
http://cnzhx.net/blog/apache-httpd-mod_proxy_fcgi-php-fpm/#ProxyPassMatch
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。