你如何configuration一个Apache站点专门用于请求不包含域名(即他们直接来自IP, http://123.45.67.89/ )?
这个答案build议创build一个虚拟主机,如:
<VirtualHost *> DocumentRoot /www/default # ... </VirtualHost>
但这在Apache 2.4.18上不适用于我。
我也尝试指定一个没有定义ServerName的default.conf站点,如:
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /log/ "/var/log/" <Directory "/var/log/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from all Require all granted </Directory> </VirtualHost>
但是这也行不通。 所有请求到我的服务器的IP超时,而服务器对域名主机的请求立即作出回应。
看着我的apache error.log,我看到了很多行:
[Sun Oct 29 21:13:13.843598 2017] [core:notice] [pid 5650:tid 139875504514944] AH00051: child pid 23179 exit signal Segmentation fault (11), possible coredump in /etc/apache2 [Sun Oct 29 21:13:13.843609 2017] [core:error] [pid 5650:tid 139875504514944] AH00546: no record of generation 0 of exiting child 23179 [Sun Oct 29 21:13:14.845641 2017] [core:notice] [pid 5650:tid 139875504514944] AH00051: child pid 23183 exit signal Segmentation fault (11), possible coredump in /etc/apache2 [Sun Oct 29 21:13:14.845704 2017] [core:error] [pid 5650:tid 139875504514944] AH00546: no record of generation 0 of exiting child 23183 [Sun Oct 29 21:13:14.845733 2017] [core:notice] [pid 5650:tid 139875504514944] AH00051: child pid 23184 exit signal Segmentation fault (11), possible coredump in /etc/apache2 [Sun Oct 29 21:13:14.845746 2017] [core:error] [pid 5650:tid 139875504514944] AH00546: no record of generation 0 of exiting child 23184 [Sun Oct 29 21:13:14.845770 2017] [core:notice] [pid 5650:tid 139875504514944] AH00051: child pid 23185 exit signal Segmentation fault (11), possible coredump in /etc/apache2 [Sun Oct 29 21:13:14.845783 2017] [core:error] [pid 5650:tid 139875504514944] AH00546: no record of generation 0 of exiting child 23185
我认为这不好? 什么会导致Apache段错误?
这个问题原来是Apache可以同时运行的ModWSGI站点的一个bug /限制。 我有大约20个WSGI站点运行一个Django应用程序,显然这导致了Apache崩溃并取下了我试图testing的“简单”站点。
所以我上面的例子实际上都起作用了,但是我必须先删除几个WSGI站点来阻止Apache崩溃。
我相信Apache在sites-enabled目录中使用* .conf文件的字母顺序。 所以,如果我在服务器上有一些网站:
example.org.conf example.org-ssl.conf another-domain.conf another-domain-ssl.conf
我想使用example.org作为“默认”站点,你可以创build一个符号链接到你想要的站点,像000-default.conf这样的名字(Debian这样做)。
000-default.conf -> example.org.conf