欢迎来到福编程网,本站提供各种互联网专业知识!

linux系统配置Apache虚拟主机实例

发布时间:2016-08-29 作者:佚名 来源:互联网
安装apache,php:yuminstallhttpdphp假设VPS的IP是58.130.17.168,有两个域名指向该IP,分别是domain1.com,domain2.com,修改/etc/httpd/conf/httpd.conf,在文件的最后加入:ServerName58.130.17.168NameVirtualHost58.130.17.168&

安装apache,php:

yum install httpd php

假设VPS的IP是58.130.17.168,有两个域名指向该IP,分别是domain1.com, domain2.com,

修改/etc/httpd/conf/httpd.conf,在文件的最后加入:

ServerName 58.130.17.168

NameVirtualHost 58.130.17.168

ServerName domain1.com

DocumentRoot /var/www/domain1.com

Options Indexes FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

ServerName domain2.com

DocumentRoot /var/www/domain2.com

Options Indexes FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

然后在/var/www/domain1.com和/var/www/domain2.com下创建不同的index.html文件:

echo "domain1">/var/www/domain1.com/index.html

echo "domain2">/var/www/domain2.com/index.html

在浏览器里输入http://domain1.com和http://domain2.com即可看到效果了

相关推荐