php5.6.40下载:https://www.php.net/distributions/php-5.6.40.tar.gz
php安装:
1.安装依赖包
yum 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 epel-release -y
yum install -y libmcrypt-devel
2.解压源码包
tar -zvxf php-5.6.40.tar.gz -C /usr/local
ln -s php-5.6.40 php
cd php
3.创建用户
groupadd www
useradd -g www -s /sbin/nologin www
4.编译参数
./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/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
5.安装
make && make install
6.配置文件
cp php.ini-development /usr/local/php/etc/php.ini
php.ini文件需要修改
7.php-fpm 服务
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf php-fpm.conf需要修改
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig on php-fpm
service php-fpm start
8.环境变量
#echo "export PATH=$PATH:/usr/local/php/bin" >> /etc/profile
# source /etc/profile