centos7安装php7

1.在搜狐镜像下载php源码包

wget http://mirrors.sohu.com/php/php-7.0.5.tar.gz
tar -zvxf php-7.0.5.tar.gz

2.安装依赖包

yum install gcc autoconf gcc-c++
yum 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 readline readline-devel libxslt libxslt-devel
yum install systemd-devel
yum install openjpeg-devel

3.编译安装

./configure --prefix=/usr/local/php
make
make install

4.添加php命令环境变量

  a.查看php命令所在位置

[root@localhost swoole-4.5.5]# which php
/usr/local/php/bin/php

  b.使用全局的方式添加环境变量

vi /etc/profile

  c.在文档的末尾添加

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

    export PATH

  d.让新配置生效

source /etc/profile

  e.查看配置是否生效

[root@localhost swoole-4.5.5]# php -v
PHP 7.2.9 (cli) (built: Oct 14 2020 12:20:28) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

  

posted @ 2020-10-23 10:03  coder_xds  阅读(94)  评论(0编辑  收藏  举报