ubuntu下编译安装 PHP 7.3的过程步骤

发布时间:2026-01-09 点击:2
系统运维
下载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
make
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

如何知道域名注册商好坏?有什么技巧?
云虚拟主机能挂软件吗
为什么cpu温度老是很高 cpu温度过高是什么原因
国内视频云市场前景广阔,腾讯云市场份额稳居第一梯队
site域名首页为啥不在第一页
公司网站云服务器有什么用
云服务器怎么挂机
centos7如何安装配置phpfpm