没有 MAMP,无法在 OS X 上本地安装 Wordpress

Cannot install Wordpress locally on OS X without MAMP

我先学习优秀教程here then here。我认为我成功完成了大部分步骤,因为在将浏览器指向 http://localhost 时我得到了 Apache "It works"。

我按照教程中的建议对文件 /private/etc/apache2/httpd.conf/private/etc/apache2/extra/httpd-vhosts.conf 进行了修改(基本上告诉 Apache 使用 libphp7.so 而不是拒绝对文件系统的访问)。

我的 httpd-vhosts.conf 看起来像这样:

<Directory "/www">
  Options Indexes MultiViews FollowSymLinks
  AllowOverride All
  Require all granted
</Directory>

<Virtualhost *:80>
  VirtualDocumentRoot "/www/sites/%1/wwwroot"
  ServerName sites.test
  ServerAlias *.test
  UseCanonicalName Off
</Virtualhost>

<Virtualhost *:80>
  VirtualDocumentRoot "/www/sites/%-7+/wwwroot"
  ServerName xip
  ServerAlias *.xip.io
  UseCanonicalName Off
</Virtualhost>

我在 / 层的顶层有一个 www 目录:

/www
├── home
└── sites
    ├── client1
    │   ├── assets
    │   └── wwwroot
    │       └── index.html
    ├── wordpress

当我在浏览器地址栏中输入 client1.test 时,它会正确显示 index.html 的内容。

所以下一步是在 sites 中创建一个子目录 wordpress 并将最新的 wp 版本下载并解压缩到该目录中。

2nd tutorial 中显示 "At this point you should be able to hit wordpress.test in your browser and start the WordPress installation process."

嗯,这对我不起作用:我收到“404 未找到”消息。我的权限如下所示:

drwxr-xrwx    5 root      wheel     160 Jun 19 12:39 client1
drwxrwxrwx   23 _www      wheel     736 Jun 19 15:34 wordpress

我注意到与 client1 子目录不同,wordpress 不包含 wwwroot 子目录。但我想这在这里不重要?我期待在输入 wordpress.test.

时开始一些安装步骤

有人知道我收到 404 消息的可能原因吗?我在 High Sierra 10.13.5.

经过大量挖掘,我找到了答案。

@Devon 是正确的,我应该将 WordPress 文件(即从 WP 站点下载、解压缩并添加)添加到子目录 wwwroot.

下一个错误是 Error establishing database connection,显然我一直使用的 mysql 版本有问题。我一直在使用 MySQL Community Server 8.0.11。但是根据一个不相关项目的 this post,mysql 的 v8.0.11 与 php 7.1.

有问题

我完全uninstalled/deleted mysql v8.0.11然后做了brew install mysql@5.7.

安装 v5.7 后,我登录 mysql(以 root 用户身份),然后 运行:

mysql> create database wordpress_db;
mysql> exit

我没有创建额外的用户或指定权限;就是这样。当我现在在浏览器中打开 wordpress.test 时,安装脚本按预期运行。