2

I'm familiar with Heroku, but new to Craft CMS. In order to get a site running, I followed this tutorial: https://medium.com/@aj1215/craft-cms-on-heroku-79b991665b0b#.8b561b1b4

But the site isn't functioning. My Heroku app just results in: Application Error An error occurred in the application and your page could not be served. Please try again in a few moments. If you are the application owner, check your logs for details.

My development server runs fine. But I have no idea what I need to do to get the heroku app to function. I'm pulling my hair out.

I've tried everything I can think of, but can't get it to work. I'm not sure what I'm doing wrong.

These are messages toward the end of my Heroku logs:

2016–01–31T03:09:21.480751+00:00 app[web.1]: nginx: [emerg] “server” directive is not allowed here in /app/nginx_app.conf:1
2016–01–31T03:09:21.475721+00:00 app[web.1]: Starting nginx…
2016–01–31T03:09:21.481090+00:00 app[web.1]: Process exited unexpectedly: nginx
2016–01–31T03:09:21.481236+00:00 app[web.1]: Going down, terminating child processes…
2016–01–31T03:09:22.183035+00:00 heroku[web.1]: Process exited with status 1
2016–01–31T03:09:22.182791+00:00 heroku[web.1]: State changed from starting to crashed
2016–01–31T03:09:27.185620+00:00 heroku[router]: at=error code=H10 desc=”App crashed” method=GET path=”/” host=paradata.herokuapp.com request_id=1e502143–94ac-4aea-b34b-3087addd1d20 fwd=”172.11.56.78" dyno= connect= service= status=503 bytes=

enginx_app.conf file:

        location / {
            # try to serve file directly, fallback to rewrite
            try_files $uri @rewriteapp;
        }
        location @rewriteapp {
            # rewrite all to index.php
            rewrite ^(.*)$ /index.php?p=$1 last;
        }
        location ~ ^/(index)\.php(/|$) {
            client_max_body_size 20M;
            fastcgi_pass heroku-fcgi;
            fastcgi_split_path_info ^(.+\.php)(/.*)$;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param HTTPS on;
        }

this is my craft/config/db.php file:

<?php

$url = parse_url(getenv("CLEARDB_DATABASE_URL"));

return array(

    'server' => $url["host"],

    'user' => $url["user"],

    'password' => $url["pass"],

    'database' => substr($url["path"],1),

    'tablePrefix' => 'craft',

);
  • Sounds like something is messed up in your nginx conf file. Can you share it? – Brad Bell Jan 31 '16 at 18:03
  • @BradBell Thank you, Brad. Yes, I'll put that code in immediately. – cheechaw Jan 31 '16 at 18:54
  • I'm no nginx expert, but I'm pretty sure the server block goes in the http block and not the other way around: nginx.com/resources/wiki/start/topics/examples/full – Brad Bell Jan 31 '16 at 19:27
  • @BradBell Thanks. i removed the SERVER and HTML calls in the nginx and now the error is "Craft can’t connect to the database with the credentials in craft/config/db.php." when I try to visit /admin. I'll post my db.php if it helps. Thanks for your help! – cheechaw Jan 31 '16 at 19:45
  • Thank you! @BradBell It just started working for some reason. I really just added spaces between some lines in my db.php and that was it. :/ – cheechaw Jan 31 '16 at 19:50
2

I solved it.

I needed to remove calls to 'server' and 'http' in my enginx_app.conf file. Now the file only makes calls to 'location'.

  • How'd you get the permissions for /app/craft/storage sorted? – Jack Mar 25 '16 at 3:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.