Centos7 编译 php5.6

环境准备

yum install -y epel-release
yum install -y libmcrypt-devel
yum -y install gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel jemalloc jemalloc-devel

cd /usr/local/src
wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
tar zvxf php-5.6.30.tar.gz
cd php-5.6.30
groupadd www
useradd -g www -s /sbin/nologin www

编译安装

##编译参数

./configure --prefix=/data/server/php \
--with-config-file-path=/data/server/php/etc \
--enable-inline-optimization --disable-debug \
--disable-rpath --enable-shared --enable-opcache \
--enable-fpm --with-fpm-user=www \
--with-fpm-group=www \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gettext \
--enable-mbstring \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--enable-bcmath \
--enable-soap \
--with-libxml-dir \
--enable-pcntl \
--enable-shmop \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--with-curl --with-zlib \
--enable-zip \
--with-bz2 \
--with-readline


 

make && make install

配置服务

#配置文件

cp php.ini-development /data/server/php/etc/php.ini


 
#php-fpm 服务

cp /data/server/php/etc/php-fpm.conf.default /data/server/php/etc/php-fpm.conf
cp sapi/fpm/init.d.php-fpm /data/service/php-fpm
chmod +x /data/service/php-fpm
 


启动

/data/service/php-fpm start

添加环境变量

    

vim /etc/profile

PATH=$PATH:/data/server/php/bin
export PATH

source /etc/profile

Q:configure: error: mcrypt.h not found. Please reinstall libmcrypt.

解决办法:yum install -y epel-release
yum install -y libmcrypt-devel
两个不能一起安装,因为CentOs6默认的yum源没有 libmcrypt-devel这个包,只能借助epel的yum源,所以先安装epel,再安装
libmcrypt。

猜你喜欢

转载自blog.csdn.net/qq389674856/article/details/83116745