PHP   发布时间:2022-04-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ubuntu下编译安装 PHP 7.3的过程步骤大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

下载PHP代码
首先需要从PHP官网下载PHP7.3.1的源代码,保存为PHP-7.3.1.tar.xz。http://cn2.php.net/distributions/php-7.3.1.tar.xz
在上述文件保存的目录中打开终端,使用命令将其解压,并使用cd进入解压后的目录
tar -xvJf ./PHP-7.3.1.tar.xz
cd PHP-7.3.1

1.安装依赖
其次,需要安装一些编译PHP所需要的依赖
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
在编译前,需要对PHP进行配置,以供其生成对应的makefile文件
./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@H_27_1@make@H_27_1@make install

4.验证PHP
可以使用如下指令来输出PHP的版本,来验证是否正确安装
/usr/local/PHP/bin/PHP -v
如果正确安装,将会出现如下内容
PHP 7.3.1 (cli) (built: Jan 18 2019 20:11:04) ( ZTS )
Copyright (C) 1997-2018 The PHP Group
Zend ENGIne v3.3.1, Copyright (C) 1998-2018 Zend Technologies
到这一步为止,PHP7.3.1便成功从源代码编译安装了。

5.复制PHP.ini
编译安装后的目录并不会有现成的PHP.ini,需要手动复制过去。
在解压出来的源代码目录中,有供开发环境使用的PHP.ini-development和供生产环境使用的PHP.ini-production。

cp PHP.ini-development /usr/local/PHP/etc/PHP.ini
cp /usr/local/PHP5/etc/PHP-fpm.conf.default /usr/local/PHP5/etc/PHP-fpm.conf
cp sapi/fpm/init.d.PHP-fpm /etc/init.d/PHP-fpm
/usr/local/PHP5/sbin/PHP-fpm
启动PHP报错
cp /usr/local/PHP/etc/PHP-fpm.conf.default /usr/local/PHP/etc/PHP-fpm.conf
#/usr/local/PHP/sbin/PHP-fpm
[29-Nov-2019 13:04:49] ERROR: [pool www] cAnnot get uid for user 'www'
[29-Nov-2019 13:04:49] ERROR: FPM initialization Failed

创建www用户

直接创建Nginx用户用户

useradd Nginx
groupadd Nginx
usermod -G Nginx Nginx

/usr/local/PHP5/sbin/PHP-fpm

大佬总结

以上是大佬教程为你收集整理的ubuntu下编译安装 PHP 7.3的过程步骤全部内容,希望文章能够帮你解决ubuntu下编译安装 PHP 7.3的过程步骤所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: