Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying PHP Project On Heroku

Tags:

php

heroku

I've successfully deployed my PHP project on the heroku, but the problem is that whenever I type in the "Heroku Open" for the webpage url to load, I get the following error :

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

I know the problem may arise from server configuration, my ht-access, or even the Apache configs, and I've tried making variety of changes, but none of them worked so far, here are the heroku logs:

015-03-15T10:47:30.266691+00:00 heroku[api]: Release v2 created by [email protected]
2015-03-15T10:50:02.189549+00:00 heroku[api]: Scale to web=1 by [email protected]
2015-03-15T10:50:02.262334+00:00 heroku[api]: Deploy d388ddf by  [email protected]
2015-03-15T10:50:02.262334+00:00 heroku[api]: Release v3 created by [email protected]
2015-03-15T10:50:08.597918+00:00 heroku[web.1]: Starting process with command `vendor/bin/heroku-php-apache2`
2015-03-15T10:50:10.812072+00:00 app[web.1]: Starting php-fpm...
2015-03-15T10:50:10.620318+00:00 app[web.1]: Optimzing defaults for 1X dyno...
2015-03-15T10:50:10.802110+00:00 app[web.1]: 4 processes at 128MB memory limit.
2015-03-15T10:50:12.815707+00:00 app[web.1]: Starting httpd...
2015-03-15T10:50:13.132692+00:00 heroku[web.1]: State changed from starting to up
2015-03-15T10:50:38.639895+00:00 heroku[api]: Scale to web=1 by [email protected]
2015-03-15T10:50:49.465371+00:00 heroku[router]: at=info method=GET path="/" host=boiling-bastion-7861.herokuapp.com request_id=92b6872e-c060-4e06-8ede-5d44ea335ada fwd="175.140.77.229" dyno=web.1 connect=1ms service=3ms status=403 bytes=387
2015-03-15T10:50:49.465802+00:00 app[web.1]: 10.123.194.135 - - [15/Mar/2015:10:50:49 +0000] "GET / HTTP/1.1" 403 209 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36
2015-03-15T10:50:49.465396+00:00 app[web.1]: [Sun Mar 15 10:50:49.463558 2015] [autoindex:error] [pid 117:tid 140423049713408] [client 10.123.194.135:31742] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (home.php) found, and server-generated directory index forbidden by Options directive
2015-03-15T10:50:49.907445+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=boiling-bastion-7861.herokuapp.com request_id=76865ea0-628f-426f-8bad-5507aa052fb4 fwd="175.140.77.229" dyno=web.1 connect=1ms service=5ms status=200 bytes=3964
2015-03-15T10:50:49.906266+00:00 app[web.1]: 10.123.194.135 - - [15/Mar/2015:10:50:49 +0000] "GET /favicon.ico HTTP/1.1" 200 3754 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36
2015-03-15T10:53:30.128901+00:00 heroku[router]: at=info method=GET path="/" host=boiling-bastion-7861.herokuapp.com request_id=56038276-5eb7-40ad-8615-cc695a72cdcb fwd="175.140.77.229" dyno=web.1 connect=1ms service=2ms status=403 bytes=387
2015-03-15T10:53:30.129676+00:00 app[web.1]: 10.91.13.225 - - [15/Mar/2015:10:53:30 +0000] "GET / HTTP/1.1" 403 209 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36
2015-03-15T10:53:30.129331+00:00 app[web.1]: [Sun Mar 15 10:53:30.128673 2015] [autoindex:error] [pid 102:tid 140423284651776] [client 10.91.13.225:15561] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (home.php) found, and server-generated directory index forbidden by Options directive
2015-03-15T10:53:30.686329+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=boiling-bastion-7861.herokuapp.com request_id=9bfc7392-7f31-49ff-831a-55dbd0812914 fwd="175.140.77.229" dyno=web.1 connect=3ms service=4ms status=200 bytes=3964
2015-03-15T10:53:30.686175+00:00 app[web.1]: 10.91.13.225 - - [15/Mar/2015:10:53:30 +0000] "GET /favicon.ico HTTP/1.1" 200 3754 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36
2015-03-15T11:06:22.231815+00:00 heroku[router]: at=info method=GET path="/" host=boiling-bastion-7861.herokuapp.com request_id=3a2df217-758f-469c-884a-3f27072dda7d fwd="175.140.77.229" dyno=web.1 connect=4ms service=7ms status=403 bytes=387
2015-03-15T11:06:22.228756+00:00 app[web.1]: 10.93.25.70 - - [15/Mar/2015:11:06:22 +0000] "GET / HTTP/1.1" 403 209 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36
2015-03-15T11:06:22.228440+00:00 app[web.1]: [Sun Mar 15 11:06:22.227460 2015] [autoindex:error] [pid 104:tid 140423183963904] [client 10.93.25.70:29123] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (home.php) found, and server-generated directory index forbidden by Options directive
2015-03-15T11:06:22.710597+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=boiling-bastion-7861.herokuapp.com request_id=ad006b2f-00fe-426e-81f0-e2a8d8e9e457 fwd="175.140.77.229" dyno=web.1 connect=1ms service=10ms status=200 bytes=3964
2015-03-15T11:06:22.709151+00:00 app[web.1]: 10.93.25.70 - -   [15/Mar/2015:11:06:22 +0000] "GET /favicon.ico HTTP/1.1" 200 3754 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.99 Safari/537.36

What is the possible solution ?! any consideration is appreciated...

like image 344
Pouya Ataei Avatar asked Mar 15 '15 12:03

Pouya Ataei


1 Answers

Apache is telling you what the problem is right here in your error logs (I've wrapped it for readability):

2015-03-15T10:50:49.465396+00:00 app[web.1]: [Sun Mar 15 10:50:49.463558 2015]
  [autoindex:error] [pid 117:tid 140423049713408] [client 10.123.194.135:31742]
  AH01276: Cannot serve directory /app/: No matching DirectoryIndex (home.php) found,
  and server-generated directory index forbidden by Options directive

You apparently have DirectoryIndex home.php somewhere in a .htaccess file, but there is no home.php, so when you try to go to /, it can't find that file (that it would use when you request just the directory itself, /), and listing directory contents (which is not what you want anyway) is not allowed in the default config.

So you either need to create a home.php with your code, change that .htaccess to remove the DirectoryIndex statement so your index.php/index.html (if present) gets served, or, if your home.php and everything else is not in the root of your project but in a sub-directory like public or web, define a document root using the documented argument in your Procfile command:

web: vendor/bin/heroku-php-apache2 public/
like image 61
dzuelke Avatar answered Sep 18 '22 10:09

dzuelke