centos7 php编译安装

11 篇文章 0 订阅

1.下载源码
wget -O php7.tar.gz http://cn2.php.net/get/php-7.1.1.tar.gz/from/this/mirror
2.解压php7
tar -xvf php7.tar.gz
3.进入php目录
cd php-7.1.1

4.安装依赖包

yum 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

5.编译配置(如果出现错误,基本都是上一步的依赖文件没有安装所致)

./configure \
--prefix=/data/server/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-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 \
--without-pear \
--disable-phar

编译安装php报错PHP configure: error: mcrypt.h not found. Please reinstall libmcrypt. 解决办法
1、使用yum命令安装
yum  install  php-mcrypt  libmcrypt  libmcrypt-devel

方法2:
使用php mcrypt 前必须先安装Libmcrypt
libmcrypt源码安装方法:

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz
tar -zxvf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
./configure  –prefix=/usr/local
make
make install
再去编译安装就可以了。如有其他报错,请根据具体报错解决。

php Make编译PEAR package PHP_Archive not installed解决方法

php 的编译时需要依赖pear package ,目前的问题错误"PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.",已经明显报出这个问题。
因此编译使用参数 --without-pear   将pear 屏蔽掉编译安装后,再进行安装;同时因为phar 属于pear的一个库 ,所以不将phar关闭掉,同时还会报这个错误,
同时需要使用 --disable-phar   编译参数. 
 
./configure --without-pear  --disable-phar
make
make install
 
成功编译安装完成后,再安装pear
 
wget  http://pear.php.net/go-pear.phar 
/usr/local/php/bin/php go-pear.phar

7.配置环境变量
vi /etc/profile

PATH=$PATH:/usr/local/php/bin
export PATH

执行命令使得改动立即生效
source /etc/profile
到相应的目录进行复制
cp data/server/php-1.1.1/php.ini-production /data/serve/php/etc/php.ini  
cp /data/server/php/php-fpm.conf.default /data/serve/php/etc/php-fpm.conf
cp /data/server/php/etc/php-fpm.d/www.conf.default /data/serve/php/etc/php-fpm.d/www.conf
cp data/server/php-1.1.1/sapi/fpm/init.d.php-fpm /data/serve/php/etc/init.d/php-fpm
chmod +x /data/serve/php/etc/init.d/php-fpm

启动php-fpm
/data/serve/php/etc/init.d/php-fpm

软连接
sudo ln -s /data/server/php/bin/php /usr/bin/php (把PHP命令添加到bin里面,可以全局使用)

查看php.ini位置:
php -i |grep php.ini

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值