我有一台运行Linux的服务器。它是一个具有ip 10.61.0.3
的VM。目前用于在/var/www/html
端口80
处为我的网站提供服务。
我想从位于/var/www/laraapp
的此服务器向端口8080
提供Laravel应用。
我目前为虚拟主机配置的apache是:
<VirtualHost *:8080>
ServerName 10.61.0.3:8080
DocumentRoot /var/www/laraapp/public
</VirtualHost>
当我访问10.61.0.3:8080
时,没有显示任何内容。以下是关于apache error_logs的内容:
[Mon Mar 17 17:28:43 2014] [notice] caught SIGTERM, shutting down
[Mon Mar 17 17:28:48 2014] [notice] SELinux policy enabled; httpd running as context unconfined_u:system_r:httpd_t:s0
[Mon Mar 17 17:28:48 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Mon Mar 17 17:28:48 2014] [notice] Digest: generating secret for digest authentication ...
[Mon Mar 17 17:28:48 2014] [notice] Digest: done
[Mon Mar 17 17:28:48 2014] [notice] Apache/2.2.15 (Unix) DAV/2 PHP/5.4.7 configured -- resuming normal operations
[Mon Mar 17 17:28:48 2014] [error] avahi_entry_group_add_service_strlst("10.61.0.3") failed: Invalid host name
我该怎么办?
注意:
LoadModule rewrite_module modules/mod_rewrite.so
已在/etc/httpd/conf/httpd.conf
Listen 8080
已在/etc/httpd/conf/httpd.conf
答案 0 :(得分:0)
在Apache文档中,ServerName
应该类似于域名http://httpd.apache.org/docs/2.2/mod/core.html#servername
尝试将ServerName 10.61.0.3
更改为ServerName example.com
。
不要忘记将127.0.0.1 example.com
添加到/etc/hosts
。
如果您希望在端口8080上运行VirtualHost,则必须定义NameVirtualHost
http://httpd.apache.org/docs/2.2/vhosts/examples.html#port
例如:
Listen 8080
NameVirtualHost 10.61.0.3:8080
<VirtualHost 10.61.0.3:8080>
ServerName example.com
DocumentRoot /var/www/laraapp/public
</VirtualHost>