Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii2 App not displaying on Heroku domain

Tags:

php

heroku

yii

yii2

I installed a Yii2 "basic" app on a Cloud9 workspace using composer. It runs fine as you can see here https://portfolio-php--dfmmalaw.c9.io/basic/web/index.php

Problem is I am getting below error when trying to view after deploying to Heroku URL.

"Forbidden You don't have permission to access / on this server."

The below screenshot is my Cloud9 workspace http://prntscr.com/8rrkn0

I even tried adding basic/web/index.php to the Heroku URL but I just get a blank page. What am I doing wrong?

like image 477
Dean Friedland Avatar asked Oct 15 '15 23:10

Dean Friedland


1 Answers

After getting help from Herokai, David Zuelke, I decided to create a how-to on the subject of "Creating Yii2 App in Cloud9 → Pushing to Github → Deploying to Heroku". Please see below (google doc link at top if easier to read):

https://docs.google.com/document/d/15teHaGWUWSNW_VwdV3-7bVpQHNRv2G0Z8GPFbIB-ogs/edit

1) Create Yii2 “basic” app:

290795 $ composer create-project --prefer-dist yiisoft/yii2-app-basic basic

2) Move into “basic” directory

290795 $ cd basic/

3) Initialize local repo for “basic” directory

basic $ git init

4) Add and commit Yii project

basic $ git add .
basic $ git commit -m "basic Yii project"

5) Add procfile that will point to index.php (entry script) in “web” directory

basic $ echo "web: vendor/bin/heroku-php-apache2 web/" > Procfile
basic $ git add Procfile 
basic $ git commit -m "Procfile for Heroku"

6) Comment out debugging stuff (I do this manually instead of from command line)

basic $ vim web/index.php # remove dev/debug env stuff (not my way)
basic $ git add web/index.php 
basic $ git commit -m "remove dev/debug env"

7) This updates the dependency from v1.0.3 to v1.1 (absolute necessity)

basic $ composer require fxp/composer-asset-plugin
basic $ git add composer.json composer.lock 
basic $ git commit -m "use fxp/composer-asset-plugin in project"

8) Create Heroku app and push to it. (I instead create and push to Github repo)

basic $ heroku create
basic $ git push heroku master (again I push to Github Repo synced with Heroku)

9) Add logging to Heroku for Yii app (no logging for Yii out of the box)

basic $ echo "web: vendor/bin/heroku-php-apache2 -l runtime/logs/app.log web/" > Procfile
basic $ git add Procfile 
basic $ git commit -m "tail runtime/logs/app.log"
basic $ git push heroku master (again I push to Github Repo synced with Heroku)

10) This allows the “Contact” page to work (not sure why)

basic $ composer require ext-gd:* --ignore-platform-reqs
basic $ git add composer.json composer.lock 
basic $ git commit -m "require GD for contact CAPTCHA"
basic $ git push heroku master (again I push to Github Repo synced with Heroku)
like image 158
Dean Friedland Avatar answered Sep 23 '22 03:09

Dean Friedland