前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS 7 安装 PHP 7.4.0 正式版

CentOS 7 安装 PHP 7.4.0 正式版

作者头像
Alone88
发布2020-09-01 09:49:36
2.6K0
发布2020-09-01 09:49:36
举报
文章被收录于专栏:Alone88Alone88

php 教程 centos 源码 编译

CentOS 7 源码安装 PHP 7.4 正式版教程

1、准备编译环境

代码语言:javascript
复制
yum -y install epel-release yum-utils
yum config-manager --set-enabled PowerTools
yum -y install gcc gcc-c++ make autoconf bzip2 bzip2-devel libpng libpng-devel freetype-devel gmp-devel readline-devel curl-devel libxml2-devel libjpeg-devel bison openssl-devel uw-imap-devel libc-client sqlite-devel libicu-devel libedit-devel libxslt-devel oniguruma oniguruma-devel
#yum -y install http://mirror.centos.org/centos-7/7.7.1908/cloud/x86_64/openstack-queens/oniguruma-6.7.0-1.el7.x86_64.rpm
#yum -y install http://mirror.centos.org/centos-7/7.7.1908/cloud/x86_64/openstack-queens/oniguruma-devel-6.7.0-1.el7.x86_64.rpm

以及 libzip

2、下载并解压

wget https://www.php.net/distributions/php-7.4.0.tar.bz2 tar -jxf php-7.4.0.tar.bz2 cd php-7.4.0 3、配置并构建 PHP。在此步骤您可以使用很多选项自定义 PHP,例如启用某些扩展等。 运行 ./configure –help 命令来获得完整的可用选项清单。 在本示例中,我们仅进行包含 PHP-FPM 和 MySQL 支持的简单配置。

代码语言:javascript
复制
./configure --prefix=/usr \
   --sysconfdir=/etc/php \
   --with-config-file-path=/etc/php \
   --with-config-file-scan-dir=/etc/php/php.d \
   --bindir=/usr/bin \
   --docdir=/usr/share/doc \
   --sbindir=/usr/sbin \
   --libdir=/usr/lib64/php \
   --with-libdir=/usr/lib64/php \
   --libexecdir=/usr/libexec \
   --localstatedir=/var \
   --includedir=/usr/include \
   --localedir=/usr/local \
   --datarootdir=/usr/share \
   --datadir=/usr/share/php \
   --mandir=/usr/share/man \
   --infodir=/usr/share/info \
   --enable-fpm \
   --with-fpm-user=www-data \
   --with-fpm-group=www-data \
   --enable-mysqlnd \
   --enable-mysqlnd-compression-support \
   --enable-json \
   --with-openssl-dir \
   --with-zlib-dir \
   --with-freetype \
   --enable-gd-jis-conv \
   --enable-ftp \
   --enable-filter \
   --enable-fileinfo \
   --with-curl \
   --with-iconv \
   --with-bz2 \
   --with-zlib \
   --with-zip \
   --with-xsl \
   --with-jpeg \
   --with-webp \
   --with-xpm \
   --without-iconv \
   --with-kerberos \
   --with-imap-ssl \
   --with-openssl \
   --enable-dom \
   --with-gettext \
   --with-mysqli=mysqlnd \
   --enable-pdo \
   --with-pdo-mysql=mysqlnd \
   --enable-simplexml \
   --enable-session \
   --enable-sysvsem \
   --enable-sysvmsg \
   --enable-sockets \
   --with-pear \
   --with-xmlrpc \
   --with-mhash \
   --enable-bcmath \
   --with-cdb \
   --enable-exif \
   --with-gmp \
   --enable-mbstring \
   --enable-mbregex \
   --with-readline \
   --enable-shmop \
   --enable-soap \
   --enable-sockets \
   --enable-pcntl \
   --enable-intl \
   --enable-re2c-cgoto \
   --with-libedit
make
sudo make install

4、创建配置文件,并将其复制到正确的位置。

代码语言:javascript
复制
cp php.ini-production /etc/php/php.ini
cp sapi/fpm/php-fpm.conf /etc/php/php-fpm.conf
cp sapi/fpm/www.conf /etc/php/php-fpm.d/www.conf
cp sapi/fpm/php-fpm.service /etc/systemd/system/php-fpm.service

5、需要着重提醒的是,如果文件不存在,则阻止 Nginx 将请求发送到后端的 PHP-FPM 模块, 以避免遭受恶意脚本注入的攻击。 将 php.ini 文件中的配置项 cgi.fix_pathinfo 设置为 0 。 打开 php.ini:

vi /etc/php/php.ini 定位到 cgi.fix_pathinfo= 并将其修改为如下所示:

cgi.fix_pathinfo=0 6、配置 php-fpm 服务

sudo systemctl start php-fpm 检查是否启动成功

sudo systemctl status php-fpm

如果出现错误:ERROR: [pool www] cannot get uid for user 'www-data' 则新建www-data 用户组:

代码语言:javascript
复制
groupadd www-data
useradd -g www-data www-data

设置服务自启动

sudo systemctl enable php-fpm 本文档未涵盖对 php-fpm 进行进一步配置的信息,如果您需要更多信息,请查阅相关文档。

本文由 Alone88 创作,采用 知识共享署名4.0 国际许可协议进行许可 本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名 最后编辑时间为: Aug 31, 2020 at 11:03 pm

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
云数据库 MySQL
腾讯云数据库 MySQL(TencentDB for MySQL)为用户提供安全可靠,性能卓越、易于维护的企业级云数据库服务。其具备6大企业级特性,包括企业级定制内核、企业级高可用、企业级高可靠、企业级安全、企业级扩展以及企业级智能运维。通过使用腾讯云数据库 MySQL,可实现分钟级别的数据库部署、弹性扩展以及全自动化的运维管理,不仅经济实惠,而且稳定可靠,易于运维。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档