1. 程式人生 > >HTTP搭建第一篇

HTTP搭建第一篇

int html back ack face ech links 內容 family

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

二、實現808080多端口的訪問

修改配置文件/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搭建第一篇