Deployer: Deployer doesn’t create the file 'laravel.log'

Created on 24 Nov 2015  Â·  2Comments  Â·  Source: deployphp/deployer

On my VirtualBox (‘laravel/homestead’ Vagrant box), I have a Laravel 5 test application containing the following file: storage/logs/laravel.log

  • After changing the above folder permission, I could push the file to GitHub.
  • I point to /var/www/html/current/public in sites-enabled on my VPS.
  • I 'successfully deployed' the app to the remote server (VPS).

deploy.php:

require 'recipe/laravel.php';
server('prod', 'myipaddress', 2210)
    ->user('root')
    ->password('mypassword')
    ->stage('production')
    ->env('deploy_path', '/var/www/html');
set('repository', 'https://github.com/my/repo');

The problem is that the file laravel.log is not being created on the remote server (missing).
(Because of that Apache default welcome page shows _Server error 500_).

Apache error log file (/var/log/apache2/error.log):

[Tue Nov 24 12:16:24.129870 2015] [:error] [pid 22751] [client 2400:cb00:29:1024::6ca2:f0b2:55318] PHP Fatal error:  Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/html/releases/20151124170720/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /var/www/html/releases/20151124170720/bootstrap/cache/compiled.php:13301\nStack trace:\n#0 /var/www/html/releases/20151124170720/bootstrap/cache/compiled.php(13239): Monolog\\Handler\\StreamHandler->write(Array)\n#1 /var/www/html/releases/20151124170720/bootstrap/cache/compiled.php(13002): Monolog\\Handler\\AbstractProcessingHandler->handle(Array)\n#2 /var/www/html/releases/20151124170720/bootstrap/cache/compiled.php(13098): Monolog\\Logger->addRecord(400, Object(UnexpectedValueException), Array)\n#3 /var/www/html/releases/20151124170720/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(50): Monolog\\Logger->error(Object(UnexpectedValueException))\n#4 /var/www/html/releases/20151124170720/app/Exceptions/Handler.php(33): Illuminate\\Foundation\\Exceptions\\Handler->report(Object(UnexpectedValueE in /var/www/html/releases/20151124170720/bootstrap/cache/compiled.php on line 13301
[Tue Nov 24 12:16:24.130630 2015] [:error] [pid 22751] [client 2400:cb00:29:1024::6ca2:f0b2:55318] PHP Fatal error:  Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/var/www/html/releases/20151124170720/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied' in /var/www/html/releases/20151124170720/bootstrap/cache/compiled.php:13301\nStack trace:\n#0 /var/www/html/releases/20151124170720/bootstrap/cache/compiled.php(13239): Monolog\\Handler\\StreamHandler->write(Array)\n#1 /var/www/html/releases/20151124170720/bootstrap/cache/compiled.php(13002): Monolog\\Handler\\AbstractProcessingHandler->handle(Array)\n#2 /var/www/html/releases/20151124170720/bootstrap/cache/compiled.php(13098): Monolog\\Logger->addRecord(400, Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException), Array)\n#3 /var/www/html/releases/20151124170720/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(50): Monolog\\Logger->error(Object(Symfony\\Component\\Debug\\Exception\\FatalErrorException))\n#4 /var/www/html/releases/20151124170720/app/Exceptions/Handler.php(33): Illuminate\\Fou in /var/www/html/releases/20151124170720/bootstrap/cache/compiled.php on line 13301
Why Deployer doesn’t create this file on my VPS? How to fix it?

Most helpful comment

[SOLVED]

  • sudo chown -R root:www-data storage (ownership to members of..)
  • sudo chmod -R g+rwX storage (permissions recursively)
  • sudo chmod g+s storage (affect future sub-directories)
  • .env was misisng on the remote server (.gitignore)

All 2 comments

The problem is that the file laravel.log is not being created on the remote server (missing).
(Because of that Apache default welcome page shows Server error 500).

500 error does not means the file is missing. You should confirm the file is here or not directly.
For example, ls -l /var/www/html/releases/20151124170720/storage/logs/laravel.log.

You should check the file permission. Becaseu the error messages is:

The stream or file "/var/www/html/releases/20151124170720/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied

[SOLVED]

  • sudo chown -R root:www-data storage (ownership to members of..)
  • sudo chmod -R g+rwX storage (permissions recursively)
  • sudo chmod g+s storage (affect future sub-directories)
  • .env was misisng on the remote server (.gitignore)
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ElForastero picture ElForastero  Â·  3Comments

ovaiskhan11 picture ovaiskhan11  Â·  4Comments

dima-stefantsov picture dima-stefantsov  Â·  4Comments

k-solnushkin picture k-solnushkin  Â·  5Comments

antonmedv picture antonmedv  Â·  5Comments