I'm building my first app using Google App Engine and have hit a problem straight off: My images and css are not loading with the error: Failed to load resource: the server responded with a status of 404 (Not Found). I have done all I can think of to try and tackle it, and now I'm stumped. Here's my code:
PHP:
<?php
echo "<html><header><link rel='stylesheet' type='text/css' href='/stylesheets/style.css'></header>
<body>
<div class=header><img src='/images/logo.png'>
</div><div class=main>hello</div>
</body></html>";
?>
app.yaml:
application: phpunionapp
version: 1
runtime: php
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /images
static_dir: static/images
- url: .*
script: main.php
- url: /stylesheets
static_dir: stylesheets
Directory Structure:
phpunionapp\images\logo.png
phpunionapp\stylesheets\style.css
And the log:
2013-10-13 16:53:01 Running command: "[u'C:\\Python27\\pythonw.exe', 'C:\\Program Files (x86)\\Google\\google_appengine\\dev_appserver.py', '--skip_sdk_update_check=yes', '--port=10080', '--admin_port=8002', u'C:\\Users\\User\\Documents\\Web Development\\Tests\\phpunionapp']"
INFO 2013-10-13 16:53:03,480 devappserver2.py:660] Skipping SDK update check.
INFO 2013-10-13 16:53:03,520 api_server.py:138] Starting API server at: http://localhost:54192
INFO 2013-10-13 16:53:03,523 dispatcher.py:168] Starting module "default" running at: http://localhost:10080
INFO 2013-10-13 16:53:03,526 admin_server.py:117] Starting admin server at: http://localhost:8002
INFO 2013-10-13 16:53:11,661 module.py:599] default: "GET / HTTP/1.1" 200 191
INFO 2013-10-13 16:53:11,713 module.py:599] default: "GET /images/logo.png HTTP/1.1" 404 -
INFO 2013-10-13 16:53:11,844 module.py:599] default: "GET /stylesheets/style.css HTTP/1.1" 200 191
The 404 in the browser:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:10080/images/logo.png
I am honestly not sure why the app cannot find the images, any help would be very much appreciated! Thanks in advance.
In your app.yaml, change static_dir: static/images to static_dir: images.
I got there by noticing in the logs that the stylesheet was getting served, but the image wasn't. That led back to a difference in app.yaml that I'd missed on first look.
Related
I have a simple login script that checks mysql for authentication of the user and then redirects to the start page of the application using the php 'header' function.
if (mysqli_num_rows($dbq)==1) {
header("Location: header.html");
}
where header.html is in the same directory as index.php, but it seems to ignore this completely. The log simply says;
INFO 2016-03-22 13:36:48,421 module.py:787] default: "POST /index.php HTTP/1.1" 200 301
INFO 2016-03-22 13:36:48,517 module.py:787] default: "GET /favicon.ico HTTP/1.1" 200 301
Here is some more info - if I put
- url: /.*
script: index.php
I get the http status of 301, but if I remove this handler the redirection works.
Here is current app.yaml file;
application: crm
version: 1
runtime: php55
api_version: 1
threadsafe: yes
handlers:
# Serve php scripts.
#- url: /.*
# script: index.php
#- url: /.*
# script: header.html
- url: /(.+\.php)$
script: \1
- url: /(.+\.html)$
script: \1
# Serve images as static resources.
- url: /(.+\.(gif|png|jpg))$
static_files: \1
upload: .+\.(gif|png|jpg)$
application_readable: true
I am trying to upload this as my app.yaml
application: *******
version: 2
runtime: php55
api_version: 1
threadsafe: yes
instance_class: F2
automatic_scaling:
min_idle_instances: 1
max_idle_instances: 5
min_pending_latency: 5.0s
max_pending_latency: 7.7s
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /resources
static_dir: resources
- url: /static
static_dir: static
- url: /test.php
script: test.php
- url: .*
script: home/service/index.php
How ever every time I do upload it, it says I am using custom peformance settings and to look at the application section. This is the exact error I get Your application currently has custom performance settings that are not compatible with the Modules feature. You must either clear or migrate these application-level settings before you can upload a non-default module. See the Performance section of the Application Settings page of the Admin Console for more information.
So I looked at the migrate to app section and here is what it says.
application: ********
# Other settings here...
instance_class: F2
automatic_scaling:
min_idle_instances: 1
max_idle_instances: 5
min_pending_latency: 5.0s
max_pending_latency: 7.7s
I've followed the guides as close as possible, I am not sure what is wrong with my app.yaml? I have removed all the other .yaml files (I had a pdf.yaml [module] and a dispatch.yaml) it all booted up fine on the local dev machine but when I call appcfg.py update app.yaml - I just get told of my issue with custom performance settings, any help would be much appreciated
It's funny every time I post to Stackoverflow, I always find a solution soon after (I've been trying to solve this issue for days btw)
You have to set all the application settings to Automatic on the Old-Settings page, and suddenly modules work.
Cheers
Trying to get joomla working locally and ran into an issue with the Administror page. I have this error,
home page of site works - www.my-site.index.php
but with admin I find the following error - www.my-site/administrator.index.php
Warning: require(/Users/RichardClark/Sites/demo-test2/joomla/administrator): failed to open stream: No such file or directory in /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/php/setup.php on line 115
Fatal error: require(): Failed opening required '/Users/RichardClark/Sites/demo-test2/joomla/administrator' (include_path='/Users/RichardClark/Sites/demo-test2:/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/php/sdk') in /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/php/setup.php on line 115
I get the impressions joomla and google app engine aren't very compatible. I am really struggling to debug this. My app.yaml file is as follows;
application: fit-rig-517
version: 1
runtime: php
api_version: 1
handlers:
- url: /joomla/(.*\.(htm$|html$|css$|js$))
static_files: joomla/\1
upload: joomla/(.*\.(htm$|html$|css$|js$))
application_readable: true
## Admin
- url: /administrator(.+)
script: joomla/administrator\1
## Asset folders
- url: /media
static_dir: joomla/media
application_readable: true
mime_type: text/html
- url: /images
static_dir: joomla/images
application_readable: true
## Template folders
- url: /templates
static_dir: joomla/templates
application_readable: true
mime_type: application/(htm$|html$|css$|js$)
- url: /administrator/templates
static_dir: joomla/administrator/templates
application_readable: true
mime_type: text/html
## SEO robots
- url: /robots.txt
script: joomla/robots.txt
## Site access
- url: /(.+)?/?
script: joomla/index.php
thanks
App Engine does not have the concept of a default script (e.g. index.php) for directory access. Instead, it relies on the following rule in your app.yaml to locate the php script.
## Admin
- url: /administrator(.+)
script: joomla/administrator\1
Use /administrator/index.php to access your admin page instead.
I developed a web application the usual way and hosted on a normal shared server.
These are what I mean by usual
Include my PHP function files (using php include/require)
Use my normal MySQL database with msqli
Upload my files normally to the server using FTP.
For some reasons, I need to move the web app to appengine, I have succeeded in uploading the files but it shows me this error:
500 Server Error
with this error in my log:
Traceback (most recent call last):
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 239, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 298, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/base/data/home/runtimes/python27/python27_lib/versions/1/google/appengine/runtime/wsgi.py", line 84, in LoadObject
obj = __import__(path[0])
ImportError: No module named index
What changes do I need to make to my files to enable my website work well on appengine without issues?
EDIT (Content of app.yaml)
application: gcdc2013-myworkset
version: 1
runtime: python27
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: index.php
- url: /css
static_dir: stylesheets
- url: /images
static_dir: images
libraries:
- name: webapp2
version: "2.5.2"
I tried changing runtime to php but it gave an error which cleared immediately i changed it back to python27
EDIT:
Updated app.yaml file (Project deploys now but shows this error for all PHP files: Could not guess mimetype for excel/excel_reader.php. Using application/octet-stream.
Also the project appears as blank when viewed on the browser):
application: gcdc2013-myworkset
version: 1
runtime: php
api_version: 1
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: .*
script: index.php
- url: /
script: index.php
- url: /index\.php
script: index.php
- url: /features
script: features/index.php
- url: /about
script: about/index.php
- url: /oauth2callback/?
script: signup.php
- url: (.*)\.[\d]{10}\.(css|js)
static_files: $1.$2
upload: (.*).(.*)
- url: /css
static_dir: css
- url: /js
static_dir: js
Also, how can I import mysql database that I exported from my localhost to the appengine?
Change:
runtime: python27
To:
runtime: php
And remove:
libraries:
- name: webapp2
version: "2.5.2"
See https://developers.google.com/appengine/docs/php/config/appconfig for more information.
I am running Windows 8.1 64 bit on a core I7 laptop. I am running Python 2.7.6 with the GoogleAppEngine-1.8.7 installed. IIS 8.5 is also installed with the PHP manager extension
I have PHP 5.4.10 also installed in the C:\PHP directory
I had already created 3 Wordpress apps locally successfully (about a week ago) and when I ran them in the Google App Engine Launcher Browser everything was fine until 2 days ago.
Now when I start the apps and launch the browser on the locally host on port 8080 I get a blank screen.
This is the contents of the log file:
INFO 2013-11-12 04:31:39,665 dispatcher.py:171] Starting module "default" running at: http://locally host:8080
INFO 2013-11-12 04:31:39,667 admin_server.py:117] Starting admin server at: http://locally host:8000
INFO 2013-11-12 04:31:50,822 module.py:608] default: "GET / HTTP/1.1" 302 -
contents of app.yaml:
application: icefishingco
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
Contents of cron.yaml
cron:
- description: wordpress cron tasks
url: /wp-cron.php
schedule: every 2 hours
contents of my php.ini:
google_app_engine.enable_functions = "php_sapi_name, gc_enabled"
System Environment variable:
Path=C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;c:\php;c:\python27;C:\Program Files (x86)\QuickTime\QTSystem\
What, if anything, am I doing wrong?
The http://locally host:8080 looks fishy in the log. Could you post the extra flags you used for the project as well?