HTTP搭建第一篇
1、搭建web,部署能訪問的網頁
2、實現80和8080等多端口的訪問
3、實現多端口訪問的內容不同
一、搭建web,部署能訪問的網頁
①裝包
# yum -y install httpd
②部署網頁
# echo web > /var/www/html/index.html
③起服務
# service httpd restart
# chkconfig httpd on
④客戶端驗證
# elinks -dump http://192.168.2.21
二、實現80和8080多端口的訪問
①修改配置文件/etc/httpd/conf/httpd.conf
# vim /etc/httpd/conf/httpd.conf
增 Listen 8080
②起服務
# service httpd restart
③客戶端驗證
# elinks -dump http://192.168.2.21:8080
三、實現多端口訪問的網頁內容不同
①前提部署
# chcon -R --reference=/var/www /html8080/ :配置網頁訪問權限,安全上下文
# echo 123 > /html8080/index.html
# vim /etc/hosts
增 web :設置本機的域名
②修改配置文件
# vim /etc/httpd/conf/httpd.conf
Listen 80
增 <VirtualHost *:80>
增 ServerName web
增 DocumentRoot /var/www/html
增 </VirtualHost>
Listen 8080
增 <VirtualHost *:8080>
增 ServerName web
增 DocumentRoot /html8080
增 </VirtualHost>
③起服務
# service httpd restart
④客戶端測試(訪問到的內容不一樣)
# elinks -dump http://192.168.2.21:80
# elinks -dump http://192.168.2.21:8080
HTTP搭建第一篇