分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 代码编程

CentOS 7解压安装PHP7.1.21

发布时间:2023-09-06 02:14责任编辑:白小东关键词:PHP

下载php

yum install -y wgetwget http://cn2.php.net/distributions/php-7.1.21.tar.gz

解压

tar -zxvf php-7.1.21.tar.gz
cd php-7.1.21

编译:

# 安装epelyum install -y epel-releasewget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
# 安装编译依赖
yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel \ libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel \ gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel gcc
# 创建目录
mkdir -p /data/service/php/etc./configure \--prefix=/data/service/php \--with-config-file-path=/data/service/php/etc \--enable-fpm \--with-fpm-user=nginx \--with-fpm-group=nginx \--enable-inline-optimization \--disable-debug \--disable-rpath \--enable-shared \--enable-soap \--with-libxml-dir \--with-xmlrpc \--with-openssl \--with-mcrypt \--with-mhash \--with-pcre-regex \--with-sqlite3 \--with-zlib \--enable-bcmath \--with-iconv \--with-bz2 \--enable-calendar \--with-curl \--with-cdb \--enable-dom \--enable-exif \--enable-fileinfo \--enable-filter \--with-pcre-dir \--enable-ftp \--with-gd \--with-openssl-dir \--with-jpeg-dir \--with-png-dir \--with-zlib-dir \--with-freetype-dir \--enable-gd-native-ttf \--enable-gd-jis-conv \--with-gettext \--with-gmp \--with-mhash \--enable-json \--enable-mbstring \--enable-mbregex \--enable-mbregex-backtrack \--with-libmbfl \--with-onig \--enable-pdo \--with-mysqli=mysqlnd \--with-pdo-mysql=mysqlnd \--with-zlib-dir \--with-pdo-sqlite \--with-readline \--enable-session \--enable-shmop \--enable-simplexml \--enable-sockets \--enable-sysvmsg \--enable-sysvsem \--enable-sysvshm \--enable-wddx \--with-libxml-dir \--with-xsl \--enable-zip \--enable-mysqlnd-compression-support \--with-pear \--enable-opcache
make && make install

增加环境变量

cat <<EOF > /etc/profile.d/php.shexport PATH=/data/service/php/bin:\$PATHEOF
# 生效环境变量
. /etc/profile

配置php-fpm

cp php.ini-production /data/service/php/etc/php.inicp /data/service/php/etc/php-fpm.conf.default /data/service/php/etc/php-fpm.confcp /data/service/php/etc/php-fpm.d/www.conf.default /data/service/php/etc/php-fpm.d/www.conf

配置php-fpm服务

# 注意:这个文件是根据上面C++编译配置动态生成的文件,里面写了上面配置的路径
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm# 启动权限chmod +x /etc/init.d/php-fpm

启动:

# 增加开机启动systemctl enable php-fpmsystemctl start php-fpm

注意:php-fpm需要nginx用户,当然你可以自行增加,也可以直接安装nginx。

自动化脚本:

https://github.com/easonjim/centos-shell/blob/master/php/install-php_7.1.21.sh 

参考:

https://blog.csdn.net/tojohnonly/article/details/78680633

CentOS 7解压安装PHP7.1.21

原文地址:https://www.cnblogs.com/EasonJim/p/9614413.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved