CentOS6.8服务器LAMP环境搭建(三) 源码安装php7.1.4

时间:2022-09-17 18:18:30

第一篇写了CentOS6.8服务器LAMP环境搭建(一) 安装Apache2.4.25,接下来接着CentOS6.8服务器LAMP环境搭建(二) 使用cmake安装MySQL5.7.18,续写CentOS6.8服务器LAMP环境搭建(三) 源码安装php7.1.4。


1、将php源码安装包下载到/usr/local/src目录下

cd /usr/local/src

# wget http://php.net/get/php-7.1.4.tar.gz/from/a/mirror


2、解压软件包

# tar -zxvf php-7.1.4.tar.gz


3、进入解压后的文件夹

# cd php-7.1.4


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

./configure \
--prefix=/usr/local/php \
--exec-prefix=/usr/local/php \
--bindir=/usr/local/php/bin \
--sbindir=/usr/local/php/sbin \
--with-libdir=/usr/lib64 \
--disable-rpath \
--with-apxs2=/usr/local/apache2/bin/apxs \
--enable-fpm \
--with-config-file-path=/etc \
--with-libxml-dir \
--with-openssl \
--with-zlib=/usr/local/zlib \
--with-zlib-dir=/usr/local/zlib \
--enable-bcmath \
--with-bz2 \
--enable-calendar \
--with-curl=/usr/local/curl \
--enable-exif \
--with-pcre-dir=/usr/local/pcre/ \
--enable-ftp \
--with-openssl-dir \
--with-gd \
--with-jpeg-dir=/usr/local/jpeg9/ \
--with-png-dir=/usr/local/libpng \
--with-xpm-dir=/usr/include/X11/xpm.h \
--with-freetype-dir=/usr/local/freetype/ \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-mbstring \
--with-libmbfl \
--with-onig \
--with-mcrypt=/usr/include \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-readline \
--enable-shmop \
--enable-soap \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-xmlrpc \
--with-xsl \
--enable-zip \
--with-pear \
--enable-mysqlnd \
--enable-shared \
--enable-inline-optimization \
--disable-debug \
--enable-xml \
--with-sqlite3 \
--with-iconv \
--with-cdb \
--enable-dom \
--enable-fileinfo \
--enable-filter \
--enable-json \
--enable-mbregex \
--enable-mbregex-backtrack \
--enable-pdo \
--with-pdo-sqlite \
--enable-session \
--enable-simplexml \
--enable-opcache


6、编译安装

# make && make install


7、配置环境变量

编辑/etc/profile

在末尾追加:

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

执行命令使得改动立即生效:

# source /etc/profile


8、配置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


9、启动php-fpm
# /etc/init.d/php-fpm start


php安装完成,至此,lamp环境就搭建完成了,接下来会续写phpMyAdmin的安装。