发布网友 发布时间:2022-04-22 03:57
共1个回答
热心网友 时间:2024-08-13 21:11
linux系统配置Apache虚拟主机实例:
1、安装apache和php:
yum install httpd php
2、假设服务器的IP是192.168.1.1,有两个域名指向该IP,分别是domain1.com, domain2.com,
修改/etc/httpd/conf/httpd.conf,在文件的最后加入:
ServerName 192.168.1.1NameVirtualHost 192.168.1.1
<VirtualHost 192.168.1.1>
ServerName domain1.com
DocumentRoot /var/www/domain1.com
<Directory "/var/www/domain1.com">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 192.168.1.1>
ServerName domain2.com
DocumentRoot /var/www/domain2.com
<Directory "/var/www/domain2.com">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
3、然后在/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
4、在浏览器里输入http://domain1.com和http://domain2.com即可看到效果了。