您好,欢迎访问一九零五行业门户网

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.rpmwget https://mirror.webtatic.com/yum/el6/latest.rpm
centos 7.x源
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmwget https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
4、安装相关yum源安装包(这里以centos 7.x的为例)
rpm -uvh epel-release-latest-7.noarch.rpmrpm -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-serversystemctl start mariadb.servicesystemctl 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><?phpecho "hello world!";?></body></html>
以上就是linux如何使用yum安装php的详细内容。
其它类似信息

推荐信息