如何在yum中安装apache与php

发布时间:2020-07-15 15:23:25 作者:Leah
来源:亿速云 阅读:173

这篇文章将为大家详细讲解有关如何在yum中安装apache与php,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

yum安装apache与php的方法:首先执行命令“yum install -y httpd”安装apache;然后启动apache;接着执行命令“yum install -y php”安装php;最后新建一个PHP页面进行测试即可。

yum安装apache和php

一:安装apache

[root@ser6-52 ~]# yum install -y httpd
#验证是否安装成功
[root@ser6-52 ~]# rpm -qa | grep httpd
httpd-2.2.15-47.el6.centos.x86_64
httpd-tools-2.2.15-47.el6.centos.x86_64

显示已成功安装。

#启动apache
[plain] view plain copy
[root@ser6-52 ~]# service httpd start  
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

假如,启动的时候,出现如上:

Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

需要修改 /etc/httpd/conf/httpd.conf

vi  /etc/httpd/conf/httpd.conf

在文件最后添加:ServerName 127.0.0.1:80

#重启apache:
[root@ser6-52 ~]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

没有再报这个错误了。

#配置系统让 Apache 随系统启动:

[root@ser6-52 ~]# chkconfig --levels 235 httpd on

此时apache已经安装好了,访问http://192.168.6.52/就可以看到如下界面(备注:192.168.6.52是你服务器的ip)

注意:在CentOS 中 Apache 的默认根目录是/var/www/html,配置文件 /etc/httpd/conf/httpd.conf。其他配置存储在 /etc/httpd/conf.d/ 目录。

二:安装php

[root@ser6-52 conf.d]# yum install -y php

需要重新启动 Apache 服务:

[root@ser6-52 conf.d]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]

三:测试

为了测试是否安装成功,你可以新建一个 PHP 页面进行测试,使用 vim 编辑器新建:

[root@localhost ~]# vi /var/www/html/info.php

输入:welcome,dandan!

在浏览器里输入:http://192.168.6.52/info.php

可以看到:

说明安装成功。

--apache也可以这样启动停止:

/usr/local/apache2/bin/apachectl start/stop

关于如何在yum中安装apache与php就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

推荐阅读:
  1. 如何在linux中安装php与配置Apache服务器
  2. yum安装PHP/yum升级PHP

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

yum apache php

上一篇:解决postgresql无法删除数据表的方法

下一篇:更改jupyter工作路径的方法

相关阅读

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

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