Reputation: 332
I have a very basic application on App Engine, set up with PHP 7.2.
In the official documentation of installing WP on GAE PHP 7.2, they wrote a script that copies WordPress files, and then you commit and deploy them.
This composer configuration uses johnpbloch/wordpress
together with composer/installers
, to download and install WordPress to wp
folder upon composer install
, so I don't have to commit nor deploy this code.
The composer.json
file:
{
"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
file:
.gcloudignore
# Git
.git
.gitignore
# PHP Composer dependencies
vendor
wp
and app.yaml
file:
runtime: php72
handlers:
- url: /(.*\.(gif|png|jpg|htm|html|css|js))$
static_files: wp/\1
upload: wp/.*\.(gif|png|jpg|htm|html|css|js)$
So, GAE successfully deploys and builds the project.
The default handler (index.php
) seems to have access to vendor
folder, e.g. when writing require __DIR__.'/wp/index.php'
it works.
BUT it will not serve the static files. Going to a URL like <project>.appspot.com/wp-includes/images/media/audio.png
returns 404.
Any ideas?
Upvotes: 2
Views: 591
Reputation: 332
As of January 2019, there is no such option in Google App Engine PHP 7 Standard.
statically serve
only files you directly deploy.statically serve
any files installed by composer.By statically serve
, I mean to use static_dir
or static_files
handlers in your app.yaml
(read more).
This information is from a discussion with a Google Support representative.
I am waiting on the Support Team to create a feature request, and will attach the link here.
Upvotes: 2
Reputation: 11360
The way your app.yaml
is set up, a call to <project>.appspot.com/wp-includes/images/media/audio.png
will try to upload from the directory:
/wp/wp-includes/images/media/audio.png
Is that the way your files are nested? Is the wp
directory at the root of your project?
Upvotes: 0
Reputation: 481
Your app.yaml is referencing wp/
directory whereas your URL is looking for wp-includes/
directory. See the documentation of static_files for details.
Upvotes: 0