Php 如何将Kalabox与具有嵌套web根目录的WordPress安装一起使用?

Php 如何将Kalabox与具有嵌套web根目录的WordPress安装一起使用?,php,wordpress,docker,nginx,pantheon,Php,Wordpress,Docker,Nginx,Pantheon,一周来,我一直在尝试让Kalabox使用WordPress安装,该安装有一个嵌套的万神网根。我发现了一些很好的资源,但其中很多都是针对Drupal的,它们似乎没有转化为WP安装,就像这里的Tandem的伟大文章: 是否有人有一个快速的演练,这将工作?谢谢 我想出来了!这就是它所需要的: 1.在中设置站点 2.使用将站点克隆到本地计算机 确保您的机器上安装了Kalabox。如果您还没有安装Docker,这也将安装Docker。现在,打开你的终端 mkdir -p ~/Kalabox cd ~/Ka

一周来,我一直在尝试让Kalabox使用WordPress安装,该安装有一个嵌套的万神网根。我发现了一些很好的资源,但其中很多都是针对Drupal的,它们似乎没有转化为WP安装,就像这里的Tandem的伟大文章:


是否有人有一个快速的演练,这将工作?谢谢

我想出来了!这就是它所需要的:

1.在中设置站点 2.使用将站点克隆到本地计算机 确保您的机器上安装了Kalabox。如果您还没有安装Docker,这也将安装Docker。现在,打开你的终端

mkdir -p ~/Kalabox
cd ~/Kalabox
kbox create pantheon
# follow the prompts to clone down your Pantheon site
3.添加您的站点代码 这是真正的工作开始的地方。确保您在主Kalabox目录中。我正在使用优秀的作为这个应用程序的样板。但是你想用什么就用什么

# replace text in < > with your site name
cd ~/Kalabox/<your-site-name>
rm -rf code/

# Clone this or copy your own site code into the code directory
git clone https://github.com/ataylorme/advanced-wordpress-on-pantheon.git code
确保已将代码添加到~/Kalabox//code/目录中

您现在可以访问您的网站:http://.kbox.site 在浏览器上,但如果您有嵌套的web根目录,则可能会看到Nginx 500错误。这就是我们要解决的问题

4.编辑Kalabox设置以允许嵌套的Web根目录 这部分是秘方。我们必须进入Kalabox设置的Docker容器,并更改nginx配置文件。如果你觉得这一切毫无意义,别担心。这些简单的说明应该可以帮助你做到这一点!回到终点站

docker ps
这将转储一个包含正在运行的Docker容器列表的表。在“图像”列下找到显示nginix的图像。在容器ID列中立即向左看。注意,复制和/或写下该容器ID的前四个左右的字母。您将在下一个命令的部分中使用这些字母:

docker exec -i -t <container-id> bash
一旦这些命令完成运行,我们就可以编辑配置文件:

nano /etc/nginx/conf.d/default.conf
这将打开Nano编辑器,其中包含我们尝试编辑的配置文件。查看并更改以下行:

# This one is near the top of the file
# Before
root /code;
# After
root /code/web;

# These next two are near the bottom of the file.
# This exact line appears twice--once in the `location ~ ^/simplesaml/`
# block, and once in the `location ~ \.php$` block. Edit it in
# BOTH locations.
#
# Before
fastcgi_param SCRIPT_FILENAME /code/$fastcgi_script_name;
# After
fastcgi_param SCRIPT_FILENAME /code/web/$fastcgi_script_name;
完成后,键入保存工作并退出。您回到Docker容器的伪shell。键入exit返回正常的命令行

5.重建Kalabox并进行测试! 确保您位于~/Kalabox/目录中,并键入kbox restart以确保已清除Kalabox缓存中的所有内容。Kalabox将为您停止并重新启动您的站点。完成后,请访问http://.kbox.site 在浏览器中查看您的工作

额外的糖果 在您喜爱的编辑器中升级到php7:Open~/Kalabox//Kalabox.yml,并将第33行更改为PHP:70。 删除未定义的索引:NONCE_KEY error:open~/Kalabox//config/php/prepend.php并大致转到第55行,其内容为$_ENV['NONCE_SALT']=getenv'NONCE_SALT';。在下面,添加一行类似的代码:$_ENV['NONCE_KEY']=getenv'NONCE_KEY';
nano /etc/nginx/conf.d/default.conf
# This one is near the top of the file
# Before
root /code;
# After
root /code/web;

# These next two are near the bottom of the file.
# This exact line appears twice--once in the `location ~ ^/simplesaml/`
# block, and once in the `location ~ \.php$` block. Edit it in
# BOTH locations.
#
# Before
fastcgi_param SCRIPT_FILENAME /code/$fastcgi_script_name;
# After
fastcgi_param SCRIPT_FILENAME /code/web/$fastcgi_script_name;