启动apache的httpd服务

2 篇文章 0 订阅
2 篇文章 0 订阅

        我们经常在linux下使用某个节点node,而浏览器其实和node也是有联系的,这个桥梁就是apache的httpd服务。接下来我们来看具体的使用过程。以node的ip为10.10.37.248为例。

一、判断httpd是否启动

在浏览器上输入ip回车:
再到node上查看并启动进程:
[root@localhost ~]# ps -ef |grep httpd
root     20609 20588  0 19:35 pts/0    00:00:00 grep httpd
[root@localhost ~]# service httpd start
httpd: unrecognized service
所得得知没有httpd服务,所以我们首先要安装httpd服务。

二、安装运行httpd

1. 安装
[root@localhost ~]# yum install httpd
在这个安装过程中下载安装了5个包:
 Installing : apr-1.3.9-5.el6_2.x86_64        
 Installing : apr-util-1.3.9-3.el6_0.1.x86_64      
 Installing : httpd-tools-2.2.15-39.el6.centos.x86_64  
 Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64   
 Installing : httpd-2.2.15-39.el6.centos.x86_64

2. 然后再次执行httpd的启动:
[root@localhost ~]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
                                                           [  OK  ]
[root@localhost ~]# ps -ef |grep httpd
root     20698     1  0 19:39 ?        00:00:00 /usr/sbin/httpd
apache   20700 20698  0 19:39 ?        00:00:00 /usr/sbin/httpd
apache   20701 20698  0 19:39 ?        00:00:00 /usr/sbin/httpd
apache   20702 20698  0 19:39 ?        00:00:00 /usr/sbin/httpd
apache   20703 20698  0 19:39 ?        00:00:00 /usr/sbin/httpd
apache   20704 20698  0 19:39 ?        00:00:00 /usr/sbin/httpd
apache   20705 20698  0 19:39 ?        00:00:00 /usr/sbin/httpd
apache   20706 20698  0 19:39 ?        00:00:00 /usr/sbin/httpd
apache   20707 20698  0 19:39 ?        00:00:00 /usr/sbin/httpd
root     20709 20588  0 19:39 pts/0    00:00:00 grep httpd
[root@localhost ~]# 

三、测试

1. 此时在浏览器下输入ip回车:
说明服务启动成功。
2. 查看log:
[root@localhost html]# cd /var/log/httpd/
[root@localhost httpd]# ls
access_log  error_log
[root@localhost httpd]# cat error_log 
[Mon Nov 24 19:39:52 2014] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0
[Mon Nov 24 19:39:52 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Nov 24 19:39:52 2014] [notice] Digest: generating secret for digest authentication ...
[Mon Nov 24 19:39:52 2014] [notice] Digest: done
[Mon Nov 24 19:39:52 2014] [notice] Apache/2.2.15 (Unix) DAV/2 configured -- resuming normal operations
[Mon Nov 24 19:40:36 2014] [error] [client 10.10.19.235] Directory index forbidden by Options directive: /var/www/html/
[Mon Nov 24 19:40:36 2014] [error] [client 10.10.19.235] File does not exist: /var/www/html/favicon.ico
[root@localhost httpd]# 

说明是没有index文件,所以我们创建一个index.html文件:
[root@localhost httpd]# echo "hello" > /var/www/html/index.html

3. 再在浏览器上输入ip回车:
说明访问成功。

四、补充说明

1. 访问index有可能出现的问题:

Permission denied: access to /index.html denied

解决办法:要确定/var/www/html这几级目录都具有可执行权限。如果确定了之后还是permission denied,还可以再试着把index.html删除然后重新创建一个index.html(有可能和浏览器的缓存有关系)。

2. 要查看log:
log可能在一下几个地方:
  • 在安装目录下即ServerRoot下有个logs目录,里面有errorlogaccesslog
  • 用yum安装的话默认在/etc/httpd下的logs下【这个logs是一个链接文件】
  • /var/log/httpd/


  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值