CentOS 7 配置 http 伺服器

2021-09-25 02:38:06 字數 1487 閱讀 2860

一、http單網域名稱訪問

1、安裝軟體: yum -y install httpd

2、啟動服務:systemctl  start httpd

3、設定開機啟動: systemctl enable httpd

4、建立index.html : touch  /var/www/html/index.html

5、在index.html裡新增內容test : echo "test" >/var/www/html/index.html

6、將 http 服務新增到防火牆: firewall-cmd  --permanent --add-rich-rule='rule family=ipv4 source address=10.0.0.0/24 service name=http accept'

8、建立httpd-vhosts.conf: vim /etc/httpd/conf.d/httpd-vhosts.conf

9、在httpd-vhosts.conf新增如下內容:

documentroot  /var/www/html

servername  www.test.com

serveralias  test.com

10、重啟http服務:systemctl restart httpd

11、在/etc/hosts裡新增如下內容:

10.0.0.20  www.test.com

10.0.0.20  test.com

12、完成以上步驟上即可實現網域名稱訪問,linux網域名稱訪問命令: curl  www.test.com

二、多網域名稱訪問

1、建立新目錄: mkdir  /var/www/private

2、建立index.html檔案並新增內容 orange: echo "orange"  >/var/www/private/index.html

3、在httpd-vhosts.conf裡新增如下內容:

documentroot  /var/www/private

servername  www.private.com

serveralias  private.com

4、重啟httpd服務: systemctl  restart httpd

5、在/etc/hosts裡新增如下內容: 

10.0.0.20 www.private.com

10.0.0.20 private.com

三、只允許指定ip訪問,在httpd-vhosts.conf裡新增如下內容:

require  ip 10.0.0.21      // 「require  local  allow」 表示只允許本機訪問,「require ip 10.0.0.0/24」 則表示允許0段網路訪問

require all  denied       // 此項為預設設定,有無均可

ps : 如區域網內沒做dns,則需要新增http伺服器裡的hosts檔案裡的相同內容到訪問電腦的hosts檔案裡

配置 Centos7 配置samba服務

這有何難,然而確實配置不易,我算是服了這個系統了。關於ubuntu配置可以參考我的這篇文章 root node02 yum install y samba samba client1.備份 cp etc samba smb.conf etc samba smb.conf backup 2.vi et...

centos7配置samba服務

samba匿名共享配置 安裝samba服務 yum install y samba samba client samba common 安裝之後請備份乙份原始的samba配置檔案 備份檔案 cp etc samba smb.conf etc samba smb.conf.bak 配置samba檔案 ...

Centos7配置samba服務

工作中總是碰到需要安裝samba服務的情況,看網上那些教程,雖然寫的很詳細,但是太多了,我只想最快配置好乙個能用的環境,所以自己整理了一點東西,作為備忘。yum install samba samba client yrpm qi samba修改配置檔案 etc samba smb.conf 最好備...