I want to update database password inside the env file. I want to update the db_password variable.
I am trying the following command after navigation to /var/www/html
php artisan env:set db_password=myPassWordHere
And I am getting error.
PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107
Full error
PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107
Stack trace:
#0 /var/www/html/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\StreamHandler->write(Array)
#1 /var/www/html/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#2 /var/www/html/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\Logger->addRecord(400, Object(UnexpectedValueException), Array)
#3 /var/www/html/vendor/laravel/framework/src/Illuminate/Log/Writer.php(202): Monolog\Logger->error(Object(UnexpectedValueException), Array)
#4 /var/www/html/vendor/laravel/framework/src/Illuminate/Log/Writer.php(113): Illuminate\Log\Writer->writeLog('error', Object(UnexpectedValueException), Array)
#5 /var/www/html/vendor/laravel/framework/src/Illuminate/Foundati in /var/www/html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/html/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied in /var/www/html/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107
How can I update db_password variable inside env file, using command line?
Check that the log file exists and that it has write permissions:
ls -l /var/www/html/storage/logs/laravel.log
If it's not writable, run:
chmod 755 /var/www/html/storage/logs/laravel.log
You can use the Github Package https://github.com/svenluijten/flex-env
After the Successful Package Installation
For Example
If you want to add new constant to .env File
Maybe if you want to add ADMIN_EMAIL with the value admin#app.com
php artisan env:set ADMIN_EMAIL admin#app.com
I had a similar issue and was able to resolve it by running the following set of commands.
php artisan route:clear
php artisan config:clear
php artisan cache:clear
(In that order)
Related
I'm trying to learn Laravel-The PHP Framework and wanted to use artisan.
I already installed Laravel globally and also created my first project but every time I run php artisan it doesnt recognize the command. I opened git on my project directory and sill not recognized.
It gives me this error:
$ php artisan
PHP Warning: require(C:\Users\--------\Desktop\Project\Laravel\firstProject/vendor/autoload.php): Failed to open stream: No such file or directory in C:\Users\--------\Desktop\Project\Laravel\firstProject\artisan on line 18
Warning: require(C:\Users\--------\Desktop\Project\Laravel\firstProject/vendor/autoload.php): Failed to open stream: No such file or directory in C:\Users\--------\Desktop\Project\Laravel\firstProject\artisan on line 18
PHP Fatal error: Uncaught Error: Failed opening required 'C:\Users\--------\Desktop\Project\Laravel\firstProject/vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\Users\--------\Desktop\Project\Laravel\firstProject\artisan:18
Stack trace:
#0 {main}
thrown in C:\Users\--------\Desktop\Project\Laravel\firstProject\artisan on line 18
Fatal error: Uncaught Error: Failed opening required 'C:\Users\--------\Desktop\Project\Laravel\firstProject/vendor/autoload.php' (include_path='C:\xampp\php\PEAR') in C:\Users\--------\Desktop\Project\Laravel\firstProject\artisan:18
Stack trace:
#0 {main}
thrown in C:\Users\--------\Desktop\Project\Laravel\firstProject\artisan on line 18
I tried downloading PHP manually or use the PHP from XAMPP but no changes.
I used php v8.0.2 and composer v2.0.11
You shouldn't install Laravel globally.
Go through this link:
How to Install Laravel on Ubuntu 20.04
I'm trying to install pterodactyl server management panel on my CentOS 7 server.. I did chown and chmod stuff like docs told me so. But when i try to open the website i see a blank page (phpinfo.php file works like it should work)
output of www-error.log
[22-Nov-2017 16:49:58 UTC] PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/www/html/pterodactyl/storage/logs/laravel-2017-11-22.log" could not be opened: failed to open stream: Permission denied in /var/www/html/pterodactyl/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:107
Stack trace:
#0 /var/www/html/pterodactyl/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(107): Monolog\Handler\StreamHandler->write(Array)
#1 /var/www/html/pterodactyl/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\RotatingFileHandler->write(Array)
#2 /var/www/html/pterodactyl/vendor/monolog/monolog/src/Monolog/Logger.php(337): Monolog\Handler\AbstractProcessingHandler->handle(Array)
#3 /var/www/html/pterodactyl/vendor/monolog/monolog/src/Monolog/Logger.php(616): Monolog\Logger->addRecord(400, Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)
#4 /var/www/html/pterodactyl/vendor/laravel/framework/src/Illuminate/Log/Writer.php(203): Monolog\Logger->error(Ob in /var/www/html/pterodactyl/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 107
You should create the following folder /var/www/html/pterodactyl/storage/logs/ then change the permission so Apache or Nginx can write to that folder.
I am trying to load my project on the live server.
these are the specs
PHP version 5.6
Server : Windows
I have loaded all the files and chmod 777
Storage
Vendor
bootstrap/cache
but it keeps giving me the following streaming error:
Fatal error: Uncaught exception 'UnexpectedValueException' with
message 'The stream or file
"C:\inetpub\wwwroot\websites\mysite\storage/logs/laravel.log" could
not be opened: failed to open stream: Permission denied' in
C:\inetpub\wwwroot\websites\mysite\vendor\monolog\monolog\src\Monolog\Handler\StreamHandler.php:87
Stack trace: #0
C:\inetpub\wwwroot\websites\mysite\vendor\monolog\monolog\src\Monolog\Handler\AbstractProcessingHandler.php(37):
Monolog\Handler\StreamHandler->write(Array) #1
C:\inetpub\wwwroot\websites\mysite\vendor\monolog\monolog\src\Monolog\Logger.php(336):
Monolog\Handler\AbstractProcessingHandler->handle(Array) #2
C:\inetpub\wwwroot\websites\mysite\vendor\monolog\monolog\src\Monolog\Logger.php(615):
Monolog\Logger->addRecord(400, Object(UnexpectedValueException),
Array) #3
C:\inetpub\wwwroot\websites\mysite\vendor\laravel\framework\src\Illuminate\Log\Writer.php(202):
Monolog\Logger->error(Object(UnexpectedValueExc
in C:\inetpub\wwwroot\websites\mysite\vendor\monolog\monolog\src\Monolog\Handler\StreamHandler.php on
line 87
Fatal error: Uncaught exception 'UnexpectedValueException' with
message 'The stream or file
"C:\inetpub\wwwroot\websites\mysite\storage/logs/laravel.log" could
not be opened: failed to open stream: Permission denied' in
C:\inetpub\wwwroot\websites\mysite\vendor\monolog\monolog\src\Monolog\Handler\StreamHandler.php:87
Stack trace: #0
C:\inetpub\wwwroot\websites\mysite\vendor\monolog\monolog\src\Monolog\Handler\AbstractProcessingHandler.php(37):
Monolog\Handler\StreamHandler->write(Array) #1
C:\inetpub\wwwroot\websites\mysite\vendor\monolog\monolog\src\Monolog\Logger.php(336):
Monolog\Handler\AbstractProcessingHandler->handle(Array) #2
C:\inetpub\wwwroot\websites\mysite\vendor\monolog\monolog\src\Monolog\Logger.php(615):
Monolog\Logger->addRecord(400,
Object(Symfony\Component\Debug\Exception\FatalErrorException), Array)>
3 C:\inetpub\wwwroot\websites\mysite\vendor\laravel\framework\src\Illuminate\Log\Writer.php(202):
Monolog\Logger->er
in C:\inetpub\wwwroot\websites\mysite\vendor\monolog\monolog\src\Monolog\Handler\StreamHandler.php on
line 87
You need to allow writing for logs dir chmod -R 777 storage/logs
You didn't set permissions correctly. You're on Windows, so read this or this. storage folder with all subfolders and files should be accessible to r&w.
I had a similar problem, turns out the server didnt create the file with the correct owner, even though permissions were set correctly. Hope this helps someone!
I deleted that particular log (im using daily logs) and it worked again.
Delete laravel.log file inside logs folder.
It worked for me.
I am an absolute beginner of laravel.
I would like to make some changes in my database. but when I try to refresh my databases, I keep dealing with the error below.
Before making this post, I googled so much and read many references. However, none of that worked and helped me solve the error.
Has anyone encountered this error before? Any advice would be appreciated. Thanks in advance.
PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/web/journal/storage/logs/laravel-2016-04-03.log" could not be opened: failed to open stream: Permission denied' in /web/journal/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:87 Stack trace: #0 /web/journal/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(88): Monolog\Handler\StreamHandler->write(Array) #1 /web/journal/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\RotatingFileHandler->write(Array)#2 /web/journal/vendor/monolog/monolog/src/Monolog/Logger.php(336): Monolog\Handler\AbstractProcessingHandler->handle(Array)#3 /web/journal/vendor/monolog/monolog/src/Monolog/Logger.php(615): Monolog\Logger->addRecord(400, 'exception 'Unex...', Array)#4 /web/journal/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(47): Monolog\Logger->error('exception 'Unex...')#5 /web/journal/app/Exceptions/Handler.php(27): Illuminate\Foundation\ in /web/journal/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 87 PHP Fatal error: Uncaught exception 'UnexpectedValueException' with message 'The stream or file "/web/journal/storage/logs/laravel-2016-04-03.log" could not be opened: failed to open stream: Permission denied' in /web/journal/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:87Stack trace: #0 /web/journal/vendor/monolog/monolog/src/Monolog/Handler/RotatingFileHandler.php(88): Monolog\Handler\StreamHandler->write(Array) #1 /web/journal/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(37): Monolog\Handler\RotatingFileHandler->write(Array)#2 /web/journal/vendor/monolog/monolog/src/Monolog/Logger.php(336): Monolog\Handler\AbstractProcessingHandler->handle(Array)#3 /web/journal/vendor/monolog/monolog/src/Monolog/Logger.php(615): Monolog\Logger->addRecord(400, 'exception 'Symf...', Array) #4 /web/journal/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(47): Monolog\Logger->error('exception 'Symf...')#5 /web/journal/app/Exceptions/Handler.php(27): Illuminate\Foundation\ in /web/journal/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php on line 87
run
composer dump-autoload
inside project, before running artisan
Add www-data group and write permission to the folder /storage/logs/. error is about writing permission of the log file. need to change permission of /storage/logs/. then only the real error will be seen
sudo chmod -R 777 storage
would help change permission
I'm trying to run a script using crontab, but I have problems making it work even from the command line. The script runs fine from the browser and it creates some excel files in reports/ folder which is owned by apache. The script file is owned by me: john.
When I try to run the script from the command line, I get the following warnings, and the excel file doesn't create. I've tryed with the full path, but I get the same results.
This is what I got after I try to run the script from command line
public_html]$ php include/tests/mailme.php
PHP Warning: fopen(reports/4-March.xls): failed to open stream: Permission denied in /home/john/public_html/PHPExcel/Shared/OLE/PPS/Root.php on line 90
Warning: fopen(reports/4-March.xls): failed to open stream: Permission denied in /home/john/public_html/PHPExcel/Shared/OLE/PPS/Root.php on line 90
PHP Fatal error: Uncaught exception 'Exception' with message 'Can't open reports/4-March.xls. It may be in use or protected.' in /home/john/public_html/PHPExcel/Shared/OLE/PPS/Root.php:93
Stack trace:
#0 /home/john/public_html/PHPExcel/Writer/Excel5.php(233): PHPExcel_Shared_OLE_PPS_Root->save('reports/...')
#1 /home/john/public_html/include/generate_daily_excel.inc(401): PHPExcel_Writer_Excel5->save('reports/...')
#2 /home/john/public_html/include/tests/mailme.php(41): generateDailyExcel('04-02-2013')
#3 {main}
thrown in /home/john/public_html/PHPExcel/Shared/OLE/PPS/Root.php on line 93
Fatal error: Uncaught exception 'Exception' with message 'Can't open reports/4-March.xls. It may be in use or protected.' in /home/john/public_html/PHPExcel/Shared/OLE/PPS/Root.php:93
Stack trace:
#0 /home/john/public_html/PHPExcel/Writer/Excel5.php(233): PHPExcel_Shared_OLE_PPS_Root->save('reports/...')
#1 /home/john/public_html/include/generate_daily_excel.inc(401): PHPExcel_Writer_Excel5->save('reports/...')
#2 /home/john/public_html/include/tests/mailme.php(41): generateDailyExcel('04-02-2013')
#3 {main}
thrown in /home/john/public_html/PHPExcel/Shared/OLE/PPS/Root.php on line 93
I assume that if I change the owner of reports, the browser version will not be allowed to save. I'm new to linux and rights.
When you run php code from command line. The script runs with your user permission , not with www-data user permissions.
You should run script as root (not recommend) , or instead change the file permissions:
sudo chown yourUser:www-data file
sudo chmod 664 file
And you should do nearly the same with the directory:
sudo chown yourUser:www-data dir
sudo chmod 775 dir
The error is laid out very explicitely for you: "failed to open stream: Permission denied". When you are running this from the command line, you are user "john" (I assume from your home path). Does user "john" have permission to write in the reports directory?
What are the permissions of the actual reports directory?
ls -al /home/john/public_html/reports