【发布时间】:2019-05-19 06:59:38
【问题描述】:
我在 App Engine 上有一个非常基本的应用程序,使用 PHP 7.2 设置。
在official documentation of installing WP on GAE PHP 7.2 中,他们编写了一个复制 WordPress 文件的脚本,然后你提交并部署它们。
此作曲家配置使用johnpbloch/wordpress 和composer/installers,将WordPress 下载并安装到composer install 上的wp 文件夹,因此我不必提交或部署此代码。
composer.json 文件:
{
"require": {
"php": ">=7.2",
"ext-phar": "*",
"ext-zip": "*",
"paragonie/random_compat": "^1.3",
"symfony/console": "^3.0",
"google/cloud-tools": "^0.8.5",
"johnpbloch/wordpress": "^5.0.1",
"vlucas/phpdotenv": "^2.5",
"composer/installers": "^1.6"
},
"require-dev": {
"phpunit/phpunit": "^5"
},
"extra": {
"installer-paths": {
"wp/wp-content/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
"wp/wp-content/plugins/{$name}/": ["type:wordpress-plugin"],
"wp/wp-content/themes/{$name}/": ["type:wordpress-theme"]
},
"wordpress-install-dir": "wp"
}
}
.gcloudignore文件:
.gcloudignore
# Git
.git
.gitignore
# PHP Composer dependencies
vendor
wp
和app.yaml 文件:
runtime: php72
handlers:
- url: /(.*\.(gif|png|jpg|htm|html|css|js))$
static_files: wp/\1
upload: wp/.*\.(gif|png|jpg|htm|html|css|js)$
因此,GAE 成功部署并构建了项目。
默认处理程序 (index.php) 似乎可以访问 vendor 文件夹,例如当写require __DIR__.'/wp/index.php' 时,它可以工作。
但它不会提供静态文件。转到像 <project>.appspot.com/wp-includes/images/media/audio.png 这样的 URL 会返回 404。
有什么想法吗?
【问题讨论】:
标签: wordpress google-app-engine composer-php php-7.2 appengine-wordpress