Apache 服务器在不同端口上为 WordPress 和普通站点提供服务

发布于 2025-01-20 15:30:19 字数 1565 浏览 1 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

梦幻的心爱 2025-01-27 15:30:19

我建议检查您的 WordPress 的站点/主页 URL。确保更改站点/主页 URL 以匹配端口,例如,如果您的 URL 当前为“http://localhost”(默认为 80 HTTP 端口),那么当您尝试访问时看到重定向发生绝对是正常行为访问“http://localhost:81”。

请尝试在 WordPress URL 末尾添加“:81”,看看效果如何。

I would recommend checking the Site/Home URL of your WordPress. Make sure to change the Site/Home URLs to match the port, for example, if your URL is currently "http://localhost" ( 80 HTTP port by default ) it is absolutely normal behavior to see a redirection occur when you attempt to visit "http://localhost:81".

Please try adding ":81" at the end of your WordPress URL and see how it goes.

夏至、离别 2025-01-27 15:30:19

我不知道它是如何工作的,但它确实有效。我删除了所做的所有更改,然后重新开始。
现在我没有触及 000-default.conf 文件,我只是添加了 wordpress.conf 文件并在其中编写了下面提到的 vhost 代码。

Listen 81

<VirtualHost *:81>

        ServerAdmin webmaster@localhost
        DocumentRoot /srv/wordpress
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

让我通过运行 $apache2ctl configtest 命令来测试 Apache 语法,它显示 syntax ok
然后我通过运行 $service apache2 reload 重新加载 apache 服务器;

最后,我打开 172.20.xy:81,上面写着“您无权访问”,此时我取消了 apache2.conf 文件上的某些代码部分的注释在/etc/apache2/。
就像

# <Directory /srv/>
#        Options Indexes FollowSymLinks
#        AllowOverride None
#        Require all granted
# </Directory>

更改为

<Directory /srv/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

再次重新加载 Apache 服务器一样。最后,它可以正常工作了。

I do not know how it works, but it works. I erased all the changes I had made and started doing it all over again.
Now I did not touch the 000-default.conf file, I just added the wordpress.conf file and wrote vhost code mentioned below in it.

Listen 81

<VirtualHost *:81>

        ServerAdmin webmaster@localhost
        DocumentRoot /srv/wordpress
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Let me test the Apache syntax by running the $apache2ctl configtest command, it shows syntax ok.
Then I reload the apache server by running $service apache2 reload;

Finally, I open 172.20.x.y:81, which says "You do not have permission to access", At which point I uncommnent some parts of code on apache2.conf file at /etc/apache2/.
It was like

# <Directory /srv/>
#        Options Indexes FollowSymLinks
#        AllowOverride None
#        Require all granted
# </Directory>

Changed to

<Directory /srv/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

Again I reload the Apache server. Finally, it works properly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文