CentOS7安装PHP开发环境2-源码安装PHP

OS:CentOS 7
PHP:7.1.6、7.2.1

文章目录

  • 编译
    • (php 7.1.8)
    • (php 7.2.1)
  • (php 7.3.0)
    • 复制php.ini
    • 设置上传文件大小、时区
    • 命令行配置文件:
    • php-fpm慢日志
    • PHP进程号和错误日志
    • PHP进程的属主属组和监听端口
    • php加入到环境变量中:
    • 复制php-fpm配置文件
    • 启动fpm
    • 设置php-fpm.pid的文件路径
    • 设置php-fpm.log的文件路径
    • 平滑重启php-fpm
  • 安装PHP扩展
    • 在线安装扩展
    • 编译安装
      • 安装php-redis扩展
      • 安装memcache扩展
      • 安装mcrypt扩展
      • 安装imagick扩展
  • ./configure --with-php-config=/application/php/bin/php-config
      • 安装mcrypt扩展
      • 安装opcache扩展
      • 安装pgsql扩展
      • Xdebug扩展
      • 安装apcu扩展
      • 安装pdo_odbc扩展
      • 安装sodium扩展
      • 其他编译错误
  • 使用Redis存储session

新建用户www

[root@sy-pc ~]# useradd www -s /sbin/nologin -M

编译

(–enable-maintainer-zts 线程安全模式)
(较少的配置)注意:--enable-fpm
./configure --prefix=/application/php-7.1.6 --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-phpdbg --with-openssl --enable-zip --enable-mysqlnd --with-mysqli

(较多的配置-线程安全模式)注意:--enable-fpm --enable-maintainer-zts --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local
./configure --prefix=/application/php-7.1.6 --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-maintainer-zts --enable-phpdbg --enable-phpdbg-debug --enable-debug --enable-sigchild --enable-libgcc --enable-dtrace --enable-calendar --enable-dba --enable-exif --enable-ftp --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --enable-intl --enable-mbstring --enable-mysqlnd --with-mysqli --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-openssl --enable-zip --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local

(较多的配置-线程不安全模式)
./configure --prefix=/application/php-7.1.6 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-fpm-acl --with-litespeed --enable-phpdbg --enable-phpdbg-webhelper --enable-phpdbg-debug --enable-gcov --with-tsrm-st --with-tsrm-pthreads --enable-mod-charset --enable-roxen-zts --enable-sigchild --enable-libgcc --enable-calendar --enable-dba --enable-exif --enable-ftp --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --enable-intl --enable-mbstring --enable-mysqli --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-wddx --with-openssl --enable-zip --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local

(无opcache debug)
注意:--enable-fpm --enable-maintainer-zts
./configure --prefix=/application/php-7.1.6 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-fpm-systemd --with-fpm-acl --with-litespeed --enable-phpdbg --enable-phpdbg-webhelper --enable-phpdbg-debug --enable-gcov --enable-maintainer-zts --with-tsrm-st --with-tsrm-pthreads --enable-mod-charset --enable-roxen-zts --enable-sigchild --enable-libgcc --enable-dtrace --enable-calendar --enable-dba --enable-exif --enable-ftp --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --enable-intl --enable-mbstring --enable-mysqli --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-openssl --enable-zip --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local

(很多库已经安装过了。)
./configure --prefix=/application/php-7 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-fpm-systemd --with-fpm-acl --with-curl --with-iconv --with-mcrypt --with-mhash --enable-bcmath --with-litespeed --enable-phpdbg --enable-phpdbg-webhelper --enable-phpdbg-debug --enable-roxen-zts --enable-maintainer-zts --enable-debug --enable-mod-charset --enable-sigchild --enable-libgcc --enable-dtrace --enable-calendar --enable-dba --enable-exif --enable-ftp --with-gd --enable-gd-native-ttf --enable-gd-jis-conv --enable-intl --enable-mbstring --enable-mysqlnd --with-mysqli --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-openssl --enable-zip --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local && make && make install

(php 7.1.8)

