php编译的常见报错和制作php.tar.gz解压可直接用的包

首先下载一个php源码包

 wget  https://www.php.net/distributions/php-7.4.13.tar.gz

安装依赖

yum -y install gcc gcc-c++     libxml2-devel openssl-devel   sqlite-devel libcurl libcurl-devel gmp-devel oniguruma-devel gdbm-devel net-snmp-devel

创建一个要安装到的目录

 mkdir /srv/php

进入编译

[root@localhost ~]# tar xf php-7.4.13.tar.gz
[root@localhost ~]# cd php-7.4.13/

开始编译指定路径

[root@localhost php-7.4.13]# ./configure --prefix=/srv/php  --with-config-file-path=/srv/php/etc  --with-mysql=mysqlnd  --enable-mysqlnd  --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd  --with-openssl  --with-snmp --with-zlib --with-curl       --with-pear --with-gettext --with-gmp  --enable-inline-optimization --enable-soap --enable-ftp  --enable-sockets --enable-mbstring --enable-fpm  --with-fpm-user=nginx --with-fpm-group=nginx --with-mhash

常见的一些编译报错

  1. configure: error: Please reinstall the BZip2 distribution
    解决:yum -y install bzip2 bzip2-devel

  2. configure: error: Package requirements (libcurl >= 7.15.5) were not met:No package ‘libcurl’ found
    解决:yum -y install libcurl libcurl-devel

3.you may set the environment variables SQLITE_CFLAGS and SQLITE_LIBS to avoid the need to call pkg-config.
解决:yum -y install libxslt pkg-devel

4.configure: error: Package requirements (sqlite3 > 3.7.4) were not met:
解决:yum -y install sqlite-devel

5.configure: error: GNU MP Library version 4.2 or greater required.
解决:yum -y install gmp-devel

6.configure: error: Package requirements (oniguruma) were not met: No package ‘oniguruma’ found
解决:yum -y install oniguruma-devel

7.configure: error: Please reinstall readline - I cannot find readline.h
解决:yum -y install readline-devel

8.configure: error: Package requirements (libpcre2-8 >= 10.30) were not met: No package ‘libpcre2-8’ found
解决:https://www.jianshu.com/p/89646111a1ce

9.configure: error: DBA: Could not find necessary header file(s).
解决:yum -y install gdbm-devel
10.configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:No package ‘libzip’ found
解决:https://www.jianshu.com/p/6cbd25addc29

11 configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.
解决
yum -y install net-snmp-devel
没有报错后编译

make && make install

生成标准配置

cp php.ini-development /srv/php/etc/php.ini
mv /srv/php/etc/php-fpm.conf.default /srv/php/etc/php-fpm.conf

改名配置文件

[root@localhost ~]# cd /srv/php/etc/php-fpm.d/
[root@localhost php-fpm.d]# ls
www.conf.default
[root@localhost php-fpm.d]# mv www.conf.default  www.conf

创建一个nginx用户因为我们安装时规定的用户是nginx

 useradd -s /sbin/nologin nginx

启动即可

 /srv/php/sbin/php-fpm

在这里插入图片描述
然后打包
在这里插入图片描述
上传到一个没安装php的机子上测试

scp php1.tar.gz root@192.168.124.178:/srv

在这里插入图片描述
这台机子没有nginx用户添加一个

useradd -s /sbin/nologin nginx

然后解压启动
在这里插入图片描述
报错是少些依赖插件解决方法

yum -y install epel-release
yum -y install oniguruma

接着报错
在这里插入图片描述
安装

yum -y install net-snmp

完事之后启动即可
在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值