I am using Google App Engine for the first time. I am trying to upload a CodeIgniter website, but the problem is no links in the website is working. Every link, even the css and js are going to the index page.
Here is my app.yaml:
application: vatiali-dev
version: 1
runtime: php
api_version: 1
threadsafe: false
handlers:
- url: /css
static_dir: css/
- url: /js
static_dir: js/
- url: /fonts
static_dir: fonts/
- url: /.*
script: index.php
You should change your app.yaml to look like this:
application: vatiali-dev
version: 1
runtime: php
api_version: 1
threadsafe: true
handlers:
- url: /css/*
static_dir: css
- url: /js/*
static_dir: js
- url: /fonts/*
static_dir: fonts
- url: /.*
script: index.php
I have also changed threadsafe to true, unless you had it set to false for a specific reason I believe it is best practice/standard to set it to true, or else you may get performance issues.
Related
I'm deploying a php app to GCP's app engine and can't make the app.yaml configuration work.
The app has this directory structure:
index.php
/sistema
/js
/images
/css
index.php
login.php
otherpage.php
...
I'm having problems with the pages that are under the 'sistemas' folder. And also would like to access those pages without the '.php' in the url.
I've tried with many handlers, but none of them worked as I wanted.
runtime: php55
threadsafe: yes
api_version: 1
handlers:
- url: /sistema/css/*
static_dir: sistema/css
- url: /sistema/js/*
static_dir: sistema/js
- url: /sistema/fonts/*
static_dir: sistema/fonts
- url: /sistema/images/*
static_dir: sistema/images
# Serve php scripts.
- url: /(.+\.php)$
script: \1
- url: /
script: index.php
I've a simple folder structure,
main
|__core
|__start.php
|__bootstrap.php
js
|__file.js
css
|__file.css
index.php
Now, this file.js makes xhr request to start.php for which I'm getting a 500 error.
This is my app.yaml:
runtime: php55
api_version: 1
handlers:
- url: /
script: index.php
- url: /js
static_dir: js
- url: /css
static_dir: css
Now I'm not sure if I'm also suppose to do this:
- url: /main/core/.*
script: start.php
Which, by the way, doesn't seem entirely legit to me.
I created a PHP web app which runs fine in localhost, but it is incorrectly formatted when I run it through GAE development server.
Do you have any idea why?
Correct format:
Incorrect format:
app.yaml:
runtime: php55
api_version: 1
handlers:
- url: /.*
script: index.php
You have to specify handlers for your static files so that they get uploaded with your deployed app:
runtime: php55
api_version: 1
handlers:
- url: /images
static_dir: images
- url: /css
static_dir: css
# Catch all handler for any other requests:
- url: /.*
script: index.php
Read more about using the static_dir or static_files options.
My GAE PHP .yaml file works locally but not when deployed. Everything worked fine up until I reorganized the folders my .php scripts were contained in. There is a php folder in the root of the app and the .php further organized into folders.
Current YAML file:
application: raven3mil
version: 1
runtime: php
api_version: 1
threadsafe: yes
handlers:
- url: /favicon\.ico
static_files: favicon.ico
upload: favicon\.ico
- url: /js
static_dir: js
- url: /css
static_dir: css
- url: /images
static_dir: /static/images
# Serve php scripts.
- url: /(.+\.php)$
script: \1
- url: /.*
script: /login.php
error_handlers:
- file: /errors/404.html
File structure example:
+root
+php
+admin
manageUsers.php
+teacher
lessons.php
+student
schedule.php
dashboard.php
+css
index.css
main.css
+js
+jquery
+bootstrap
login.php
I'm not sure why my YAML file works locally but not deployed. Can anyone give any insight?
If your scripts are using content from static_dir's you need to make sure they are available to the application.
You can achieve that by adding application_readable: true to your js, css and images handlers.
You can read more about it here: https://cloud.google.com/appengine/docs/php/config/appconfig
I have two files in root folder. ie. index.php and signup.php and the app.yaml looks like this,
application: testcboy
version: 1
runtime: php
api_version: 1
threadsafe: yes
handlers:
- url: /css
static_dir: css
- url: /js
static_dir: js
- url: /img
static_dir: img
- url: /.*
script: index.php
Problem is, when the link of singup.php from the home page (index.php) is cliked, then only the url of address bar is changes but page remains the same home page(index.php).
Did you read the documentation?
- url: /signup.php
script: signup.php
- url: /.*
script: index.php
or if you have lots of scripts you want to route to you could use something like
- url: /(.*)\.php
script: \1.php
- url: /.*
script: index.php