Linux安装PHP 7并搭建环境
2022-07-28 15:20:24
143
{{single.collect_count}}

1、依次执行以下三条命令 安装PHP和一些所需的扩展

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpmrpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpmyum -y install php70w-tidy php70w-common php70w-devel php70w-pdo php70w-mysql php70w-gd php70w-ldap php70w-mbstring php70w-mcrypt php70w-fpm

2、输入php -v验证PHP的安装版本

在这里插入图片描述

3、systemctl start php-fpm启动php服务

4、systemctl enable php-fpm 设为开机启动

5、修改nginx配置文件

在index里添加index.php
让Nginx支持php格式的主页

location /{root /usr/local/webserver/nginx/html;index index.html index.htm index.php;}

/usr/share/nginx/html部分为自己Nginx的路径 其余无须改动

location ~ \.php$ {root html;fastcgi_pass 127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;includefastcgi_params;}

保存退出

6、service nginx reload 重载配置文件

7、测试

输入vi info.php 在html包下创建一个名为info.php的测试页面

输入:

<?php phpinfo();?>

保存

然后再在浏览器输入http://服务器ip地址/info.php

若显示如下图 则PHP环境搭建成功:
在这里插入图片描述


回帖
全部回帖({{commentCount}})
{{item.user.nickname}} {{item.user.group_title}} {{item.friend_time}}
{{item.content}}
{{item.comment_content_show ? '取消' : '回复'}} 删除
回帖
{{reply.user.nickname}} {{reply.user.group_title}} {{reply.friend_time}}
{{reply.content}}
{{reply.comment_content_show ? '取消' : '回复'}} 删除
回帖
收起
没有更多啦~
{{commentLoading ? '加载中...' : '查看更多评论'}}