当前位置: 首页 > >

源码安装PHP7和ApachePHP支持

发布时间:


本文参考http://www.jb51.net/article/109228.htm文章,并在安装过程中出现的问题加入解决方法。

系统CentOS6.5


首先升级YUM仓




yum install epel-release //扩展包更新包
yum update //更新yum源



安装PHP依赖环境




yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel


安装HTTPD



yum -y install httpd httpd-devel #这里必须加上HTTPD扩展,如果不加编译安装PHP时会报错

下载php


wget -O php7.tar.gz http://cn2.php.net/get/php-7.1.1.tar.gz/from/this/mirror

解压


tar -zxvf php7.tar.gz

mv php7.1.1 php

cd php








配置PHP


./configure --prefix=/usr/local/php --with-config-file-path=/etc --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-apxs2=/usr/sbin/apxs --with-libxml-dir --with-xmlrpc --with-openssl --with-mcrypt --with-mhash --with-pcre-regex --with-sqlite3 --with-zlib --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --with-cdb --enable-dom --enable-exif --enable-fileinfo --enable-filter --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-native-ttf --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-json --enable-mbstring --enable-mbregex --enable-mbregex-backtrack --with-libmbfl --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --with-readline --enable-session --enable-shmop --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip --enable-mysqlnd-compression-support --with-pear --enable-opcache





编译安装

make && make install

配置环境变量

vim /etc/profile







在最下方加入

PATH=$PATH:/usr/local/php/bin
export PATH
使配置立即生效


source /etc/profile配置php-fpm

cp php.ini-production /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm

添加nginx用户 因为/usr/local/php/etc/php-fpm.d/www.conf文件中对用户和组为nginx的关系








useradd nginx启动php-fpm


service php-fpm start修改httpd.conf文件


vim /etc/httpd/conf/httpd.conf

AddType?application*
后面加如下一行



AddType application/x-httpd-php .php .phtml

DirectoryIndex?index.html
加上
index.php


DirectoryIndex index.php index.html确保httd.conf文件中包含以下字段,如不包含则加入此字段


LoadModule php7_module /usr/lib64/httpd/modules/libphp7.so*鬑TTPD


service httpd restart



















友情链接: hackchn文档网 营销文档网 爱linux网 爱行业网 时尚网