CentOS 5.5下Apache配置(初级篇)

CentOS 5.5下Apache配置(初级篇-三种基本配置)。

配置前准备。

挂载镜像-〉安装apache的rpm包->创建web主目录以及站点文件->进入apache配置文件

#mkdir /mnt/cdrom

#mount –t iso9660 /dev/cdom /mnt/cdrom

#rpm –ivh httpd-*

#mkdir /web /web1

#touch /web/index.html

#touch /web1/index.html

#echo 1 > /web/index.html

#echo 2 > /web1/index.html

#vim /etc/httpd/conf/httpd.conf

一、两个不同ip

最后一行添加:

DocumentRoot /web

DirectoryIndex index.html

ServerName web

DocumentRoot /web1

DirectoryIndex index.html

ServerName web1

打开浏览器如果服务器有这两个ip则可以看到192.168.10.100的网页内容是1,192.168.10.101的网页内容是2

二、两个不同端口

首先在135行添加Listen 8080

DocumentRoot /web

DirectoryIndex index.html

ServerName web

DocumentRoot /web1

DirectoryIndex index.html

serverName web1

打开浏览器可以访问,服务器不需要两个ip,只需要开启两个端口即可,如果135没有添加端口则无法访问8080端口因为8080端口默认是不开启的

三、两个不同域名

NameVirtualHost 192.168.10.100

:80>

DocumentRoot /web

DirectoryIndex index.html

ServerName web

NameVirtualHost 192.168.10.100

DocumentRoot /web1

DirectoryIndex index.html

ServerName web1

这里不需要开启另外一个端口就可以访问,只要配置了两个域名则可以使用这两个域名来访问。

三种方法各种特色,初学者仅需按照要求进行相应配置即可…

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/psjfd.html