Installation on localhost: stuck on an error 500

Hello all,
I just discovered Grav and it looks to be the CMS of my dreams! However, I’ve only been able to actually work with it on a shared hosting server, as I simply cannot get it to run on my desktop computer. I’m sure it must be something fairly simple that I’m overlooking though.

I’m running PHP 7.0.27 and Apache 2.4.25 under Debian 9. What I’ve done so far is:

  1. made sure php was working (via phpinfo.php),
  2. installed all the necessary PHP extensions,
  3. set AllowOverride All in the apache2 config file,
  4. tried setting the RewriteBase,
  5. checked this forum for similar issues.

But try as I may – I’m getting an error 500, whether I try a Skeleton, the Grav-Admin version or a clone from github. I’m running out of ideas of where to look. Can anyone help me out?

Thank you for your time!
Anna~

Hi,
it’s very simple.
You don’t need apache!
Download Grav or a skeleton and unzip it to a folder of your choice.
Go to that folder, open it, open a terminal there.
Type: php -S localhost:8000 system/router.php
Open your browser, type in your adressbar: localhost:8000
Read about it:
https://learn.getgrav.org/basics/installation#running-grav-with-the-built-in-php-webserver-using-router-php

Hey there,

thank you for that tip! This actually does work nicely – I’d seen it in the docs but sort of dismissed it straight away. However, it also says in the docs that this is for quick development and should not be used in place of a dedicated webserver. Since I intend to do quite a few projects that will probably also require plugin development, I really would like to mimic the shared hosting environment that the projects will later run under. Plus, this is likely to be a very simple issue… that I just can’t figure out right now :laughing:

Anyway I shall use this until the 500 error problem is solved, so thanks again!
Anna~

The usual reason is file ownership and permissions and you don’t say if you tried that. However, if you got it running with PHP’s server, it’s probably not that.

So, it would be helpful to know what you are seeing in your Apache (or maybe PHP) error logs when the 500 error comes up.

BTW I use Nginx (which I recommend) so it’s unlikely I can help.

Hey, thank you also for that tip! First of all, sorry I forgot to mention that but I did check the file permissions. As far as I can see I’m running PHP with my own user, so I should be good.

I checked the error logs and I’m actually not sure what I am seeing, or rather what it all means. The errors look like this:
::1 - - [25/Jun/2018:11:00:38 +0200] “GET /workspace/Grav/skeleton-mediator/ HTTP/1.1” 500 185 “http://localhost/workspace/Grav/” “Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0”

I did an internet search on that little 185 there, but it doesn’t seem to be a status code?

– okay wow, the weirdest thing just happened. I tried the clone from Github (the error above was produced by a Skeleton install), and suddenly I’m getting a very helpful list of error notices that a couple of directories are not writeable! I swear I was getting only blank pages yesterday… oh well. At least I should be rolling now. Thank you all again for your help! If I find out what exactly is causing the blank pages as opposed to the error list, I shall post it here.

Hi Anna, certainly sounds like a permissions issue! If you go into the skeleton-mediator directory and run

ls -l

who shows up as the owner of the files? Make sure that this user is either:

  1. The user running the PHP pool
    or
  2. A user who is in a secondary group that runs the pool

For example, www-data is the user that runs my pool. I don’t want to use www-data for actually doing work, so I’ve added user coderooney to the group www-data. Since you said you’re running PHP as your own user though, all this is probably fine for you.

Next in my Grav directory (i.e. skeleton-mediator here) I run the following script to make sure coderooney has all the right permissions:

#!/bin/sh
chown -R coderooney:coderooney .
find . -type f | xargs chmod 664
find ./bin -type f | xargs chmod 775
find . -type d | xargs chmod 775
find . -type d | xargs chmod +s

Save the above as chown.sh or something (replacing “coderooney:coderooney” with your user:group), then make the script executable with:

sudo chmod +x chown.sh

and execute it with:

sudo ./chown.sh

That’ll change ownership to the user:group that you set and hopefully get you on your way.

Checkout https://learn.getgrav.org/troubleshooting/permissions if you’re still stuck!

Hey, just to let you know: I didn’t look properly at my PHP user. It’s www-data and not my own so of course the permissions weren’t right. I don’t have that problem online and I think I’ll set up a local server with a configuration that mimics my online settings – as soon as this deadline has been taken care of. :wink:

Good luck! First important step in troubleshooting is checking facts.