美文网首页
源码编译安装PHP

源码编译安装PHP

作者: LatitudeMaster | 来源:发表于2019-09-26 00:09 被阅读0次

1、安装依赖

sudo apt update
sudo apt install gcc
sudo apt install make
sudo apt install openssl
sudo apt install curl
sudo apt install libbz2-dev
sudo apt install libxml2-dev
sudo apt install libjpeg-dev
sudo apt install libpng-dev
sudo apt install libfreetype6-dev
sudo apt install libzip-dev

2、下载PHP源码,生成configure

git clone https://github.com/php/php-src.git 
# 或者git clone http://git.php.net/repository/php-src.git 
cd php-src 
./buildconf
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysqli --with-pdo-mysql --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-ftp --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo --enable-maintainer-zts

配置成功后会出现如下字样
+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+

Thank you for using PHP.

3、编译安装PHP

make -j4
# 测试php源码
make TEST_PHP_ARGS=-j4 test
make test
# 安装php
make install

4、验证PHP

usr/local/php/bin/php -v
# 编译安装后的目录并不会有现成的php.ini,需要从源码目录手动复制过去。
sudo cp php.ini-development /usr/local/php/etc/php.ini

5、安装PHP扩展库

方法一:
#从PECL官网下载需要的扩展:https://pecl.php.net/package-stats.php
#1、使用pecl安装扩展(redis为例)
[root@localhost]# wget http://pecl.php.net/get/redis-4.0.0.tgz
[root@localhost]# tar -xzvf redis-4.0.0.tgz && cd redis-4.0.0
#2、执行phpize
[root@localhost redis-4.0.0]# phpize
#3、./configure
[root@localhost redis-4.0.0]#  ./configure --with-php-config=/usr/bin/php-config
#4、 make && make install
#5、配置php.ini
# 通过运行 php --ini查找php.ini文件位置,然后在文件中添加extension=memcached.so

方法二:
#1、使用pecl安装扩展(memcached为例)
~# pecl install memcached
#2、配置php.ini
# 通过运行 php --ini查找php.ini文件位置,然后在文件中添加extension=memcached.so

相关文章

  • php 手动编译添加扩展

    在完成 php的编译安装后, 发现没有编译某此模块。手动添加安装。php源码编译安装 编译安装 在php源码包中 ...

  • php7.3.5配置swoole4

    一、PHP7源码安装和Swoole源码编译安装 1.1 PHP7源码安装 1.1.1 获取源码与安装 获取PHP7...

  • PHP 开发环境,源代码安装 LNMP

    源码编译安装 LNMP 环境 LNMP(Linux, Nginx, Mysql, PHP) 源码编译安装,需要用到...

  • CentOS7.4 编译安装 php7

    阿里云 CentOS7.4 编译安装 PHP7.1.11 下载并解压源码包 安装编译php所需的依赖包 进去源码目...

  • PHP7 编译安装

    基准测试 - 可以对比所需版本性能 安装解压器 下载php7源码 解压php7源码 安装编译软件(必须) 安装编译...

  • CentOs 同时使用多个php版本

    多个版本php要共存,必须使用不同的安装路径,这里使用源码编译安装**php编译参数详解:http://blog....

  • linux 安装php7.3

    请先安装依赖包 下载php-7.3.4 解压 配置 编译安装 在之前编译的源码包中,找到 php.ini-prod...

  • CentOS 7 安装nginx+php+mysql环境

    安装php 首先得安装第三方软件库 安装依赖包 下载php源码 下载php-5.6.30.tar.gz 编译&安装...

  • PHP安装

    服务器使用nginx时,需要使用php-fpm。所以PHP安装需要通过编译源码来安装。 下载源码包 配置 make

  • PHP 编译安装+apache开启php

    PHP安装提示 直接 yum install php-cli 安装的是5.x版本,建议直接下载源码编译安装 安装:...

网友评论

      本文标题:源码编译安装PHP

      本文链接:https://www.haomeiwen.com/subject/rbxguctx.html