注意:--enable-fpm --with-fpm-acl --enable-maintainer-zts --disable-inline-optimization --disable-zend-signals --with-gnu-ld
./configure --prefix=/application/php-7.1.8 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-fpm-systemd --with-fpm-acl --with-litespeed --enable-phpdbg --enable-phpdbg-webhelper --enable-phpdbg-debug --enable-gcov --enable-debug --enable-sigchild --enable-libgcc --enable-dmalloc --enable-dtrace --enable-fd-setsize --with-system-ciphers --with-pcre-jit --enable-bcmath --enable-calendar --enable-dba --enable-exif --with-pcre-dir --enable-ftp --enable-gd-native-ttf --enable-gd-jis-conv --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local --enable-intl --enable-mbstring --enable-embedded-mysqli --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --enable-zip --enable-mysqlnd --enable-maintainer-zts --disable-inline-optimization --disable-zend-signals --with-tsrm-st --with-tsrm-pthreads --with-gnu-ld --with-pic

(php 7.2.1)

注意:--enable-maintainer-zts --with-tsrm-pthreads

./configure --prefix=/application/php-7.2.1 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-fpm-acl --with-curl --with-iconv --with-bz2 --with-mhash --enable-bcmath --with-litespeed --enable-phpdbg --enable-phpdbg-webhelper --enable-phpdbg-debug --enable-maintainer-zts --with-tsrm-pthreads --enable-debug --enable-sigchild --enable-libgcc --enable-dtrace --enable-calendar --enable-dba --enable-exif --enable-ftp --with-gd --enable-gd-jis-conv --enable-intl --enable-mbstring --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-openssl --enable-zip --with-zlib --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local

编译时的错误解决方案:https://blog.csdn.net/u011608531/article/details/50756112

# make && make install

安装报错:
Wrote PEAR system config file at: /application/php-7.2.1/etc/pear.conf
You may want to add: /application/php-7.2.1/lib/php to your php.ini include_path
/wwwroot/package/php-7.2.1/build/shtool install -c ext/phar/phar.phar /home/sy/local/php7.2.1/bin
cp -pR -f phar.phar /application/php-7.2.1/bin/phar
cp: cannot stat ‘phar.phar’: No such file or directory
make: *** [install-pharcmd] Error 1

(php 7.3.0)

Libzip 版本过低或提示reinstall解决方法 http://www.kwx.gd/PHPEnvironment/CetnOS-libzip.html
centos安装Libzip https://blog.csdn.net/oxiaobaio/article/details/80854054

./configure --prefix=/application/php-7.3.0 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-fpm-acl --with-curl --with-iconv --with-bz2 --with-mhash --enable-bcmath --with-litespeed --enable-phpdbg --enable-phpdbg-webhelper --enable-phpdbg-debug --enable-maintainer-zts --with-tsrm-pthreads --enable-debug --enable-sigchild --enable-libgcc --enable-dtrace --enable-calendar --enable-dba --enable-exif --enable-ftp --with-gd --enable-gd-jis-conv --enable-intl --enable-mbstring --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-openssl --enable-zip --with-zlib --with-zlib-dir=/usr/local --with-libzip=/usr/local --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local

报错:
Protected multilib versions
解决方案:
https://blog.csdn.net/shouldnotappearcalm/article/details/64212868?utm_source=blogxgwz3
yum install -y zlib zlib-devel --setopt=protected_multilib=false

安装后创建软连接

# ln -s /application/php-具体版本号 /application/php

设置目录所属用户、所属用户组

# chown www:www -R /application/php/

注意:上一句的/application/php是软连接,若不加\,则改变软连接文件的所属用户(组);若加上\,则改变真实文件的所属用户(组)。-R表示作用到目录文件及全部子文件。

复制php.ini

安装完PHP后,可以在命令行中输入# php -i | grep ini
查看php.ini应当存放的路径,然后将源代码安装包中的php.ini-development文件拷贝一份,如下:

[root@sy-pc lib]# php -i | grep ini 
Configuration File (php.ini) Path => /application/php-7.2.1/lib
Loaded Configuration File => /application/php-7.2.1/lib/php.ini

