CentOS 编译安装php5.5, 并配制支持apach,nignx核心代码
首先是编译准备工作:
yumgroupinstall"Developmenttools"
然后是编译安装 PHP 5.5.x 需要用到的 devel 包:
yuminstalllibxml2-develgd-devellibmcrypt-devellibcurl-developenssl-devel
从官方下载,解压:
wgethttp://us3.php.net/get/php-5.5.5.tar.gz/from/cn2.php.net/mirrortar-xvfphp-5.5.5.tar.gzcdphp-5.5.5
编译安装 php 5.5 的参数:
./configure--with-apxs2=/usr/local/apache2/bin/apxs--disable-cli--enable-shared--with-libxml-dir--with-gd--with-openssl--enable-mbstring--with-mcrypt--with-mysqli--with-mysql--enable-opcache--enable-mysqlnd--enable-zip--with-zlib-dir--with-pdo-mysql--with-jpeg-dir--with-freetype-dir--with-curl--without-pdo-sqlite--without-sqlite3
我已经尽量的在参数上做了精简,用以上参数编译安装好的 php 运行 wordpress, joomla, ip board 等常见的博客、论坛程序都是没有问题的,因为有了 --disable-cli,所以就没法 make test 了,安装好以后也没法 php -v 了。安装吧:
makemakeinstallcpphp.ini-production/usr/local/lib/php.ini#记住上面php.ini的位置哦。
如是apache, 配制 apache
是时候让 apache 知道有 php 的存在了,在 apache 配置文件 httpd.conf 中添加:
LoadModulephp5_modulemodules/libphp5.so#上面那行可能在编译安装php的过程中已经由系统自动添加了<FilesMatch\.php$>SetHandlerapplication/x-httpd-php</FilesMatch>
OK!重启 apache,人品好的人是不会出现问题的。
如是nignx, 配制 nignx
cp/etc/nginx/conf.d/default.conf/etc/nginx/conf.d/default.confbak#备份原有配置文件vi/etc/nginx/conf.d/default.conf#编辑
index index.php index.html index.htm;#增加index.php
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#location~\.php${roothtml;fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;includefastcgi_params;}
#取消FastCGI server部分location的注释,并要注意fastcgi_param行的参数,改为$document_root$fastcgi_script_name,或者使用绝对路径
service nginx restart#重启nginx
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。