我刚刚通过 Apache 服务器和 word-press 创建了一个网站。当我连接到本地网络时,我可以访问它。虽然我已经对路由器进行了端口转发设置,但通过 ufw,我无法从其他网络访问它。我正在使用“public_ip”/site1(当我来自本地 192.168.xx 时),但我收到 403 禁止访问。如果我不使用 /site1,我得到的页面显示 Apache 工作正常,我想这意味着我的端口转发工作正常。所以我相信它与 word-press 设置或 /var/www/html/site1 权限有关。这是 ls -l /var/www/html/site1 输出:除了 wp-admin、wp-content、wp-includes 之外,所有内容都是 -rwxr-xr-x,它们是 drwxr-xr-x 提前感谢大家编辑:虚拟主机 conf 文件是 apache 默认值(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.example.com
ServerAdmin webmaster@localhost
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>