腾讯云服务器安装PHP(CentOS Linux release 7.6.1810)
操作系统:腾讯云CentOS Linux release 7.6.1810 (Core)
cat /etc/centos-release //查看系统版本
一、先检查以前有没有安装的版本,如果有删除之前的 php 版本:
yum remove php* php-common
yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64
二、rpm 安装 Php7 相应的 yum源
CentOS/RHEL 7.x:
1 rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 2 rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
可以用yum search php7查看下安装源的版本
yum search php7
看来最新的是php72w,下来就开始安装吧
三、安装PHP
yum install php72w //根据需求选择模块
yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml
查看安装模块和版本:
yum list installed | grep php //查看安装木块
php -v //查看安装版本
四、常用systemctl指令:
systemctl enable *.service #开机运行服务 systemctl disable *.service #取消开机运行 systemctl start *.service #启动服务 systemctl stop *.service #停止服务 systemctl restart *.service #重启服务 systemctl reload *.service #重新加载服务配置文件 systemctl status *.service #查询服务运行状态 systemctl --failed #显示启动失败的服务