CentOS6安装使用httpd

获取更多文章和更新,请关注我的个人主页:leiting6.cn

1 安装httpd

在终端输入命令httpd,如果提示命令没有找到,则说明没有安装httpd。使用:

yum install -y httpd

安装httpd,如果出现No package httpd available,可以尝试:

yum --disableexcludes=all install -y httpd

来安装httpd。如果出现其他错误,就利用搜索引擎看看有没有解决办法吧。

2 修改配置文件

首先:

cd /etc/httpd
ls

可以看到,有这个目录有2个文件,一个README,一个welcome.conf

README的内容简单看一下,主要来关注welcome.conf的内容:

vi welcome.conf

可以看到:

#
# This configuration file enables the default "Welcome"
# page if there is no default index page present for
# the root URL.  To disable the Welcome page, comment
# out all the lines below.
#
<LocationMatch "^/+$">
    Options -Indexes
    ErrorDocument 403 /error/noindex.html
</LocationMatch>

很明白,意思是说,如果你没有配置httpd的话,默认显示Welcome页面;如果你不想使用Welcome页面,就讲下面所有行都注释掉。所以,直接使用vi编辑器把下面的都注释掉:

#
# This configuration file enables the default "Welcome"
# page if there is no default index page present for
# the root URL.  To disable the Welcome page, comment
# out all the lines below.
#
#<LocationMatch "^/+$">
#    Options -Indexes
#    ErrorDocument 403 /error/noindex.html
#</LocationMatch>

然后:

cd /etc/httpd/conf
ls

可以看到这个目录下有一个httpd.conf文件,这个就是httpd的配置文件,直接使用vi编辑器编辑它:

vi httpd.conf

我修改了如下几个地方:

  • listen 80修改为listen 2004(通过ip:2004端口来访问httpd页面)
  • DocumentRoot "/var/www/html"改成DocumentRoot "/www/wwwroot/leiting6.cn/tools" (访问httpd将显示该文件下的内容)
  • <Directory "/var/www/html"> ...改成<Directory "/www/wwwroot/leiting6.cn/tools"> (设置根目录一些权限)

如果出现:

httpd: Could not reliably determine the server's fully qualified domain name, using localhost.locald

将httpd.conf中的:

ServerName localhost:80改成ServerName localhost:2004

最后,重启httpd服务:

service httpd restart

这样,访问我的域名:2004,就能打开访问tools文件夹下面的内容了。这只是httpd的一个最简单的应用,可以把一些常用文件放在tools文件夹下,方便查看和下载;更高级的应用,还是需要研究一下httpd.conf配置文件才行。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 一、概述 二、编译安装 三、httpd服务基础 四、httpd.conf配置文件 五、httpd服务访问控制 六、...
    紫_轩阅读 970评论 0 0
  • awstats 可以通过apache 部署,关联指定格式的日志文件(apache,nginx),然后通过网页的形式...
    日不落000阅读 1,008评论 0 2
  • httpd相关: httpd程序版本: 。1.3 停止维护 。2.0 。 2.2 event为测试使用 。 2.4...
    ckhzw阅读 418评论 0 0
  • 诗人巴尔蒙特写道:“我来到这个世界为的是看太阳,和蔚蓝色的原野。我来到这个世界为的是看太阳,和连绵的群山。我...
    小莉文字铺阅读 392评论 0 2
  • 第22章 《两首菩萨蛮》 这一章用两首《菩萨蛮》举例,简要介绍了词的构造以及怎样欣赏一首词所表达的境界或想要抒发的...
    从此新生阅读 1,699评论 0 5