php源码安装phpini,源码编译安装PHP

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值