那么我应该将拷贝的文件放入到/application/php-7.2.1/lib/php.ini。
cp /home/sy/Downloads/php-7.2.1/php.ini-development /application/php-7.2.1/lib/php.ini
开发环境,拷贝php.ini-development文件;
生产环境,考本php.ini-production文件。

有关错误的配置:

  • error_log 错误日志的生成目录(~/etc/php-fpm.conf)
  • error_reporting 生产环境错误级别应全开(~/lib/php.ini)
  • display_errors 在页面上不显示错误(~/lib/php.ini)
  • log_errors 开启错误日志(~/lib/php.ini)

设置上传文件大小、时区

# vim /application/php/lib/php.ini

post_max_size = 20M
upload_max_filesize = 20M
date.timezone = Asia/Shanghai

命令行配置文件:

# cp php.ini php-cli.ini
若没有独立的命令行配置文件,则命令行加载php.ini文件中的配置。

php-fpm慢日志

vim PHP安装目录/etc/php-fpm.d/www.conf

; The log file for slow requests
; Default Value: not set
; Note: slowlog is mandatory if request_slowlog_timeout is set
;slowlog = log/$pool.log.slow

; The timeout for serving a single request after which a PHP backtrace will be
; dumped to the 'slowlog' file. A value of '0s' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_slowlog_timeout = 0

; Depth of slow log stack trace.
; Default Value: 20
;request_slowlog_trace_depth = 20

; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
;request_terminate_timeout = 0
  • slowlog 设置慢查询日志的生成目录
  • request_slowlog_timeout 设置慢查询的标准时间(打开此配置就相当于开启了慢查询日志),配置以秒为单位,一般设置3s。

PHP进程号和错误日志

  配置进程文件、错误日志
# vim /application/php/etc/php-fpm.conf

pid = run/php-fpm.pid
error_log=/wwwroot/logs/php_error_log/php7.2.1/php-fpm.log

PHP进程的属主属组和监听端口

# vim /application/php/etc/php-fpm.d/www.conf

user = www
group = www
listen = 127.0.0.1:9000

php加入到环境变量中:

# vim /etc/profile

#手工加入
PATH=/application/php/bin:$PATH

保存退出后,
重新引入
# source /etc/profile

复制php-fpm配置文件

cp /application/php/etc/php-fpm.conf.default /application/php/etc/php-fpm.conf
(因为php-fpm.conf文件的最后一句include=/application/php-7.2.1/etc/php-fpm.d/*.conf ,所以要执行下一句)
cp /application/php/etc/php-fpm.d/www.conf.default /application/php/etc/php-fpm.d/www.conf

编辑www.conf文件,如果注释了下面两行user 和 group,那么以root身份启动/application/php/sbin/php-fpm会导致失败。
在这里插入图片描述

启动fpm

/application/php/sbin/php-fpm

/application/php/bin/php-cgi -b 127.0.0.1:9000 -c /application/php/etc/php.ini

/application/php/sbin/php-fpm -c /application/php/lib/php.ini -y /application/php/etc/php-fpm.conf

测试php-fpm配置
/application/php/sbin/php-fpm -t

/application/php/sbin/php-fpm -c /application/php/lib/php.ini -y /application/php/etc/php-fpm.conf -t

根据端口号查看进程:
# lsof -i :9000
杀死进程
kill -o 进程ID
killall php-fpm #杀死php-fpm进程

kill `lsof -i:9000|grep php|head -1|awk '{print $2}'`
kill `netstat -lntup | grep php | grep -v grep | awk '{print $7}' | awk -F / '{print $1}'`
kill `ps -ef | grep php | grep -v grep | head -1 | awk '{print $2}'`

设置php-fpm.pid的文件路径

vim /application/php/etc/php-fpm.conf
;pid = run/php-fpm.pid
改成 pid = run/php-fpm.pid
则php-fpm.pid文件在php的安装目录的下的var/run/目录下,
此次安装后的目录是/application/php/var/run/php-fpm。

设置php-fpm.log的文件路径

vim /application/php/etc/php-fpm.conf
;error_log = log/php-fpm.log
改成 error_log=/wwwroot/logs/php_error_log/php版本号/php-fpm.log

平滑重启php-fpm

kill -USR2 `cat /application/php/var/run/php-fpm.pid`

参考:http://blog.csdn.net/u010098331/article/details/50737322

++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++

安装PHP扩展

在线安装扩展

命令如:
/application/php/bin/pecl install pthreads

编译安装

gd库
# yum install freetype* libwebp* libjpeg* libpng* libXpm*
但是phpinfo()的结果是
Linux版默认:
CentOS7安装PHP开发环境2-源码安装PHP_第1张图片

Windows版完整如下:
CentOS7安装PHP开发环境2-源码安装PHP_第2张图片

freetype
https://www.freetype.org/
++++++++++++++++++++++++++++++++++++++++++
https://fossies.org/linux/misc/jpegsrc.v9b.tar.gz
jpegsrc.v9b.tab.gz

# tar -zxvf jpegsrc.v9b.tab.gz
# cd jpeg-9b
# ./configure --prefix=/home/sy/local/jpegsrc
# make && make install

# yum install freetype* libwebp* libjpeg* libpng* libXpm*
进入php源码目录的gd扩展目录

# /application/php/bin/phpize
# ./configure --with-php-config=/application/php/bin/php-config  --with-webp-dir=/usr/local --with-jpeg-dir=/url/local --with-png-dir=/usr/local --with-xpm-dir=/usr/local --with-freetype-dir=/usr/local    
# make && make install  

如果以前编译过,建议 make clean && make && make install
php.ini文件增加一句话extension=gd
++++++++++++++++++++++++++++++++++++++++++

安装php-redis扩展

下载解压 https://github.com/nicolasff/phpredis/archive/2.2.4.tar.gz
下载地址 http://pecl.php.net/package/redis
但是因为本机安装了php7,所以必须要下载php7redis包
https://github.com/phpredis/phpredis/archive/php7.zip

# cd /home/sy/Downloads
# wget https://github.com/phpredis/phpredis/archive/php7.zip
# unzip phpredis-php7.zip
# cd phpredis-php

编译安装:先用phpize编译生成configure等文件

[root@sy-pc phpredis-2.2.4]# /application/php/bin/phpize  
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
[root@sy-pc phpredis-php7]# ./configure --with-php-config=/application/php/bin/php-config  
# make  
[root@sy-pc phpredis-php7]# make install  
make && make install  
Installing shared extensions:     /application/php-7.2.1/lib/php/extensions/debug-zts-20170718/

根据php.ini实际所在的路径,修改php.ini文件,加一句话:

extension=redis

安装memcache扩展

安装libmemcached
下载地址:https://launchpad.net/libmemcached/+download
如libmemcached-1.0.18.tar.gz

# tar -zxvf libmemcached-1.0.18.tar.gz
# cd libmemcached-1.0.18
# ./configure --prefix=/home/sy/local/libmemcached1.0.18
# make && make install

下载memcached扩展包并安装
https://github.com/php-memcached-dev/php-memcached
如php-memcached-master.zip

# unzip php-memcached-master.zip
# cd php-memcached-master
# /application/php/bin/phpize
# ./configure -with-php-config=/application/php/bin/php-config -with-libmemcached-dir=/home/sy/local/libmemcached1.0.18 -enable-memcached --disable-memcached-sasl  

注意:

  1. 如果是yum安装libmemcached,则-with-libmemcached-dir=/usr
  2. 如果没有–disable-memcached-sasl ,则会出现
checking sasl/sasl.h usability... no
checking sasl/sasl.h presence... no
checking for sasl/sasl.h... no
configure: error: no, sasl.h is not available. Run configure with --disable-memcached-sasl to disable this check

安装

# make && make install
Installing shared extensions:     /application/php-7.2.1/lib/php/extensions/debug-zts-20170718/

修改php.ini文件,添加一句,或者用完整的一句。建议用下面的第一句。

extension=memcached.so
extension=/application/php-7.2.1/lib/php/extensions/debug-zts-20170718/memcached.so

安装memcache扩展
下载memcache源代码 http://pecl.php.net/package/memcache (太老的版本,不适合php7)
如memcache-3.0.8.tgz

# tar -zxvf memcache-3.0.8
# cd memcache-3.0.8
# /application/php/bin/phpize
# ./configure -with-php-config=/application/php/bin/php-config 
# make 

提示错误

In file included from /home/sy/Downloads/memcache-3.0.8/php_memcache.h:34:0,
                 from /home/sy/Downloads/memcache-3.0.8/memcache.c:30:
/home/sy/Downloads/memcache-3.0.8/memcache_pool.h:45:47: fatal error: ext/standard/php_smart_str_public.h: No such file or directory
 #include "ext/standard/php_smart_str_public.h"
                                               ^
compilation terminated.
make: *** [memcache.lo] Error 1

参看网站http://www.lnmp.cn/install-memcache-and-memcached-extends-under-php7.html
下载https://github.com/websupport-sk/pecl-memcache
如pecl-memcache-NON_BLOCKING_IO_php7.zip

# unzip pecl-memcache-NON_BLOCKING_IO_php7.zip
# cd pecl-memcache-NON_BLOCKING_IO_php7
# /application/php/bin/phpize  
# ./configure -with-php-config=/application/php/bin/php-config  
# make && make install
extension=memcached

++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++++++++++++
为了使用cURL函数,安装libcurl库,造成的混淆

# yum install libcurl* -y
# whereis libcurl
libcurl: /usr/lib64/libcurl.so /usr/share/man/man3/libcurl.3.gz

在php.ini中添加extension=/usr/lib64/libcurl.so,但是启动php-fpm是提示

NOTICE: PHP message: PHP Warning:  PHP Startup: Invalid library (maybe not a PHP library) 'curl.so' in Unknown on line 0

Warning: PHP Startup: Invalid library (maybe not a PHP library) 'curl.so' in Unknown on line 0

后来,进入php7.1.6的源代码安装包

# cd ext
# cd curl
# /application/php-7.1.6/bin/phpize 
# ./configure --with-php-config=/application/php-7.1.6/bin/php-config  
# make && make install
Installing shared extensions:     /application/php-7.1.6/lib/php/extensions/no-debug-non-zts-20160303/

编辑了php.ini文件

extension=curl.so

但是启动php-fpm仍然报错。和上面的一样。
然后修改php.ini文件为
extension=/application/php-7.1.6/lib/php/extensions/no-debug-non-zts-20160303/curl.so
或者
extension_dir=/application/php-7.1.6/lib/php/extensions/no-debug-non-zts-20160303/ extension=curl.so

安装mcrypt扩展

编译后提示

# ./configure --with-php-config=/application/php/bin/php-config  
configure: error: mcrypt.h not found. Please reinstall libmcrypt.

源文件的库太老了,所以没有继续安装
解决方式参考:http://www.zjmainstay.cn/php-mcrypt
http://www.cnblogs.com/huangzhen/archive/2012/09/12/2681861.html

下载libmcrypt https://nchc.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz
下载mhash https://nchc.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz
下载 mcrypt http://pecl.php.net/package/mcrypt 选择吧

或者懒人安装方式:
yum install libmcrypt libmcrypt-devel mcrypt mhash

#tar -zxvf libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure
#make
#make install 说明:libmcript默认安装在/usr/local
#tar -zxvf mhash-0.9.9.9.tar.gz
#cd mhash-0.9.9.9
#./configure
#make
#make install
# tar -zxvf mcrypt-1.0.1.tgz
# cd mcrypt-1.0.1
# /application/php/bin/phpize  
# ./configure -with-php-config=/application/php/bin/php-config  
# make && make install
extension=mcrytp
zend_extension=xdebug

安装imagick扩展

#yum install ImageMagick ImageMagick-c++ ImageMagick-c++-devel ImageMagick-devel ImageMagick-doc ImageMagick-perl
下载imagick扩展:http://pecl.php.net/package/imagick 如imagick-3.4.3.tgz

# tar -zxvf imagick-3.4.3.tgz
# cd imagick-3.4.3/
# /application/php/bin/phpize  
# ./configure
# make && make install

php.ini文件增加一句话extension=imagick.so

++++++++++++++++++++++++++++++++++++++++++
如安装zlib扩展的时候出现Cannot find config.m4. Make sure that you run ‘/home/sy/local/php7.1.6/bin/phpize’ in the top level source directory of the module的解决方法 :
进入php源码包目录:cd /home/sy/local/php7.1.6/ext/zlib
执行命令: cp ./config0.m4 ./config.m4 即可

++++++++++++++++++++++++++++++++++++++++++
PHP 7.3.0安装zlib扩展失败:
错误:checking for libzip… configure: error: system libzip must be upgraded to version >= 0.11
方案:https://www.uedbox.com/centos7-ziparchive-libzip/

错误:configure.ac:3: error: Autoconf version 2.68 or higher is required
方案:https://blog.csdn.net/yongcto/article/details/24791885

++++++++++++++++++++++++++++++++++++++++++
安装enchant扩展的错误与解决
./configure编译后提示
configure: error: Cannot find enchant
执行命令: yum -y install enchant-devel

++++++++++++++++++++++++++++++++++++++++++
安装gmp扩展
./configure编译后提示
configure: error: Unable to locate gmp.h
执行:
yum -y install gmp*
yum -y install gmp-devel

++++++++++++++++++++++++++++++++++++++++++
安装imap扩展–然并卵
checking for IMAP support… yes, shared
checking for IMAP Kerberos support… no
checking for IMAP SSL support… no
checking for utf8_mime2text signature… new
checking for U8T_DECOMPOSE…
configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.
执行:# yum install libc* --skip-broken

++++++++++++++++++++++++++++++++++++++++++
安装interbase扩展:失败
编译后提示
configure: error: libfbclient, libgds or libib_util not found! Check config.log for more information.
执行;
yum install libf*

++++++++++++++++++++++++++++++++++++++++++
安装ldap扩展:
编译后提示

./configure --with-php-config=/application/php/bin/php-config

configure: error: Cannot find ldap.h
执行:# yum -y install openldap-devel
编译后提示

# ./configure --with-php-config=/application/php/bin/php-config
configure: error: Cannot find ldap libraries in /usr/lib.

分析原因:
可能原因是安装了64位的系统,在/usr/lib64目录下,而在/usr/lib目录下没有。
解决方式一:强制复制一次:
# cp -frp /usr/lib64/libdap* /usr/lib/
解决方式二:编译时指定libraries所在目录(推荐)
# ./configure --with-php-config=/application/php/bin/php-config --with-libdir=lib64

++++++++++++++++++++++++++++++++++++++++++

安装mcrypt扩展

编译后提示

# ./configure --with-php-config=/application/php/bin/php-config  
configure: error: mcrypt.h not found. Please reinstall libmcrypt.

源文件的库太老了,所以没有继续安装
解决方式参考:http://www.zjmainstay.cn/php-mcrypt
http://www.cnblogs.com/huangzhen/archive/2012/09/12/2681861.html

或者懒人安装方式:
yum install libmcrypt libmcrypt-devel mcrypt mhash

++++++++++++++++++++++++++++++++++++++++++
安装oci8扩展
编译后提示
checking checking if we’re on a 64-bit platform… yes
configure: WARNING: OCI8 extension: ORACLE_HOME is not set, looking for default Oracle Instant Client instead
checking Oracle Instant Client directory… configure: error: Oracle Instant Client directory /usr/lib/oracle/…/client64/lib libraries not found. Try --with-oci8=instantclient,DIR
没有继续安装

++++++++++++++++++++++++++++++++++++++++++
安装odbc扩展
编译后提示
checking for Adabas support… cp: cannot stat ‘/usr/local/lib/odbclib.a’: No such file or directory
configure: error: ODBC header file ‘/usr/local/incl/sqlext.h’ not found!
解决方式:
yum install unixODBC-devel
但是源文件太老,没有继续安装

++++++++++++++++++++++++++++++++++++++++++

安装opcache扩展

cd /home/sy/Downloads/php-7.1.6/ext/opcache
编译
/application/php/bin/phpize
./configure --with-php-config=/application/php/bin/php-config
安装
make && make install
修改php.ini文件
vim /application/php/lib/php.ini
zend_extension=opcache.so

++++++++++++++++++++++++++++++++++++++++++

安装pgsql扩展

提示
checking for pg_config… not found
configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
执行
yum install postgresql-devel

++++++++++++++++++++++++++++++++++++++++++
安装pspell扩展
提示
configure: error: Cannot find pspell
执行:
yum install aspell-devel

++++++++++++++++++++++++++++++++++++++++++
安装recode扩展
提示:
configure: error: Can not find recode.h anywhere under yes /usr/local /usr /opt.
执行
yum install recode-devel

++++++++++++++++++++++++++++++++++++++++++
安装tidy扩展
提示
checking for TIDY support… yes, shared
configure: error: Cannot find libtidy
扩展太老

++++++++++++++++++++++++++++++++++++++++++

Xdebug扩展

Note:
如果需要将 » Xdebug 扩展和 OPcache 一起使用,必须在 Xdebug 扩展之前加载 OPcache 扩展。
下载地址:https://xdebug.org/download.php

# tar -zxvf xdebug-2.5.5.tgz
# cd  xdebug-2.5.5
[root@sy-pc xdebug-2.5.5]# /application/php/bin/phpize
Configuring for:
PHP Api Version:         20160303
Zend Module Api No:      20160303
Zend Extension Api No:   320160303
[root@sy-pc xdebug-2.5.5]# ./configure --with-php-config=/application/php/bin/php-config

然后修改php.ini文件,添加扩展语句

# vim /application/php/lib/php.ini
zend_extension=xdebug.so

安装apcu扩展

安装id3扩展
下载:http://pecl.php.net/package/id3

# tar -zxvf id3-0.2.tgz
# cd id3-0.2
# /application/php/bin/phpize
# ./configure --with-php-config=/application/php/bin/php-config
# make

修改id3.c文件
如196行 function_entry 改为 zend_function
如删除 ENFORCE_SAFE_MODE undeclared 则删除 ENFORCE_SAFE_MODE

# make && make install

编辑php.ini文件

安装pdo_odbc扩展

checking for PDO includes... checking for PDO includes... /home/sy/local/php7.2.1/include/php/ext
checking for selected PDO ODBC flavour... configure: error: Unknown ODBC flavour /usr
			  include and lib dirs are looked for under 'dir'.

			  'flavour' can be one of:  ibm-db2, iODBC, unixODBC, generic
			  If ',dir' part is omitted, default for the flavour
			  you have selected will be used. e.g.:

			    --with-pdo-odbc=unixODBC

			  will check for unixODBC under /usr/local. You may attempt
			  to use an otherwise unsupported driver using the "generic"
			  flavour.  The syntax for generic ODBC support is:

			    --with-pdo-odbc=generic,dir,libname,ldflags,cflags

			  When built as 'shared' the extension filename is always pdo_odbc.so

yum -y install unixODBC-*
进入PHP源文件ext/pdo_odbc目录,
/home/sy/local/php7.1.6/bin/phpize

./configure --with-php-config=/application/php/bin/php-config --with-pdo-odbc=unixODBC,/usr

make && make install

安装sodium扩展

参考:https://blog.csdn.net/hnhuangyiyang/article/details/50421657
wget https://download.libsodium.org/libsodium/releases/libsodium-1.0.16.tar.gz

其他编译错误

如安装 ldap扩展
configure: error: Cannot find ldap libraries in /usr/lib
解决方案:
cp -frp /usr/lib64/libldap* /usr/lib/

使用Redis存储session

编辑php.ini文件。如果为Redis已经添加了auth权限(requirpass),则session.save_path的值需要加GET参数。

session.save_handler = Redis

session.save_path =  "tcp://192.168.55.170:6379?persistent=1&database=10&auth=Redis密码"

你可能感兴趣的:(PHP环境)