PHP 安装

下载地址:

http://cn2.php.net/downloads.php

解压后编译

./configure \

--prefix=/usr/local/php-7.2.4 \

--with-config-file-path=/etc \

--enable-fpm \

--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

通过编译配置过程中遇到的错误,依次安装依赖包

configure error:

configure: error: libxml2 not found. Please check your libxml2 installation

解决:

$ yum install -y libxml2 libxml2-devel

configure: error: Cannot find OpenSSL's <evp.h>

解决:

$ yum install -y openssl openssl-devel

configure: error: Please reinstall the BZip2 distribution

解决:

$ yum install -y bzip2 bzip2-devel

configure: error: cURL version 7.10.5 or later is required to compile php with cURL support

解决:

$ yum install -y libcurl libcurl-devel

If configure fails try --with-webp-dir=<DIR>

configure: error: jpeglib.h not found

解决:

$ yum install -y libjpeg libjpeg-devel

If configure fails try --with-webp-dir=<DIR>

checking for jpeg_read_header in -ljpeg... yes

configure: error: png.h not found

解决:

$ yum install -y libpng libpng-devel

If configure fails try --with-webp-dir=<DIR>

checking for jpeg_read_header in -ljpeg... yes

checking for png_write_image in -lpng... yes

If configure fails try --with-xpm-dir=<DIR>

configure: error: freetype-config not found

解决:

$ yum install -y freetype freetype-devel

configure: error: Unable to locate gmp.h

解决:

$ yum install -y gmp gmp-devel

configure: error: Please reinstall readline - I cannot find readline.h

解决:

$ yum install -y readline readline-devel

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

解决:

$ yum install -y libxslt libxslt-devel

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

解决:

$ yum install -y libmcrypt libmcrypt-devel

configure: WARNING: unrecognized options: --with-mcrypt, --enable-gd-native-ttf

解决:

将编译参数--with-mcrypt, --enable-gd-native-ttf去掉,在phh7.1时,官方就开始建议用openssl_*系列函数代替Mcrypt_*系列的函数

编译与安装

$ make && make install

添加 PHP 命令到环境变量

$ vim /etc/profile

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

配置生效

$ source /etc/profile

配置php-fpm

$ cd /usr/local/software/php-7.2.4

$ cp php.ini-production /etc/php.ini

$ cp /usr/local/php-7.2.4/etc/php-fpm.conf.default /usr/local/php-7.2.4/etc/php-fpm.conf

$ cp /usr/local/php-7.2.4/etc/php-fpm.d/www.conf.default /usr/local/php-7.2.4/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

启动php-fpm

$ /etc/init.d/php-fpm start

猜你喜欢

转载自tzhennan.iteye.com/blog/2418693