title: Incorrect permissions when running Heroku PHP project locally with Foreman in Ubuntu
body: <p>I have a Heroku PHP project in my local directory in Xubuntu 14.04 machine.</p>
  
  <p>I want to run it locally in order to develop/test it before deploying on Heroku.</p>
  
  <p>First of all, I've tried to cd into project directory and ran <code>foreman start web</code>.</p>
  
  <p>There were errors related to some missing packages and PHP version so I did the following:</p>
  
  <p>1). Installed latest PHP version from custom PPA (<em>ppa:ondrej/php5</em>):</p>
  
  <p><code>php --version</code></p>
  
  <p><code>PHP 5.5.18-1+deb.sury.org~trusty+1 (cli) (built: Oct 17 2014 15:20:47)</code>.</p>
  
  <p>2). Created a symlink for <code>php5-fpm</code> binary:</p>
  
  <p><code>sudo ln -s /usr/sbin/php5-fpm /usr/local/bin/php-fpm</code></p>
  
  <p>3). Installed <strong>nginx</strong>.</p>
  
  <p>4). Changed the <strong>Procfile</strong>:</p>
  
  <p><code>web: vendor/bin/heroku-php-nginx /web</code></p>
  
  <p>Next, I'm trying to start the server using: <code>foreman start web</code> command and I'm getting the following output:</p>
  
  <pre><code>02:38:23 web.1  | started with pid 15815
  02:38:23 web.1  | Booting on port 5000...
  02:38:23 web.1  | DOCUMENT_ROOT changed to '/web/'
  02:38:24 web.1  | Starting php-fpm...
  02:38:24 web.1  | Starting nginx...
  02:38:24 web.1  | [06-Nov-2014 02:38:24] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
  02:38:24 web.1  | [06-Nov-2014 02:38:24] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
  02:38:26 web.1  | nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
  02:38:26 web.1  | 2014/11/06 02:38:26 [warn] 15897#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
  02:38:26 web.1  | 2014/11/06 02:38:26 [emerg] 15897#0: open() "/var/log/nginx/access.log" failed (13: Permission denied)
  02:38:26 web.1  | Process exited unexpectedly: nginx
  02:38:26 web.1  | Going down, terminating child processes...
  02:38:26 web.1  | vendor/bin/heroku-php-nginx: line 282: 15891 Terminated              tail -qF -n 0 "${logs[@]}"
  02:38:26 web.1  |      15892                       | strip_fpm_child_said 1&gt;&amp;2
  02:38:26 web.1  | exited with code 1
  02:38:26 system | sending SIGTERM to all processes
  </code></pre>
  
  <p>Apparently, it can't start because it can't access log files that is owned by root user.</p>
  
  <p>Next, I'm trying to start it using <em>sudo</em>: <code>sudo foreman start web</code> and getting the following output:</p>
  
  <pre><code>02:43:29 web.1  | started with pid 16153
  02:43:30 web.1  | Booting on port 5000...
  02:43:30 web.1  | DOCUMENT_ROOT changed to '/web/'
  02:43:30 web.1  | Starting php-fpm...
  02:43:30 web.1  | Starting nginx...
  02:43:32 web.1  | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
  02:43:32 web.1  | nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
  02:43:32 web.1  | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
  02:43:32 web.1  | nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
  02:43:33 web.1  | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
  02:43:33 web.1  | nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
  02:43:33 web.1  | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
  02:43:33 web.1  | nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
  02:43:34 web.1  | nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
  02:43:34 web.1  | nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
  02:43:34 web.1  | nginx: [emerg] still could not bind()
  02:43:34 web.1  | Process exited unexpectedly: nginx
  02:43:34 web.1  | Going down, terminating child processes...
  02:43:34 web.1  | vendor/bin/heroku-php-nginx: line 282: 16229 Terminated              tail -qF -n 0 "${logs[@]}"
  02:43:34 web.1  |      16230                       | strip_fpm_child_said 1&gt;&amp;2
  02:43:34 web.1  | exited with code 1
  02:43:34 system | sending SIGTERM to all processes
  </code></pre>
  
  <p>Looks like it doesn't like that nginx service is running. Why is that?</p>
  
  <p>I'm turning the webserver off using: <code>sudo service nginx stop</code> and trying again.</p>
  
  <p>This time there are no error messages and it looks like server is running.</p>
  
  <p>However, when I'm loading the webpage in my browser I'm getting the HTTP's <strong>502 Bad Gateway</strong> error.</p>
  
  <p>From the nginx error log I can see that nginx can't access FastCGI socket file:</p>
  
  <p><code>2014/11/06 02:45:44 [crit] 16342#0: *1 connect() to unix:/tmp/heroku.fcgi.5000.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/tmp/heroku.fcgi.5000.sock:", host: "localhost:5000"</code>.</p>
  
  <p>The socket file is owned by <code>root</code> and nginx is running as <code>www-data</code>.</p>
  
  <p>What is the reason for this, how do I fix this problem? Is it possible to run Heroku locally from my user (not the root)?</p>