<p>I solved it.</p>

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

CC BY-SA 3.0
2016-03-25T03:28:06.070Z
How'd you get the permissions for /app/craft/storage sorted?
Jack
CC BY-SA 3.0
2016-01-31T20:02:58.473Z
2016-02-01T05:05:16.103Z
2016-02-01T05:05:16.103Z
cheechaw
<p>I'm familiar with Heroku, but new to Craft CMS. 
In order to get a site running, I followed this tutorial: <a href="https://medium.com/@aj1215/craft-cms-on-heroku-79b991665b0b#.8b561b1b4" rel="nofollow">https://medium.com/@aj1215/craft-cms-on-heroku-79b991665b0b#.8b561b1b4</a></p>

<p>But the site isn't functioning. My Heroku app just results in: <code>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.</code></p>

<p>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.</p>

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

<p>These are messages toward the end of my Heroku logs:</p>

<pre><code>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=
</code></pre>

<p>enginx_app.conf file:</p>

<pre><code>        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;
        }
</code></pre>

<p>this is my <code>craft/config/db.php</code> file:</p>

<pre><code>&lt;?php

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

return array(

    'server' =&gt; $url["host"],

    'user' =&gt; $url["user"],

    'password' =&gt; $url["pass"],

    'database' =&gt; substr($url["path"],1),

    'tablePrefix' =&gt; 'craft',

);
</code></pre>

CC BY-SA 3.0
2016-01-31T18:03:16.343Z
Sounds like something is messed up in your nginx conf file.  Can you share it?
Brad Bell
CC BY-SA 3.0
2016-01-31T18:54:25.293Z
@BradBell Thank you, Brad. Yes, I'll put that code in immediately.
cheechaw
CC BY-SA 3.0
2016-01-31T19:27:46.590Z
I'm no nginx expert, but I'm pretty sure the `server` block goes in the `http` block and not the other way around: https://www.nginx.com/resources/wiki/start/topics/examples/full/
Brad Bell
CC BY-SA 3.0
2016-01-31T19:45:06.003Z
@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
CC BY-SA 3.0
2016-01-31T19:50:50.593Z
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
CC BY-SA 3.0
2016-01-31T19:52:06.660Z
Hah... maybe some weird caching issue going on.  Anyway, glad you're up and running!  Would you mind summarizing what got you going and adding it as an official answer?
Brad Bell
CC BY-SA 3.0
2016-01-31T20:04:01.553Z
@BradBell Thanks again. I added the answer. However, I have one more 'easy' question for you: Images in my public/images folder are not making it to heroku. Where should I be putting those instead? Thanks again
cheechaw
<server><apache><logs>
Can't get Craft running on Heroku
# Can't get Craft running on Heroku

(Asked by: username_0 on 2016-01-31)

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:
 $url["host"],

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

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

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

    'tablePrefix' => 'craft',

);

**Tags:** server, apache, logs

> **Comments:**
> **username_1**: Sounds like something is messed up in your nginx conf file.  Can you share it?  
> **username_0**: @BradBell Thank you, Brad. Yes, I'll put that code in immediately.  
> **username_1**: I'm no nginx expert, but I'm pretty sure the `server` block goes in the `http` block and not the other way around: https://www.nginx.com/resources/wiki/start/topics/examples/full/  
> **username_0**: @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!  
> **username_0**: 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. :/  
> **username_1**: Hah... maybe some weird caching issue going on.  Anyway, glad you're up and running!  Would you mind summarizing what got you going and adding it as an official answer?  
> **username_0**: @BradBell Thanks again. I added the answer. However, I have one more 'easy' question for you: Images in my public/images folder are not making it to heroku. Where should I be putting those instead? Thanks again  

---

## 1 answers

### Answer by username_0 on 2016-01-31. Score: 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'.

> **Comments:**
> **username_2**: How'd you get the permissions for /app/craft/storage sorted?  

---

