【问题标题】:Virtual hosts not working despite following online guidance meticulously尽管仔细遵循在线指导,虚拟主机仍无法正常工作
【发布时间】:2020-09-30 06:16:31
【问题描述】:

可能没有什么比对这个问题的问题更能引起人们的蔑视了,但我真的很茫然:

我有2个IP地址,主要的77.68.123.127指向默认的VirtualHost,000-default == www.oneasl.com,第二个77.68.122.124指向davical == cal。 oneasl.com。追加2个conf文件,然后输出'root@asl1:/etc/php/7.2/apache2# apache2ctl -S'

php 在77.68.123.127/davical工作

77.68.123.127 在浏览器中将我带到 apache2 欢迎页面 77.68.123.127/davical 带我进入 davical 登录 77.68.123.127:8080 带我去tomcat8

到目前为止一切顺利

然而 77.68.122.124 应该 == 77.68.123.127/davical == cal.oneasl.com,但它没有加载任何东西...?

如果我忽略了一些明显的事情,非常感谢和抱歉。也很抱歉无偿使用代码标记,但没有它我无法发布!

000-default.conf;

<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.

ServerName www.oneasl.com
ServerAdmin webmaster@oneasl.com
DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>

<VirtualHost 77.68.122.124:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless. 
# However, you must set it for any further virtual host explicitly.

ServerName cal.oneasl.com 
ServerAdmin admin@oneasl.com  
DocumentRoot /usr/share/davical/htdocs                      
</VirtualHost>                                                            

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

davical.conf:

# DAViCal Calendar Server

Alias /davical /usr/share/davical/htdocs
<Directory /usr/share/davical/htdocs>
DirectoryIndex index.php 
AllowOverride None
# for Apache from 2.4 use
Require all granted
# for Apache before 2.4 use 
#Order allow,deny
#Allow from all

# These are usually not necessary (set correctly by default)
#AcceptPathInfo On
#php_value include_path /usr/share/php/awl/inc
#php_value magic_quotes_gpc 0
#php_value register_globals 0
#php_value error_reporting "E_ALL & ~E_NOTICE"
#php_value default_charset "utf-8"

# Some people want this. YMMV.
#php_admin_value open_basedir
/usr/share/awl/inc/:/usr/share/davical/:/etc/davical/
</Directory>

<IfModule mod_rewrite.c>
RewriteEngine On

# PT is important if you are using an alias, it implies L
# Redirect /.well-known URLs
RewriteRule ^/\.well-known/(.*)$ /davical/caldav.php/.well-known/$1 [NC,PT]
# Optionally: redirect /principals/users/ as well
RewriteRule ^/principals/users/(.*)$ /davical/caldav.php/$1 [NC,PT]
RewriteRule ^/principals/resources/(.*)$ /davical/caldav.php/$1 [NC,PT]
RewriteRule ^/calendars/__uids__/(.*)$ /davical/caldav.php/$1 [NC,PT]
RewriteRule ^/addressbooks/__uids__/(.*)$ /davical/caldav.php/$1 [NC,PT]

# Optionally: Put DAViCal in the root
# NOTE: this will break other applications that rely on mod_rewrite!
#
# Not if it's the root URL.  You might want to comment this out if you
# want to use an explicit /index.php for getting to the admin pages.
#RewriteCond %{REQUEST_URI} !^/$
#RewriteCond %{REQUEST_URI} !^/davical/$
#
# Not if it explicitly specifies a .php program, html page, stylesheet or image
#RewriteCond %{REQUEST_URI} !\.(php|html|css|js|png|gif|jpg|ico)
#
# Everything else gets rewritten to /caldav.php/...
#RewriteRule ^(.*)$ /davical/caldav.php$1  [NC,L]
</IfModule>

'root@asl1:/etc/php/7.2/apache2# apache2ctl -S' 的输出:

VirtualHost configuration:
77.68.122.124:80       cal.oneasl.com (/etc/apache2/sites-enabled/000-default.conf:32)
*:80                   www.oneasl.com (/etc/apache2/sites-enabled/000-default.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex default: dir="/var/run/apache2/" mechanism=default
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

【问题讨论】:

  • 您是否启用了该网站? sudo a2ensite davical.conf 然后sudo service apache2 reload ?
  • 恐怕...很多很多次

标签: linux apache2 virtualhost


【解决方案1】:

似乎没有在服务器上正确配置辅助 IP。 同时能够在主服务器 ip www.oneasl.com 上远程登录

telnet oneasl.com 80
Trying 77.68.123.127...
Connected to oneasl.com.
Escape character is '^]'.
^]
telnet>

无法在辅助服务器 ip cal.oneasl.com 上远程登录

 telnet cal.oneasl.com  80
 Trying 77.68.122.124...

【讨论】:

  • 嗯 - 累了不要发帖,但谢谢。仍然不确定这是为什么。我在上面进行了编辑以反映实际的 ip 条目 - 我错过了什么?我将转给我的托管公司,看看他们是否可以进行调查另外感谢您提醒我远程登录访问 - 一旦它不能用作调试步骤,我将关闭它!
  • 这个回复让我聘请了 sahil on upwork,在那里他迅速解决了界面设置中的问题
猜你喜欢
  • 1970-01-01
  • 2017-11-12
  • 2016-02-23
  • 1970-01-01
  • 2015-08-03
  • 2020-12-21
  • 2016-08-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多