linux如何使用yum安装php

发布时间:2023-01-29 11:02:35 作者:iii
来源:亿速云 阅读:136

这篇文章主要讲解了“linux如何使用yum安装php”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“linux如何使用yum安装php”吧!

linux使用yum安装php的方法:1、执行“mkdir /usr/local/php”命令;2、下载yum源的更新安装包;3、安装相关yum源安装包;4、通过“yum install”命令安装php即可。

一、yum安装php

1、mkdir /usr/local/php

2、cd /usr/local/php

3、下载yum源的更新安装包

centOS 6.x源

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget https://mirror.webtatic.com/yum/el6/latest.rpm

centOS 7.x源

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

4、安装相关yum源安装包(这里以centOS 7.x的为例)

rpm -Uvh epel-release-latest-7.noarch.rpm
rpm -Uvh webtatic-release.rpm

5、查看该源对应的php安装包命令(以PHP 为例)

yum list --enablerepo=webtatic | grep php

6、查找php 5.6版本的安装包

yum search php56w

7、安装Apache

yum install httpd httpd-devel

8、关闭firewalld防火墙

systemctl stop firewalld.service 
systemctl disable firewalld.service 
systemctl status firewalld

9、启动apache

/bin/systemctl start httpd.service

此时用浏览器访问你服务器IP地址  应该是Testing 123文件页面。

10、安装mysql【这里因为之前使用tar包安装了mysql,所以不安装】

11、启动mysql

systetcl start mysql

***如果启动mysql时报错

Failed to start mysql.service: Unit mysql.service failed to load: No such file or directory.

或者

Failed to start mysqld.service: Unit not found

则需要安装mariadb-server并启动,添加到开机自启动

yum install -y mariadb-server
systemctl start mariadb.service
systemctl enable mariadb.service

12、安装PHP

yum install php56w

13、重启apache使php生效

/bin/systemctl restart httpd.service

14、查看PHP的版本

php -v

15、php的简单使用

进入目录/var/www/html

vi index.php(必须是index.php【主页】才会在浏览器显示)

内容如下:

<!DOCTYPE html>
<html>
<body>
<?php
echo "Hello World!";
?>
</body>
</html>

感谢各位的阅读,以上就是“linux如何使用yum安装php”的内容了,经过本文的学习后,相信大家对linux如何使用yum安装php这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!

推荐阅读:
  1. linux和windows的区别是什么
  2. linux中500错误指的是什么

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

linux yum php

上一篇:php无法返回json格式如何解决

下一篇:vue中ts文件怎么应用

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》