gpt4 book ai didi

mysql - Wordpress MU+MAMP 建立数据库连接时出错

转载 作者:行者123 更新时间:2023-11-29 14:09:38 28 4
gpt4 key购买 nike

我正在尝试为 Wordpress MU 站点设置本地环境。

当我尝试使用默认的 apache/mysql 端口时。我收到错误

Error establishing database connection

当我尝试使用 MAMP 默认端口时,我必须在 header 中指定端口: http://dev.iris.se:8888/

在这种情况下,我会收到 Wordpress 错误

Multisite only works without the port number in the URL.

仅当在 wp-config 中输入正确的数据库设置时才会显示此信息,表明已建立与数据库的连接。

我尝试在端口 80(默认 apache)上运行,在端口 mySQL 上运行 8889(默认 MAMP)。我还尝试在配置文件中指定mamp端口:

localhost:8889
127.0.0.1:8889

有人不知道为什么我可以连接到数据库吗?有没有一种方法可以在端口 8888 上运行网站,而无需在浏览器中指定它?

最佳答案

我的 MAMP 计算机上运行着多个网站,并且发现使用默认 Apache 和 MAMP 设置最简单。

并且您不想通过配置文件以这种方式指定 MAMP 移植,而是修改主 Macintosh 计算机上的/etc/hosts 文件。您不应修改 fe80::1%lo0 localhost 之外的任何内容,因为这会扰乱计算机上读取主机的方式。您在该行下方键入新的虚拟主机,/etc/hosts 文件看起来与此类似:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 localhost
127.0.0.1 examplesite.local

您可以根据需要命名 examplesite.local,这是将在浏览器中显示您的网站的 URL。将这些更改保存到/etc/hosts 文件中,然后转到 Apache 文件夹中的 httpd.conf(该文件的位置位于 Applications/MAMP/conf/apache/httpd.conf 中)。然后,使用如下代码将虚拟主机添加到文件底部,再次将名称 examplesite.local 修改为您希望 URL 在浏览器中显示的任何内容:

NameVirtualHost *
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *>
DocumentRoot "/Applications/MAMP/htdocs/examplesitename"
ServerName examplesite.local
</VirtualHost>

对 httpd.conf 文件进行这些更改后,请确保重新启动 MAMP,因为 Apache 服务器需要使这些更改生效。

这是我使用的网站,因为我忘记了命令行来编辑/etc/hosts 文件以及我向您提供的更详细的步骤: http://sawmac.com/mamp/virtual/

以下是 Macintosh 上的原始/etc/hosts 文件的样子,以防您丢失它: http://thecoredump.org/2011/09/editing-the-hosts-file-in-mac-os-x-lion/

此外,请确保您在 MAMP 上运行的每个网站都有单独的数据库、数据库用户以及 htdocs 文件夹中的文件夹。

希望这可以帮助您入门并运行!

关于mysql - Wordpress MU+MAMP 建立数据库连接时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13723657/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com