实验要求:同一台服务器,不同IP,不同域名。
实验要点:1.安装Apache服务包,启动服务。
2.修改配置文件4处。(详见如下)
3.创建网站目录。
4.写入配置文件。
==================================================================
1.分配IP
==================================================================
[root@localhost Server]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1
[root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-eth0:2
实验要点:1.安装Apache服务包,启动服务。
2.修改配置文件4处。(详见如下)
3.创建网站目录。
4.写入配置文件。
==================================================================
1.分配IP
==================================================================
[root@localhost Server]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-eth0:1
[root@localhost network-scripts]# cp ifcfg-eth0 ifcfg-eth0:2
====================================================================
2.安装Apache服务包。启动服务
====================================================================
[root@localhost ~]# mount /dev/cdrom /mnt
\mount: block device /dev/cdrom is write-protected, mounting read-only
[root@localhost ~]# cd /mnt/Server/
[root@localhost Server]# rpm -ivh httpd-2.2.3-6.el5.i386.rpm
warning: httpd-2.2.3-6.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 3701 7186
Preparing... ########################################### [100%]
1:httpd ########################################### [100%]
[root@localhost Server]# service httpd start
Starting httpd: [ OK ]
[root@localhost Server]# netstat -nat |grep 80
tcp 0 0 :::80 :::* LISTEN
[root@localhost Server]# ps axo user,pid,cmd |grep httpd
root 4258 /usr/sbin/httpd |……………………………………… |
apache 4260 /usr/sbin/httpd |Ps: 此两处端口和进程命令 |
apache 4261 /usr/sbin/httpd |查看证明服务正常启动。 |
apache 4262 /usr/sbin/httpd |…………………………………………|
apache 4263 /usr/sbin/httpd
apache 4264 /usr/sbin/httpd
apache 4265 /usr/sbin/httpd
apache 4266 /usr/sbin/httpd
apache 4267 /usr/sbin/httpd
root 4271 grep httpd
==========================================================================
3.修改Apache主配置文件。
==========================================================================
[root@localhost Server]# vim /etc/httpd/conf/httpd.conf
KeepAlive On -----------→此处为需要修改Off为On的内容
…………………………………………………………………………………………… ………………|
<Directory "/var/www/html"> |
Options 『Indexes』 FollowSymLinks -----------→标记处为需要删除的内容。|
………………………………………………………………………………………………………………
DefaultType 『text/plain』 -----→此处为需要修改标记内容为application/octet-stream的内容
2.安装Apache服务包。启动服务
====================================================================
[root@localhost ~]# mount /dev/cdrom /mnt
\mount: block device /dev/cdrom is write-protected, mounting read-only
[root@localhost ~]# cd /mnt/Server/
[root@localhost Server]# rpm -ivh httpd-2.2.3-6.el5.i386.rpm
warning: httpd-2.2.3-6.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 3701 7186
Preparing... ########################################### [100%]
1:httpd ########################################### [100%]
[root@localhost Server]# service httpd start
Starting httpd: [ OK ]
[root@localhost Server]# netstat -nat |grep 80
tcp 0 0 :::80 :::* LISTEN
[root@localhost Server]# ps axo user,pid,cmd |grep httpd
root 4258 /usr/sbin/httpd |……………………………………… |
apache 4260 /usr/sbin/httpd |Ps: 此两处端口和进程命令 |
apache 4261 /usr/sbin/httpd |查看证明服务正常启动。 |
apache 4262 /usr/sbin/httpd |…………………………………………|
apache 4263 /usr/sbin/httpd
apache 4264 /usr/sbin/httpd
apache 4265 /usr/sbin/httpd
apache 4266 /usr/sbin/httpd
apache 4267 /usr/sbin/httpd
root 4271 grep httpd
==========================================================================
3.修改Apache主配置文件。
==========================================================================
[root@localhost Server]# vim /etc/httpd/conf/httpd.conf
KeepAlive On -----------→此处为需要修改Off为On的内容
…………………………………………………………………………………………… ………………|
<Directory "/var/www/html"> |
Options 『Indexes』 FollowSymLinks -----------→标记处为需要删除的内容。|
………………………………………………………………………………………………………………
DefaultType 『text/plain』 -----→此处为需要修改标记内容为application/octet-stream的内容
DefaultType application/octat-stream
………………………………………………………………………………………………………………
AddDefaultCharset zh-CN ---------→此处为需要修改编码UTf8为GB2312简体中文zh-CN
===========================================================================
4.创建网站存放目录
===========================================================================
[root@localhost Server]# mkdir /www
[root@localhost Server]# mkdir /bbs
[root@localhost Server]# echo "liunanshibendan">/www/index.html
[root@localhost Server]# echo "liunanshibendan">/bbs/index.html
===========================================================================
5.编辑辅助配置文件。
===========================================================================
[root@localhost ~]# vim /etc/httpd/conf.d/www.conf
[root@localhost Server]# echo "liunanshibendan">/bbs/index.html
[root@localhost Server]#
[root@localhost Server]# vim /etc/httpd/conf.d/www.conf
<VirtualHost 172.16.12.20>
DocumentRoot /www
ServerName www.tiancai.com
</VirtualHost>
………………………………………………………………………………………………………………
AddDefaultCharset zh-CN ---------→此处为需要修改编码UTf8为GB2312简体中文zh-CN
===========================================================================
4.创建网站存放目录
===========================================================================
[root@localhost Server]# mkdir /www
[root@localhost Server]# mkdir /bbs
[root@localhost Server]# echo "liunanshibendan">/www/index.html
[root@localhost Server]# echo "liunanshibendan">/bbs/index.html
===========================================================================
5.编辑辅助配置文件。
===========================================================================
[root@localhost ~]# vim /etc/httpd/conf.d/www.conf
[root@localhost Server]# echo "liunanshibendan">/bbs/index.html
[root@localhost Server]#
[root@localhost Server]# vim /etc/httpd/conf.d/www.conf
<VirtualHost 172.16.12.20>
DocumentRoot /www
ServerName www.tiancai.com
</VirtualHost>
<VirtualHost 172.16.12.30>
DocumentRoot /bbs
ServerName bbs.tiancai.com
</VirtualHost>
==========================================================================
[root@localhost Server]# chkconfig --level 2345 httpd on 开机自动运行httpd服务
DocumentRoot /bbs
ServerName bbs.tiancai.com
</VirtualHost>
==========================================================================
[root@localhost Server]# chkconfig --level 2345 httpd on 开机自动运行httpd服务
==========================================================================
6.安装elinks浏览器.
==========================================================================
[root@localhost Server]# rpm -ivh elinks-0.11.1-5.1.el5.i386.rpm
warning: elinks-0.11.1-5.1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:elinks ########################################### [100%]
[root@localhost Server]# elinks 172.16.12.20
http://172.16.12.20/
liunanshibendan
6.安装elinks浏览器.
==========================================================================
[root@localhost Server]# rpm -ivh elinks-0.11.1-5.1.el5.i386.rpm
warning: elinks-0.11.1-5.1.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:elinks ########################################### [100%]
[root@localhost Server]# elinks 172.16.12.20
http://172.16.12.20/
liunanshibendan
OK [------]
liunanshibendan
╔════════════ Exit ELinks ═════════════╗
║ ║
║ Do you really want to exit ELinks? ║
║ ║
║ [ Yes ] [ No ] ║
╚══════════════════════════════════════╝
OK [------]
转载于:https://blog.51cto.com/hanxs/161052