php7.3 编译安装

技术 置顶 精帖
0 483
peng49
peng49 2021-07-27 10:58:23
 

下载压缩包

  1. wget http://cn2.php.net/distributions/php-7.3.3.tar.gz

解压

tar -xzf php-7.3.3.tar.gz

进入目录

cd php7.3.3

编译php

  1. ./configure --prefix=/usr/local/php7 --with-mysqli --with-pdo-mysql --with-zlib --enable-mbstring --with-openssl --enable-fpm --with-curl --enable-session

安装

sudo make && sudo make install

配置PHP

sudo cp php.ini-development /usr/local/php7/lib/php.ini

设置环境变量

  1. vim /etc/profile
  2. 最后添加
  3. export PATH=$PATH:/usr/local/php7/bin
  4. 加载配置
  5. source /etc/profile
  6. 测试php命令
  7. php -v
  8. PHP 7.3.27 (cli) (built: Jul 27 2021 10:45:53) ( NTS )
  9. Copyright (c) 1997-2018 The PHP Group
  10. Zend Engine v3.3.27, Copyright (c) 1998-2018 Zend Technologies

常见错误

安装时提示

  1. mkdir: cannot create directory '/usr/local/php7': Permission denied
  2. mkdir: cannot create directory '/usr/local/php7/lib': No such file or directory
  3. mkdir: cannot create directory '/usr/local/php7/lib/php': No such file or directory
  4. mkdir: cannot create directory '/usr/local/php7/lib/php/extensions': No such file or directory
  5. mkdir: cannot create directory '/usr/local/php7/lib/php/extensions/no-debug-non-zts-20180731': No such file or directory
  6. make: *** [install-modules] Error 1

没有权限创建对应的目录导致的,执行时添加 sudo 即可

sudo make && sudo make install

回帖
登录
忘记密码?