千家信息网

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

发表于:2025-02-02 作者:千家信息网编辑
千家信息网最后更新 2025年02月02日,这篇文章主要讲解了"httpd服务器的安装和基本配置方法",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"httpd服务器的安装和基本配置方法"吧!主要了
千家信息网最后更新 2025年02月02日httpd服务器的安装和基本配置方法

这篇文章主要讲解了"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 <> 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服务器的安装和基本配置方法这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!

0