I'm following this guide on setting up Laravel 5.1 on Ubuntu (LAMP stack) for Digital Ocean. When I try to access my Laravel app on the one-click droplet, I get:
I went through the steps of installing Composer then Laravel, and then placed ~/.composer/vendor/bin
directory in my PATH "so the laravel executable can be located by your system."
root@phpmyadmin-512mb-nyc3-01:/# cat ~/.bashrc
:
echo 'export PATH="$PATH:$HOME/.composer/vendor/bin"' >> ~/.bashrc
export PATH="$PATH:$HOME/.composer/vendor/bin"
Then follow this guide on changing my webroot so I can serve from /public
like Laravel expects:
nano /etc/apache2/sites-enabled/000-default.conf
I change DocumentRoot /var/www/html/
to DocumentRoot /var/www/html/public
Then restarted sudo systemctl restart apache2
I cannot access my Laravel app. It gives a 500
error. Why is this?
PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/html/storage/logs/laravel-2017-05-17.log" could not be opened: failed to open stream: Permission denied in /var/www/html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107\nStack trace:\n#0 /var/www/html/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(106): Monolog\Handler\StreamHandler->write(Array)\n#1 /var/www/html/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\RotatingFileHandler->write(Array)\n#2 /var/www/html/vendor/monolog/monolog/src/Monolog/Logger.php(336): Monolog\Handler\AbstractProcessingHandler->handle(Array)\n#3 /var/www/html/vendor/monolog/monolog/src/Monolog/Logger.php(615): Monolog\Logger->addRecord(400, Object(UnexpectedValueException), Array)\n#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\Logger->error(Object(UnexpectedValueException), Array)\n#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Log/Writer.php(11 in /var/www/html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
cat
'ing the file shows that it's empty. – Growlersudo chown -R :www-data /var/www/laravel
&sudo chmod -R 775 /var/www/laravel/storage
- where laravel is your project name. Also, please add your log files for 500 error. – senty