php7的安装以及编译中的错误

1、下载地址:http://php.net/downloads.php

2、configure的配置如下:

./configure –prefix=/usr/local/php7 -with-config-file-path=/usr/local/php7/etc -with-mcrypt=/usr/local/libmcrypt -with-mysqli=mysqlnd -with-pdo-mysql=mysqlnd -with-gd -with-iconv -with-zlib -enable-xml -enable-bcmath -enable-shmop -enable-sysvsem -enable-inline-optimization -enable-mbregex -enable-fpm -enable-mbstring -enable-ftp -enable-gd-native-ttf -with-openssl -enable-pcntl -enable-sockets -with-xmlrpc -enable-zip -enable-soap -without-pear -with-gettext -enable-session -with-curl -with-jpeg-dir -with-freetype-dir -enable-opcache –with-readline

编译PHP8:

./configure –prefix=/usr/local/php8 –with-config-file-path=/usr/local/php8/etc –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd –with-iconv –with-zlib –enable-xml –enable-bcmath –enable-shmop –enable-sysvsem –enable-mbregex –enable-fpm –enable-mbstring –enable-ftp –with-openssl –enable-pcntl –enable-sockets –enable-soap –without-pear –with-gettext –enable-session –with-curl –enable-opcache –with-readline –enable-cgi
–enable-pdo –with-mhash

1、configure: error: no acceptable C compiler found in $PATH

#安装gcc编译 
yum install -y gcc.x86_64

2、configure: error: xml2-config not found. Please check your libxml2 installation.

#安装libxml2
yum install -y libxml2.x86_64 libxml2-devel.x86_64

3、configure: error: Cannot find OpenSSL’s <evp.h>

#安装openSSL
yum install -y openssl.x86_64 openssl-devel.x86_64

4、error: Please reinstall the libcurl distribution -
     easy.h should be in <curl-dir>/include/curl/

yum install -y libcurl.x86_64 libcurl-devel.x86_64

5、fails try –with-webp-dir=<DIR>
     error: jpeglib.h not found

#安装gd库
yum install -y gd.x86_64 gd-devel.x86_64

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

下载安装:https://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/

tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
 ./configure  --prefix=/usr/local/libmcrypt //目录和php的configure中的保持一致 
//--with-mcrypt=/usr/local/libmcrypt/include
# make
# make install

遇到错误:
error: C++ compiler cannot create executables
解决:yum install -y gcc-c++.x86_64

7、WARNING: unrecognized options: –with-mysql

#php 7不在支持mysql
./configure中移除 --with-mysql 

8、Package requirements (sqlite3 >= 3.7.7) were not met

# yum install sqlite-devel

9、configure: error: Package requirements (oniguruma) were not met:

# yum install -y oniguruma.x86_64  oniguruma-devel.x86_64

8、安装的操作

tar -zxf php-7.0.13.tar.gz
cd php-7.0.13
./configur ---参考上文
make --这个时间比较长
make install

cp  php.ini-production /usr/local/php7/etc/php.ini
cp sapi/fpm/init.d.php-fpm /usr/local/php7/etc/init.d.php-fpm //备用
mv /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
mv /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf

 9、安装mongodb扩展(php7种已废弃mongo的扩展)

#必须先安装git ,使用yum install git.x86_64
参考:http://php.net/manual/zh/mongodb.installation.manual.php
# git clone https://github.com/mongodb/mongo-php-driver.git
# git submodule sync && git submodule update --init
# ./configure --with-php-config=/usr/local/php7/bin/php-config //注意是php-config的完整路径
# make
# make install

安装成功后显示:
Installing shared extensions:     
/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/

查看php的扩展so的默认目录
# /usr/local/php7/bin/php -i | grep extension_dir
显示:extension_dir => /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012 
=> /usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012

两个目录一致,直接在php.ini文件添加:extension=mongodb.so

错误:
configure: error: Cannot find php-config. Please use --with-php-config=PATH
解决:
./configure --with-php-config=/usr/local/php7/bin/php-config //注意是php-config的完整路径

10、configure: error: Please reinstall readline – I cannot find readline.h

解决:
yum install -y readline.x86_64 readline-devel.x86_64

相关文章:

CGI、FastCGI、PHP-CGI、PHP-FPM的联系与区别

CGI、FastCGI和PHP-FPM关系图解[转]

php-fpm的配置详解

php7的安装以及编译中的错误

php7的安装以及编译中的错误》上有2条评论

  1. Pingback引用通告: php-fpm的配置详解 | 精彩每一天

  2. Pingback引用通告: Docker的实践笔记 | 精彩每一天

发表评论

电子邮件地址不会被公开。 必填项已用*标注

您可以使用这些HTML标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>