ENGINEER1.2
html
HTTP服務基礎linux
基於B/S架構的網頁服務web
----服務端提供頁面;vim
----瀏覽器下載並顯示頁面;瀏覽器
----------------------------------------------------------------------------------------------------------------------------------------------
安全
獨立wab主機的快速部署
服務器
安裝httpd
網絡
#yum -y install httpd架構
2啓動httpd服務,並設置開機自啓app
#systemctl restart httpd
#systemctl enable httpd
3.書寫網頁:
#echo MY FIRST WEB > /var/www/htm/index.html
Desktop上:
#elinks -dump 172.25.0.11
------Servername:本站點註冊的DNS名稱
vim /etc/httpd/conf/httpd.conf //修改主機配置文件
vim 查找/ServerName
ServerName server0.example.com:80
2.重起httpd服務:
#systemctl restart httpd
Desktop上:
#elinks -dump server0.example.com
訪問web站點:
----Documentroot:網頁根目錄(/var/www/html)
服務端:/var/www/html/
修改主配文件的內容 #vim /etc/httpd/conf/httpd.conf
DocumentRoot 「/var/www/abc」
2.建立目錄 #mkdir /var/www/abc
3.重起httpd服務 #systemctl restart httpd
4.書寫網頁文件
#echo wo shi abc > /var/www/abc/index.html
Desktop上
#elinks -dump server0.example.com
虛擬web主機
目的:省錢
由同一臺服務器提供多個不一樣的的web站點。
區分方式:
基於域名的虛擬機
基於端口的虛擬機
基於ip地址的虛擬機
幫助文檔: /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf
創建從配置文件
#vim /etc/httpd/conf.d/nsd01.conf
<VirtualHost * : 80>
DocumentRoot /var/www/test
ServerName www0.example.com
</VirtualHost>
<VirtualHost * : 80>
DocumentRoot /var/www/nsd
ServerName webapp0.example.com
</VirtualHost>
2.創建目錄及相應的網頁內容
#echo wo shi test > /var/www/test/index.html
#echo wo shi nsd > /var/www/nsd/index.html
3.重起httpd服務
#systemctl restart httpd
虛擬web,全部的站點都必須用虛擬地址
---------------------------------------------------------------------------------------------------------------------------
網頁訪問控制
配置目錄權限:
文件夾權限:
針對DocumentRoot網頁目錄的權限控制:
---httpd運行身份:apche
---能提取哪些網絡資源
#vim /etc/httpd/conf/httpd.conf
User Apche
Group Apache
客戶機地址限制:
使用<Directory>配置區段
---每一個文件家自動繼承其父目錄的acl訪問權限
---除非針對子目錄有明確設置
禁止任何客戶機訪問
<Dirctory />
Require all denied
</Dirctory>
容許任何客戶機訪問
<Dirctory 「/var/www/html」>
Require all granted
</Dirctory>
僅容許部分客戶機訪問
<Dirctory /var/www/html/private>
Require ip 127.0.0.1
</Dirctory>
--------------------------------------------------------------------------------------------------------------------------------------
SElinux策略保護
安全上下文(打上相同標籤)
#chcon -R --reference=/var/www /webroot
---------------------------------------------------------------------------------------------------------------------------------------
使用自定web訪問
修改配置文件
#vim /etc/httpd/conf.d/nsd01.conf
<VirtualHost *:80>
Document /webroot
ServerName server0.example.com
</VirtualHost>
2.建立目錄與網頁文件
#mkdir /webroot
#echo wo shi webroot >/webroot/index.html
3.修改訪問控制配置文件
#vim /etc/httpd/conf.d/nsd02.conf
<Directory "/webroot">
Require all granted
</Directory>
4.修改SElinux標籤值:
#chcon -R --reference=/var/www /webroot
5.重起httpd服務:
#systemctl restart httpd
6.在Desktop上:
#elinks -dumps server0.example.com