I have come across a problem with the app.yaml setup for the installation of wordpress in GAE following this guide: https://developers.google.com/appengine/articles/wordpress
Using the guide, I copied the app.yaml (I also used the github project: https://github.com/GoogleCloudPlatform/appengine-php-wordpress-starter-project to check that my copy/paste was ok).
Whilst the test using dev_appserver.py works fine, the upload whinges with the message:
03:08 PM Getting current resource limits.
03:08 PM Scanning files on local disk.
03:08 PM Scanned 500 files.
03:08 PM Scanned 1000 files.
Error 400: --- begin server output ---
Error when loading application configuration:
Unable to assign value '__static__/wordpress/.*\.(htm|html|css|js)$' to attribute 'upload':
Value '__static__/wordpress/.*\.(htm|html|css|js)$' for upload does not match expression '^(?:(?!\^).*(?!\$).)$'
--- end server output ---
I am using the PHP SDK v1.8.9. My app.yaml is as follows:
application: blah-de-blah
version: wp
runtime: php
api_version: 1
handlers:
- url: /(.*\.(htm|html|css|js))$
static_files: wordpress/\1
upload: wordpress/.*\.(htm|html|css|js)$
application_readable: true
- url: /wp-content/(.*\.(ico|jpg|png|gif))$
static_files: wordpress/wp-content/\1
upload: wordpress/wp-content/.*\.(ico|jpg|png|gif)$
application_readable: true
- url: /(.*\.(ico|jpg|png|gif))$
static_files: wordpress/\1
upload: wordpress/.*\.(ico|jpg|png|gif)$
- url: /wp-admin/(.+)
script: wordpress/wp-admin/\1
secure: always
- url: /wp-admin/
script: wordpress/wp-admin/index.php
secure: always
- url: /wp-login.php
script: wordpress/wp-login.php
secure: always
- url: /wp-cron.php
script: wordpress/wp-cron.php
login: admin
- url: /xmlrpc.php
script: wordpress/xmlrpc.php
- url: /wp-(.+).php
script: wordpress/wp-\1.php
- url: /(.+)?/?
script: wordpress/index.php
Something is up with the file type selector regex, but I'm not sure how to fix it. Someone came across it here: Google App Engine and Wordpress set up error - Windows 7 professional but it's still not fixed.
Does anyone have any light to shed on the subject?
Ok - I fixed it. The app.yaml needed modifying.
I think the instructions on the guide are a bit misleading - maybe something is out of date?
Here is my fixed app.yaml:
application: pooper-scooper-117
version: wp
runtime: php
api_version: 1
handlers:
- url: /(.*\.(htm$|html$|css$|js$))
static_files: wordpress/\1
upload: wordpress/.*\.(htm$|html$|css$|js$)
application_readable: true
- url: /wp-content/(.*\.(ico$|jpg$|png$|gif$))
static_files: wordpress/wp-content/\1
upload: wordpress/wp-content/.*\.(ico$|jpg$|png$|gif$)
application_readable: true
- url: /(.*\.(ico$|jpg$|png$|gif$))
static_files: wordpress/\1
upload: wordpress/.*\.(ico$|jpg$|png$|gif$)
- url: /wp-admin/(.+)
script: wordpress/wp-admin/\1
secure: always
- url: /wp-admin/
script: wordpress/wp-admin/index.php
secure: always
- url: /wp-login.php
script: wordpress/wp-login.php
secure: always
- url: /wp-cron.php
script: wordpress/wp-cron.php
login: admin
- url: /xmlrpc.php
script: wordpress/xmlrpc.php
- url: /wp-(.+).php
script: wordpress/wp-\1.php
- url: /(.+)?/?
script: wordpress/index.php
you shouldn't have to modify the app.yaml or submit a pull request(unless it's to change the documentation). Instead you need to get the latest version of the appengine SDK for PHP. As of mid January older versions won't work.
Related
Can I use this for uploading HTML pages?
app.yaml contents:
application: visualvidya
version: 1
runtime: python
api_version: 1
handlers:
- url: /(.*\.(gif|png|jpg|ico|js|css))
static_files: \1
upload: (.*\.(gif|png|jpg|ico|js|css))
A minimal handlers section for a static site might look something like this:
handlers:
- url: /
static_files: static/index.html
upload: static/index.html
- url: /
static_dir: static
Every site is different, so as Sean pointed out in the comments, you'll want to consult the documentation.
I'd like to run a function server side using a Python file on my Google App Engine application with this Ajax call.
function test(){
request = $.ajax({
url: "test.py?some_vars...",
type: "get",
});
request.done(function (response, textStatus, jqXHR){
console.log(response);
});
}
When I run test() the console logs a 404 error, "test.py not found". I've also tried "localhost:8080/test.py" locally and "http://APP.appspot.com/test.py" on the actual server.
I get a response when I try an external file like "http://graph.facebook.com/steve", but I can't get anything from local files.
Here is my app.yaml
application: APP
version: 1
runtime: python27
threadsafe: true
api_version: 1
handlers:
- url: /images
static_dir: images
- url: /js
static_dir: js
- url: /css
static_dir: css
- url: /.*
script: apprtc.app
secure: always
- url: /python
script: test.app
inbound_services:
- channel_presence
libraries:
- name: jinja2
version: latest
Thanks for reading
You need to set up a handler in app.yaml that maps to your test.py.
You'll need a route that looks something like...
- url: /test.py
script: test.app
I'm migrating my gae app to python 2.7. This is my new app.yaml:
application: webfaze
version: main
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /mapreduce(/.*)?
script: mapreduce/main.application
- url: /(.*\.(html|css|js|gif|jpg|png|ico|swf))
static_files: static/\1
upload: static/.*
expiration: "1d"
- url: .*
script: main.application
- url: /task/.*
script: main.application
login: admin
But I get this error message:
Error parsing yaml file:
Invalid object:
threadsafe cannot be enabled with CGI handler: mapreduce/main.application
in "webfaze/app.yaml", line 22, column 1
Can you tell me how to resolve the error?
Checking the source code, it looks that you need to define your handlers' path without any slash:
if (handler.script and (handler.script.endswith('.py') or
'/' in handler.script)):
raise appinfo_errors.ThreadsafeWithCgiHandler(
'threadsafe cannot be enabled with CGI handler: %s' %
handler.script)
Move application.py to the root of your project and modify the handler's path accordingly.
Change:
- url: /mapreduce(/.*)?
script: mapreduce/main.application
To:
- url: /mapreduce(/.*)?
script: mapreduce.main.application
You may also need to add an __init__.py to the 'mapreduce' folder if one doesn't exist there already. That will make the python interpret the folder as a module.
When updating my app into GAE by using the following command:
python appcfg.py update /home/tom/workspace/DjangoProject
I got an error message:
mapping values are not allowed here
in "/home/tom/workspace/DjangoProject/app.yaml", line 6, column 9
Here is my yaml:
application:myapp
version:1
runtime:python
api_version:1
handlers:
- url:/
script:home.py
- url:/index\.html
script: home.py
- url: /stylesheets
static_dir: stylesheets
- url: /(.*\.(gif|png|jpg))
static_files: static/\1
upload: static/(.*\.(gif|png|jpg))
- url: /admin/.*
script: admin.py
login: admin
- url: /.*
script: not_found.py
Can anybody help me?
I changed my yaml:
application:myapp
version:1
runtime:python
api_version:1
handlers
- url:/
script:home.py
- url:/index\.html
script:home.py
- url:/stylesheets
static_dir:stylesheets
- url:/(.*\.(gif|png|jpg))
static_files:static/\1
upload:static/(.*\.(gif|png|jpg))
- url:/admin/.*
script:admin.py
login:admin
- url:/.*
script:not_found.py
Now the error meesage is :
google.appengine.api.appinfo_errors.MissingURLMapping: No URLMap entries found in application configuration
After a colon , there has to be space . That's why it was not able to parse your app.yaml.
Try this
application: myapp
version: 1
runtime: python
api_version: 1
handlers:
- url: /
script: home.py
- url: /index\.html
script: home.py
- url: /stylesheets
static_dir: stylesheets
- url: /(.*\.(gif|png|jpg))
static_files: static/\1
upload: static/(.*\.(gif|png|jpg))
- url: /admin/.*
script: admin.py
login: admin
- url: /.*
script: not_found.py
I get this strange message error when trying to run an app using dev_appserver.py:
ERROR 2011-04-21 23:03:44,984 dev_appserver_main.py:407] Fatal error when loading
application configuration:
Value 'warmup' for key ??? does not match expression '^(mail|xmpp_message|rest|startup)$'
in "stackprinter/app.yaml", line 53, column 1
I have no idea what may be causing this, I hope someone is able to at least guide me in the right direction!
EDIT: Content of the app.yaml:
application: foo
version: 1b
runtime: python
api_version: 1
builtins:
- datastore_admin: on
inbound_services:
- warmup
handlers:
- url: /test.*
login: admin
script: gaeunit.py
- url: /favicon.ico
static_files: app/static/images/favicon.ico
upload: app/static/images/favicon.ico
- url: /robots.txt
static_files: app/static/docs/robots.txt
upload: app/static/docs/robots.txt
- url: /crossdomain.xml
static_files: app/static/docs/crossdomain.xml
upload: app/static/docs/crossdomain.xml
- url: /sitemap.xml
static_files: app/static/docs/sitemap.xml
upload: app/static/docs/sitemap.xml
- url: /javascripts
static_dir: app/static/javascripts
- url: /stylesheets
static_dir: app/static/stylesheets
- url: /images
static_dir: app/static/images
- url: /docs
static_dir: app/static/docs
- url: /deleted
static_dir: app/static/deleted
- url: /_ah/queue/deferred
script: $PYTHON_LIB/google/appengine/ext/deferred/handler.py
login: admin
- url: /_ereporter
script: $PYTHON_LIB/google/appengine/ext/ereporter/report_generator.py
login: admin
- url: /admin.*
script: application.py
login: admin
- url: /_ah/warmup
script: application.py
login: admin
- url: /.*
script: application.py
Thanks!
Solved!
The problem was that i had an old GAE SDK, Warmup requests were added in the 1.4.0 version.
Cheers