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 [...]