Install problems

Hi, I’d really like to try out grab but am running into a number of problems. I’m running on a linode running Ubuntu 14.04.1 with nginx and php-fpm.

I first tried to install from the zip file. After changing ownership of all the files to the web server (www-data in my case), the grav install is reachable by a browser. However, bin/gpm doesn’t work. I was getting permissions errors (presumably because when run by my user, it couldn’t write in the log directory). So I chowned all the files to have my group as the group owner and chmoded everything g+w. Then when I ran bin/gpm, I got the following:

Whoops\Exception\ErrorException: fopen(/www-root/mydomain.tld/grav/cache/compiled/blueprints/master-loc alhost.php): failed to open stream: Permission denied in file /data/public_html/mydomain.tld/grav/vendor/rockettheme/toolbox/File/sr c/File.php on line 149
Stack trace:
  1. Whoops\Exception\ErrorException->() /www-root/mydomain.tld/grav/vendor/rockettheme/toolbox/File/src/File.p hp:149
  2. Whoops\Run->handleError() :0
  3. fopen() /www-root/mydomain.tld/grav/vendo r/rockettheme/toolbox/File/src/File.p hp:149
  4. RocketTheme\Toolbox\File\File->lock() /www-root/mydomain.tld/grav/system/src/Grav/Common/Config/Config.php:2 38
  5. Grav\Common\Config\Config->loadCompiledBlueprints() /www-root/mydomain.tld/grav/system/src/Grav/Common/Config/Config.php:1 69
  6. Grav\Common\Config\Config->init() /www-root/mydomain.tld/grav/bin/gpm:30

At this point, I gave up with the zip file and tried the git install method. Once I tweaked permissions as above, I got a bit farther along, though when I ran bin/gpm index, I got the following error:

[Whoops\Exception\ErrorException]
  Use of undefined constant CURLOPT_REFERER - assumed 'CURLOPT_REFERER'

Any ideas what I am doing wrong here? I do think it would be helpful for some guidelines for how permissions should be set.

With any PHP application that writes files (logs, cache, etc), permissions can be a problem. This is because PHP running under apache can be a different user from the user logged in and running via CLI. You probably already know this, just repeating for clarity.

On most local installs, and even most shared hosting setups, this is not a problem because both are configured to run with the same user. However, in a dedicated server environment this is usually not the case.

The best solution I can suggest is ensure your user and your webserver are in the same group, then ensure the file & folder permissions are set with that group and that group has read+write permissions on the files folders.

Here’s a little script I have used in the past when facing this situation:

#!/bin/sh
chown rhuk:staff .
chown -R rhuk:staff *
find . -type f | xargs chmod 664
find . -type d | xargs chmod 775
find . -type d | xargs chmod +s
umask 0002

You will need to add the webserver user to the staff group. The other option is to add your user to the group that the webserver is alre ady in.

The umask should ensure that the permissions are maintained for new files too.

Woot!

Thanks for the quick reply and specifics on the permissions. I think I had reached a similar solution, but seeing the official approach is always nice.

Any clues on the gpm/CURLOPT_REFERER issue?

Yes, I think you need to enable or install php5-curl as it seems to be missing.

sudo apt-get install curl libcurl3 libcurl3-dev php5-curl

Then restart apache.

Oh! One other option to address your permissions issue.

If this Ubuntu install is your local development environment, then an easier/better solution might be to configure apache to run as your regular user account. I do this for Apache on Mac OS X:

http://getgrav.org/blog/mac-os-x-apache-setup-multiple-php-versions

You can do similar for Ubuntu.