linux debian10 编译安装 php5.6

/

–安装依赖
apt install libxml2 libxml2-dev

–编译安装
1)解决报错
configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/

下载
https://curl.se/download/curl-7.29.0.tar.gz

安装

  1. tar -xzvf curl-7.29.0.tar.gz
  2. cd curl-7.29.0
  3. ./configure --prefix=/home/public/tool/curl
  4. make
  5. 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

安装

  1. tar -xzvf freetype-2.8.1.tar.gz
  2. cd freetype-2.8.1
  3. ./configure --prefix=/home/public/tool/freetype
  4. make
  5. 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

安装

  1. tar -xzvf openssl-1.0.2q.tar.gz
  2. cd openssl-1.0.2q
  3. ./config --prefix=/home/public/tool/openssl
  4. make
  5. make install

4)安装php
下载
https://www.php.net/distributions/php-5.6.40.tar.gz

安装

  1. tar -xzvf php-5.6.40.tar.gz
  2. cd php-5.6.40
  3. ./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
  4. make
  5. 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

  1. public ALL=(ALL:ALL) NOPASSWD:/home/public/php/5.6/sbin/php-fpm

–nginx配置

  1. location ~ \.php$ {
  2. root /home/public/www;
  3. fastcgi_pass 127.0.0.1:9000;
  4. fastcgi_index index.php;
  5. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  6. include fastcgi_params;
  7. }

–测试
cd /home/public/www

vi 1.php

  1. <DOCTYPE html>
  2. <html>
  3. <body>
  4. <?php
  5. echo "hello php";
  6. ?>
  7. </body>
  8. </html>

访问
http://192.168.xxx.xxx/1.php

转载请注明作者和出处,并添加本页链接。
原文链接: //jiaoqiang.top/post/59