Centos7 源码安装php7

一、下载安装包:

mkdir /usr/local/php
cd /usr/local/php
wget -O php-7.1.19.tar.gz http://cn2.php.net/get/php-7.1.19.tar.gz/from/this/mirror

二、安装:

2.1、解压文件:

tar -zxvf php-7.1.19.tar.gz

进入解压后的文件

cd php-7.1.19

2.2、安装所需扩展库:

yum -y install gcc
yum -y install openssl openssl-devel
yum -y install curl-devel
yum -y install libjpeg-devel
yum -y install libpng-devel
yum -y install freetype-devel
yum -y install libxslt-devel
yum -y install libxml2 libxml2-devel
yum -y install epel-release
yum -y install libmcrypt-devel

2.3:配置PHP

./configure --prefix=/usr/local/php \
--with-config-file-path=/usr/local/php/etc/ \
--with-curl \
 --with-freetype-dir \
 --with-gd \
 --with-jpeg-dir \
 --with-gettext \
 --with-iconv-dir \
 --with-kerberos \
 --with-libdir=lib64 \
 --with-libxml-dir \
 --with-mysqli \
 --with-openssl \
 --with-pcre-regex \
 --with-pdo-mysql \
 --with-pdo-sqlite \
 --with-pear \
 --with-png-dir \
 --with-xmlrpc \
 --with-xsl \
 --with-zlib \
 --enable-fpm \
 --enable-bcmath \
 --enable-libxml \
 --enable-inline-optimization \
 --enable-gd-native-ttf \
 --enable-mbregex \
 --enable-mbstring \
 --enable-opcache \
 --enable-pcntl \
 --enable-shmop \
 --enable-soap \
 --enable-sockets \
 --enable-sysvsem \
 --enable-xml \
 --enable-zip

2.4:安装:

make && make install

2.5、复制配置文件到PHP目录:

cp php.ini-production /usr/local/php/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

2.6:设置环境变量:

vi /etc/profile

在文件最后添加:

PATH=$PATH:/usr/local/php/bin:
export PATH

如下图:
在这里插入图片描述
保存后,执行如下命令使配置生效:

source /etc/profile

2.7、php-fpm开机自启动:

vi /etc/systemd/system/php-fpm.service

新增如下代码:

[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target
 
[Service]
Type=simple
PIDFile=/run/php-fpm.pid
ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID
 
[Install]
WantedBy=multi-user.target

启动php-fpm:

systemctl start php-fpm.service

添加开机启动:

systemctl enable php-fpm.service

2.8:信息查看:

php -v

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值