1、下载PHP源码包

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

2、解压缩
tar xf php-7.4.30.tar.gz -C /usr/local/src
3、预编译、检查环境

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysqli --with-pdo-mysql --with-mysql-sock=/usr/local/mysql/mysql.sock --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-curl --with-gd --with-gmp --with-zlib --with-xmlrpc --with-openssl --without-pear --with-snmp --with-gettext --with-mhash --with-libxml-dir=/usr --with-ldap --with-ldap-sasl --with-fpm-user=nginx --with-fpm-group=nginx --enable-xml --enable-fpm --enable-ftp --enable-bcmath --enable-soap --enable-shmop --enable-sysvsem --enable-sockets --enable-inline-optimization --enable-maintainer-zts --enable-mbregex --enable-mbstring --enable-pcntl --enable-zip --disable-fileinfo --disable-rpath --enable-libxml --enable-opcache --enable-mysqlnd

出现的错误

configure: error: Package requirements (libxml-2.0 >= 2.7.6) were not met:

解决方法:
yum install libxml2-devel -y

configure: error: Package requirements (openssl >= 1.0.1) were not met:

解决方法:
yum install openssl-devel -y

configure: error: Package requirements (sqlite3 > 3.7.4) were not met:

解决方法:
yum install sqlite-devel -y

configure: error: Package requirements (libcurl >= 7.15.5) were not met:

解决方法:
yum install libcurl-devel -y

configure: error: GNU MP Library version 4.2 or greater required.

解决方法:
yum -y install gmp-devel -y

configure: error: Cannot find ldap.h

解决方法:
yum install openldap openldap-devel -y

configure: error: Cannot find ldap libraries in /usr/lib.

解决方法:
cp -frp /usr/lib64/libldap* /usr/lib/

configure: error: Package requirements (oniguruma) were not met:

解决方法:
yum install oniguruma-devel -y

configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.

解决方法:
yum install net-snmp-devel -y
4、编译并安装
make & make install

出现的错误

cc: fatal error: Killed signal terminated program cc1

compilation terminated.

解决方法:
mkdir -p /var/cache/swap/
dd if=/dev/zero of=/var/cache/swap/swap0 bs=10M count=400
chmod 0600 /var/cache/swap/swap0
mkswap /var/cache/swap/swap0
swapon /var/cache/swap/swap0
swapon -s

/usr/bin/ld: ext/ldap/.libs/ldap.o: undefined reference to symbol 'ber_strdup'

//usr/lib64/liblber-2.4.so.2: error adding symbols: DSO missing from command line

collect2: error: ld returned 1 exit status

make: *** [Makefile:287: sapi/cli/php] Error 1

解决方法:
vim Makefile
#在以EXTRA_LIBS开头的一行结尾添加‘-llber’,如下: EXTRA_LIBS = -lcrypt -lresolv -lcrypt -lrt -lldap -lgmp -lrt -lm -ldl -lpthread -lxml2 -lssl -lcrypto -lsqlite3 -lz -lcurl -lxml2 -lssl -lcrypto -lonig -lsqlite3 -lxml2 -lnetsnmp -lm -lssl -lssl -lcrypto -lxml2 -lcrypt -lxml2 -lxml2 -lxml2 -lxml2 -lz -lssl -lcrypto -lcrypt -llber
5、配置php配置文件
#移动php配置文件的位置,并修改名称
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.conf
#复制php.ini文件
cp /usr/local/src/php-7.4.30/php.ini-production /usr/local/php/etc/php.ini
6、复制php启动脚本到/etc/init.d/
cp /usr/local/src/php-7.4.30/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
systemctl enable php-fpm.service
/usr/lib/systemd/systemd-sysv-install enable php-fpm
systemctl status php-fpm.service

编译安装PHP7.4的更多相关文章

  1. 编译安装PHP7并安装Redis扩展Swoole扩展

    编译安装PHP7并安装Redis扩展Swoole扩展 在编译php7的机器上已经有编译安装过php5.3以上的版本,从而依赖库都有了 本php7是编译成fpm-php 使用的, 如果是apache那么 ...

  2. 【安装PHP】如何在openSUSE42.1下编译安装PHP7

    首先推荐一篇文章PHP 7 Release Date Arrived: Will Developers Adopt PHP 7? - PHP Classes blog. 里面说到是否会去使用PHP7, ...

  3. 全志a20安卓电视盒子安装可道云kodexplorer服务-编译安装php7.3+nginx

    可道云真的很强大,安装包很小,功能却很齐全,还可以自定义轻应用如果有手机客户端就更好了 研究了一下,可道云根目录放到外置存储设备(移动硬盘)会更合适,改路径的方法下面有提到上传文件时一个文件会在用户目 ...

  4. centos7.6编译安装php7.2.11及redis/memcached/rabbitmq/openssl/curl等常见扩展

    centos7.6编译安装php7..11及redis/memcached/rabbitmq/openssl/curl等常见扩展 获取Php的编译参数方法: [root@eus-api-cms-bac ...

  5. centos7下编译安装php-7.0.15(PHP-FPM)

    centos7下编译安装php-7.0.15(PHP-FPM) 一.下载php7源码包 http://php.net/downloads.php 如:php-7.0.15.tar.gz 二.安装所需依 ...

  6. 编译安装PHP7并安装Redis扩展Swoole扩展(未实验)

    用PECL自动安装Redis扩展.Swoole扩展 pecl install redis pecl install swool 编译安装PHP7并安装Redis扩展Swoole扩展 在编译php7的机 ...

  7. CentOS编译安装php7.2

    介绍: 久闻php7的速度以及性能那可是比php5系列的任何一版本都要快,具体性能有多好,建议还是先尝试下再说.如果你是升级或新安装,那你首先需要考虑php7和程序是否存在兼容性,如果程序是基于php ...

  8. CentOS7 编译安装 php7

    更新:2019-01-25 补充:CentOS 7.5 全新编译安装 PHP-7.3.1 ,补充内容接在原文之后 更新:2018-09-29 补充:新系统下编译安装PHP-7.2.5遇到的问题,补充内 ...

  9. Linux Centos7.2 编译安装PHP7.0.2

    操作环境: 1.系统:Centos7.2 2.服务:Nginx 1.下载PHP7.0.2的安装包解压,编译,安装: $ cd /usr/src/ $ wget http://cn2.php.net/d ...

  10. Centos7源码编译安装PHP7.2(生产环境)

    安装PHP依赖包,否则在编译的过程中可能会出现各种报错 # Centos 安装epel-release源并将系统包更新到最新版本 $ yum install epel-release-y $ yum ...

随机推荐

  1. java-前端之HTML

    --html网页简单使用 1.html网页的基本标签 <!doctype html><!-- 声明网页版本 --> <html><!-- 唯一的跟元素 --& ...

  2. Linux 禁止root远程登录解决办法

    linux中root用户是超级管理员,可以针对root用户暴力破解密码,这样很不安全,工作中我们一般禁止root用户直接远程登陆,开设一个或多个普通用户,只允许登陆普通用户,如果有需要用root用户, ...

  3. CF1511G Chips on a Board (倍增)

    题面 原题题面 转化方便版题意: 有 n n n 堆石子,第 i i i 堆有 c i ∈ [ 1 , m ] c_i\in [1,m] ci​∈[1,m] 个石子,有 q q q 次询问,每次询问给 ...

  4. 【JDBC】学习路径2-编写第一个JDBC程序

    第一章:导入jar包 在未安装MySQL数据库的请务必安装,安装教程:[MySQL]从入门到掌握2-下载安装 connector/J下载地址:https://dev.mysql.com/downloa ...

  5. C# 使用if(DEBUG)调试 失效问题

    在调试winform程序的时候,经常会切换debug和release模式.有些时候在debug模式下不想用的东西就会使用 #if(!DEBUG) #endif 但是这次在新项目的时候,使用这个语句,失 ...

  6. Makefile 文件的编写

    目录 目录 Makefile 编写规则 Makefile 编写规则 生成的目标文件:依赖文件 生成目标文件所需执行的动作(注:命令行前需加Tab推进) 例: VPATH=inc src main:ma ...

  7. Filebeat Nginx Module 自定义字段

    Filebeat Nginx Module 自定义字段 一.修改/usr/local/nginx/conf/nginx.conf中 log_format access '$remote_addr - ...

  8. vscode主题开发

    vscode主题开发教程 https://blog.csdn.net/Suwanqing_su/article/details/105945290 个人配置结果 主题代码 到Vscode放插件的目录中 ...

  9. 利用rpmbuild 打包可执行文件和链接库生成rpm 包

    Background: Background: 遇到一个打包可执行程序和链接库生成rpm 包的需求,查遍了很多网站的资料,现在整理下解决方案. 前期参考的是这篇帖子: https://codeante ...

  10. G&GH02 储存库创建/同步

    注意事项与声明 平台: Windows 10 作者: JamesNULLiu 邮箱: jamesnulliu@outlook.com 博客: https://www.cnblogs.com/james ...