linux debian10 编译安装 php5.6
–安装依赖
apt install libxml2 libxml2-dev
–编译安装
1)解决报错
configure: error: Please reinstall the libcurl distribution -
easy.h should be in
下载
https://curl.se/download/curl-7.29.0.tar.gz
安装
tar -xzvf curl-7.29.0.tar.gz
cd curl-7.29.0
./configure --prefix=/home/public/tool/curl
make
make install
2)解决报错
configure: error: freetype-config not found.
libfreetype6 版本为 2.9.1-3,版本过新会导致 freetype-config 无法正常使用,可以选择自行编译低版本的 freetype 2.8.1
下载
http://download.savannah.gnu.org/releases/freetype/freetype-2.8.1.tar.gz
安装
tar -xzvf freetype-2.8.1.tar.gz
cd freetype-2.8.1
./configure --prefix=/home/public/tool/freetype
make
make install
3)解决报错
make: *** [Makefile:630: ext/openssl/openssl.lo] Error 1
下载
https://www.openssl.org/source/old/1.0.2/openssl-1.0.2q.tar.gz
安装
tar -xzvf openssl-1.0.2q.tar.gz
cd openssl-1.0.2q
./config --prefix=/home/public/tool/openssl
make
make install
4)安装php
下载
https://www.php.net/distributions/php-5.6.40.tar.gz
安装
tar -xzvf php-5.6.40.tar.gz
cd php-5.6.40
./configure --prefix=/home/public/php/5.6 --with-config-file-path=/home/public/php/5.6 --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-freetype-dir=/home/public/tool/freetype --with-jpeg-dir --with-png-dir --with-zlib --with-zlib-dir --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-sysvshm --enable-inline-optimization --with-curl=/home/public/tool/curl --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl=/home/public/tool/openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --enable-opcache --enable-ftp --enable-calendar --with-xsl --with-gettext --enable-session --enable-ctype --with-kerberos --with-pcre-regex --enable-exif --with-bz2
make
make install
–复制php.ini
cp php.ini-production /home/public/php/5.6/php.ini
vi /home/public/php/5.6/php.ini
;date.timezone =
修改为
date.timezone = PRC
–复制和修改php-fpm.conf
cd /home/public/php/5.6/etc
cp php-fpm.conf.default php-fpm.conf
vi php-fpm.conf
//去掉 pid = run/php-fpm.pid 前面的分号
//并在 listen = 127.0.0.1:9000 后面添加
listen.allowed_clients = 127.0.0.1
//;security.limit_extensions = .php .php3 .php4 .php5 后面添加
security.limit_extensions = .php .php3 .php4 .php5 .html .js .css .jpg .jpeg .gif .png .htm
–添加nobody组(不添加启动会报错)
groupadd nobody
–启动
cd /home/public/php/5.6/sbin
./php-fpm
–给public用户添加sudo权限
visudo
public ALL=(ALL:ALL) NOPASSWD:/home/public/php/5.6/sbin/php-fpm
–nginx配置
location ~ \.php$ {
root /home/public/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
–测试
cd /home/public/www
vi 1.php
<DOCTYPE html>
<html>
<body>
<?php
echo "hello php";
?>
</body>
</html>
转载请注明作者和出处,并添加本页链接。
原文链接:
//jiaoqiang.top/post/59