溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

httpd服務器的安裝和基本配置方法

發(fā)布時間:2021-07-12 10:52:55 來源:億速云 閱讀:235 作者:chen 欄目:服務器

這篇文章主要講解了“httpd服務器的安裝和基本配置方法”,文中的講解內(nèi)容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“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,創(chuàng)建目錄
[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服務器的安裝和基本配置方法”的內(nèi)容了,經(jīng)過本文的學習后,相信大家對httpd服務器的安裝和基本配置方法這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權內(nèi)容。

AI