请帮我在apache服务器上设置正确的配置 . 我不知道它叫什么,但我想在我的服务器(Amazon EC2(CentOS)服务器)上设置多个站点 . 它还没有域名 .
我已经安装了所需的软件,包括php(用phpinfo.php检查) . 它工作正常 .
现在,我想在我的机器上托管两个不同的基于php的站点 .
假设,我的IP地址是 x.y.z.a
目录:
在/ var / www / html等/ CRM
在/ var / www / html等/ crmpanel
在/ var / www / html等/ mysite的
在我的httpd.conf中,我有:
NameVirtualHost *:80
ServerName x.y.z.a
DocumentRoot "/var/www/html"
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName x.y.z.a
ServerAlias x.y.z.a
DocumentRoot "/var/www/html/crm"
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName x.y.z.a
ServerAlias x.y.z.a
DocumentRoot "/var/www/html/crmpanel"
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName x.y.z.a
ServerAlias x.y.z.a
DocumentRoot "/var/www/html/mysite"
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log combined
</VirtualHost>
如果我运行"httpd -S",则返回'Syntax OK' . Apache服务器启动时没有任何错误 .
请帮我理解配置中的错误 .
1 回答
您需要为相应的虚拟主机条目设置
ServerName
和ServerAlias
(Domain names instead of the ip) 以及正确的DocumentRoot
.ServerAlias是可选的 .
有关详细说明,请参阅blog post .