温馨提示×

温馨提示×

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

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

httpd服务器的安装和基本配置方法

发布时间:2021-07-12 10:52:55 来源:亿速云 阅读:225 作者:chen 栏目:服务器

这篇文章主要讲解了“httpd服务器的安装和基本配置方法”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“httpd服务器的安装和基本配置方法”吧!

主要了解虚拟目录的使用

1,安装
[root@station10 /]# yum install httpd*

[root@station10 /]# chkconfig httpd on

[@more@]

2,启动
[root@station10 /]# service httpd start
Starting httpd: [  OK  ]
[root@station10 /]#

3,校验 DocumentRoot目录:
DocumentRoot "/var/www/html"

4,测试

5,创建目录
[root@station10 /]# mkdir -p /var/www/virtual/www10.example.com/html
[root@station10 /]# cd /var/www/virtual/www10.example.com/html
[root@station10 html]# cat > index.html <<EOF
> www10.example.com
> EOF
[root@station10 html]#


6,修改配置文件

NameVirtualHost  192.168.0.10:80


   ServerName         www10.example.com
   ServerAdmin        root@station10.example.com
   DocumentRoot       /var/www/virtual/www10.example.com/html
   ErrorLog           logs/www10.example.com-error_log
   CustomLog          logs/www10.example.com-access_log combined


           Options     Indexes     Includes
   


7,测试dns是否正常
[root@station10 html]# dig www10.example.com

; <<>> DiG 9.3.3rc2 <<>> www10.example.com
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 13726
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;www10.example.com.             IN      A

;; ANSWER SECTION:
www10.example.com.      86400   IN      CNAME   station10.example.com.
station10.example.com.  86400   IN      A       192.168.0.10

;; AUTHORITY SECTION:
example.com.            86400   IN      NS      server1.example.com.

;; ADDITIONAL SECTION:
server1.example.com.    86400   IN      A       192.168.0.254

;; Query time: 12 msec
;; SERVER: 192.168.0.254#53(192.168.0.254)
;; WHEN: Fri Oct 17 20:59:17 2008
;; MSG SIZE  rcvd: 113

[root@station10 html]#


8,语法检查:
[root@station10 html]# service httpd configtest
Syntax error on line 1002 of /etc/httpd/conf/httpd.conf:
directive missing closing '>'
[root@station10 html]#

按照提示修改,然后重新运行:
[root@station10 html]# service httpd configtest
Syntax OK
[root@station10 html]# service httpd reload
Reloading httpd: [  OK  ]
[root@station10 html]#


9,测试
[root@station10 conf]# elinks -dump www10.example.com
  www10.example.com
[root@station10 conf]#

10. 防火墙设置
[root@station10 html]# iptables -I INPUT 1 -s 192.168.0.0/24 -p tcp --dport 80 -j ACCEPT
[root@station10 html]# service iptables save
Saving firewall rules to /etc/sysconfig/iptables: [  OK  ]
[root@station10 html]#

11,本机可以访问,其他机器访问一直报错:
[root@station10 conf]# elinks -dump station12.example.com
ELinks: Receive timeout
[root@station10 conf]#

把iptables重新启动测试,运行setup设置firewall等。

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

向AI问一下细节

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

AI