我对托管自己的服务器还很陌生。我正在遵循本教程:https://www.answertopia.com/ubuntu/setting-up-an-ubuntu-web-server/我已经进入标题为“1.7 为您的域配置 Apache Web 服务器”的部分。我已遵循所有步骤,但当我进入测试配置的部分时,它会抛出一个错误,因为它无法使用 ip 127.0.1.1。我通过添加ServerName 127.0.0.1
到 /etc/apache2/apache2.conf 清除了错误,但当我转到域名时,网页仍然没有显示,如果我转到 ip 地址,则只显示默认页面。我假设ServerName
apache2.conf 中的命令是导致我遇到问题的原因,但也许还有其他原因?
如果有帮助,我通过谷歌域名购买了我的域名。
编辑:我正在使用 ubuntu 服务器 23.04
这是 /etc/apache/sites-available/diyserv.net.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.diyserv.net
ServerAdmin [email protected]
DocumentRoot /var/www/diyserv.net
# 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>
编辑:我编辑了路由器设置并设置了端口转发,并向 Google 域添加了 A 记录,现在我可以从同一网络上的设备访问网页www.diyserv.net,但不是来自不同网络上的设备。希望这只是需要等待 DNS 记录传播的情况