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

CentOS 7.4安装PHP-7.1.5

作者头像
子润先生
修改2021-07-09 10:42:09
5890
修改2021-07-09 10:42:09
举报
文章被收录于专栏:用户8644135的专栏

PHP简介

    PHP 是一种创建动态交互性站点的强有力的服务器端脚本语言。PHP是目前动态网页开发中使用最为广泛的语言之一。PHP能运行在包括Windows、Linux等在内的绝大多数操作系统环境中

    PHP 是免费的,并且使用非常广泛。同时,对于像微软 ASP 这样的竞争者来说,PHP 无疑是另一种高效率的选项。

给大家介绍下CentOS 7.4下如何通过编译去安装php7.1.5,教程为本人亲测。

1、下载php-7.1.5软件包

下载地址:https://mirrors.yangxingzhen.com/php/php-7.1.5.tar.gz

[root@localhost ~]# wget -c https://mirrors.yangxingzhen.com/php/php-7.1.5.tar.gz

2、解压php7

[root@localhost ~]# tar zxf php-7.1.5.tar.gz

3、移动解压之后的文件夹到/usr/local/

[root@localhost ~]# mv php-7.1.5 /usr/local/php

4、进入php目录

[root@localhost ~]# cd /usr/local/php

5、安装依赖包

[root@localhost php]# yum -y install 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

6、编译配置(如果出现错误,基本都是上一步的依赖文件没有安装所致),嫌麻烦的可以从这一步起参考PHP官方安装说明:http://php.net/manual/zh/install.unix.nginx.php (极简安装)

[root@localhost php]# ./configure \

--prefix=/usr/local/php \

--with-config-file-path=/etc \

--enable-fpm \

--with-fpm-user=www \

--with-fpm-group=www \

--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

7、正式安装

[root@localhost php]# make && make install

8、配置php-fpm

[root@localhost php]# cp php.ini-production /etc/php.ini

[root@localhost php]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

[root@localhost php]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

[root@localhost php]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

[root@localhost php]# chmod +x /etc/init.d/php-fpm

9、创建www用户,启动php-fpm

[root@localhost php]# useradd www

[root@localhost php]# /etc/init.d/php-fpm start

至此就已经安装好php7.1.5了,希望可以帮助到大家。如需转载请注明出处。

附一键安装脚本,脚本内容如下:

代码语言:javascript
复制
#!/bin/bash
#Date:2018-5-20 14:08:55
#Author Blog:
#	https://www.yangxingzhen.com
#Author WeChat:
#	微信公众号:小柒博客
#Author mirrors site:
#	https://mirrors.yangxingzhen.com
#About the Author
#	BY:YangXingZhen
#	Mail:xingzhen.yang@yangxingzhen.com
#Auto Install PHP-7 Soft
 
PHP_URL=https://mirrors.yangxingzhen.com/php
PHP_FILE=php-7.1.5.tar.gz
PHP_FILE_DIR=php-7.1.5
PHP_PREFIX=/usr/local/php
USER=www
function install_php {
if [ ! -d ${PHP_PREFIX} ];then
wget -c ${PHP_URL}/${PHP_FILE}
tar zxf ${PHP_FILE}
mv ${PHP_FILE_DIR} ${PHP_PREFIX}
cd ${PHP_PREFIX}
#安装依赖包
yum –y install 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
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/etc \
--enable-fpm \
--with-fpm-user=${USER} \
--with-fpm-group=${USER} \
--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
if [ $? -eq 0 ];then
    make && make install
else
    exit 1
fi
fi
}
function config_php {
cp php.ini-production /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
useradd ${USER}
/etc/init.d/php-fpm start
}
install_php
config_php

本文系转载,前往查看

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

本文系转载前往查看

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

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • PHP简介
相关产品与服务
SSL 证书
腾讯云 SSL 证书(SSL Certificates)为您提供 SSL 证书的申请、管理、部署等服务,为您提供一站式 HTTPS 解决方案。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档