php版本到7.1.5,解决Please reinstall the libcurl distribution easy.h
错误
安装依赖
在linux下编译安装软件,./configure
步骤会提示你缺少什么依赖组件,根据系统环境不同,缺少的依赖也不尽相同,举例来说,安装php依赖xpm组件
搜索xpm组件
#ubuntu下
apt search xpm
#centos下 yum search xpm
安装xpm
根据结果我们需要安装libxpm-dev
(ubuntu下是这个包名,大家灵活啊!看软件包描述!)
apt install libxpm-dev
以下默认示例系统环境:ubuntu16.04 server
安装php
下载要按照的php版本,并解压
wget -c http://hk2.php.net/distributions/php-7.1.5.tar.bz2
tar -jxvf php-7.1.5.tar.bz2
安装依赖
apt install libwebp-dev libjpeg-dev libpng-dev libxpm-dev libmcrypt-dev libcurl4-nss-dev libxslt1-dev libssl-dev libfreetype6-dev
配置安装选项
配置选项前可以通过./configure --help
详细查看有哪些可配置选项!推荐配置如下:
./configure --prefix=/opt/php/7.1.5 --with-config-file-path=/opt/php/7.1.5/etc --with-mysqli --enable-fpm --with-fpm-user=www-data --with-fpm-group=www-data --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-pcntl --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-opcache --with-xsl
常见错误解决
1、没有libssl-dev configure: error: Cannot find OpenSSL's 和configure: error: Cannot find OpenSSL's
安装openssl dev开发库软件包
apt install libssl-dev
2、找不到libcurl easy.h文件 Please reinstall the libcurl distribution easy.h
请确认安装libcurl4-nss-dev软件包(非ubuntu系统请自行搜索软件包名)。
apt install libcurl4-nss-dev
搜索easy.h所在位置
find /usr -name easy.h
结果:
/usr/include/x86_64-linux-gnu/curl/easy.h
软连接到/url/include
ln -s /usr/include/x86_64-linux-gnu/curl /usr/include/curl
3、找不到freetype-config configure: error: freetype-config not found.
安装freetype库
apt install libfreetype6-dev
编译安装
make
make install
配置PHP环境
新建php.ini文件
默认安装情况下是php.ini文件是没有被创建的,如果您按上述./configure
配置安装,该文件在/opt/php/7.0.17/etc
目录,否则默认情况下~/lib
目录。
在php源码目录中,有以下两个文件
- php.ini-development 默认推荐开发环境中的配置
- php.ini-production 默认推荐生产环境中的配置
复制您需要的配置到--with-config-file-path
指定的配置目录
编辑php-fpm.conf文件
vi /opt/php/7.1.5/etc/php-fpm.conf
内容如下:
[global]
pid = /opt/php/7.1.5/var/run/php-fpm.pid
error_log = /home/www-data/logs/php-fpm/php-fpm.log
log_level = notice
[www]
listen = /tmp/php-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www-data
listen.group = www-data
listen.mode = 0666
user = www-data
group = www-data
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 6
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = /home/www-data/logs/php-fpm/slow.log
将php命令加入系统脚本目录
vi /etc/environment
把/opt/php/7.1.5/bin
和/opt/php/7.1.5/sbin
加入PATH
,并用英文冒号隔开,范文如下:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/php/7.1.5/bin:/opt/php/7.1.5/sbin"
刷新PATH变量
source /etc/environment
php进程管理和常用命令
开启php-fpm
php-fpm
管理php-fpm
killall php-fpm
php-cli命令
php [...]