美文网首页程序员
CentOS 7 配置LNMP环境 | 安装PHP

CentOS 7 配置LNMP环境 | 安装PHP

作者: 爱生活的技术君 | 来源:发表于2020-04-17 15:05 被阅读0次

1.更新yum中PHP的软件源

依次执行下面两个命令更新PHP软件源

rpm -Uvh https://mirrors.cloud.tencent.com/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
更新PHP软件源

2.安装PHP

执行以下命令,安装 PHP 7.2 所需要的包

yum -y install mod_php72w.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-mysqlnd php72w-fpm.x86_64

3.启动PHP

执行systemctl start php-fpm启动PHP服务
执行systemctl enable php-fpm设置为开机自启动

4.验证环境配置

至此LNMP环境就算搭建完成了
执行以下命令创建测试文件

echo "<?php phpinfo(); ?>" >> /usr/share/nginx/html/index.php

执行以下命令重启Nginx服务

systemctl restart nginx

浏览器中访问公网IP查看网页中是否显示PHP INFO
如果显示如下则说明配置成功


配置成功

Done!

相关文章

网友评论

    本文标题:CentOS 7 配置LNMP环境 | 安装PHP

    本文链接:https://www.haomeiwen.com/subject/kcaevhtx.html