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

Hello! I uploaded script on the var/www/html document root, configured the virtual host on /etc/apache2/sites-available/000-default.conf by changing the document root from

DocumentRoot /var/www/html to DocumentRoot /var/www/html/myscript/public according to the docummentation of the script i bought.

Also, configured the /etc/apache2/apache2.conf by changing:

<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>


<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory>

Then restart apache using the command: sudo systemctl restart apache2

But before then I have created custom virtual host following the guide on this article:

Because of this advice by the writer below on that article:

“Apache on Ubuntu 18.04 has one server block enabled by default that is configured to serve documents from the /var/www/html directory. While this works well for a single site, it can become unwieldy if you are hosting multiple sites. Instead of modifying /var/www/html, let’s create a directory structure within /var/www for our your_domain site, leaving /var/www/html in place as the default directory to be served if a client request doesn’t match any other sites”.

After that, I uploaded the file/script on the document root of the custom virtual host I created following the above article. When I visited the site the script I uploaded appear on the browser. because of that, I deleted the custom virtual host directory from Filezilla including the app/script and also disabled the custom virtual host and enabled the default using this command:

sudo a2dissite mydomain.conf sudo a2ensite 000-default.conf

then restart using this command: sudo systemctl restart apache2

I now uploaded the script on the default one which the document root is var/www/html using Filezilla and do the configurations shown above. I also extracted the file before uploading it.

So, after everything, when I visited my site using the IP Address I found this error: “UnexpectedValueException The stream or file “/var/www/html/myapp/storage/logs/laravel.log” could not be opened: failed to open stream: Permission denied”

but when I visit the site using the domain name I also found this error: “Not Found The requested URL was not found on this server”

Again, when I uploaded the composer, I didn’t complete the rest steps, I only uploaded the composer and stopped there, I didn’t go further to set dependency and others because that part on the guide is complicated for me, I didn’t understand it at all. This is the guide below: So, I don’t know if that is part of the problem am facing now.

I also found some articles on the web to solve this error. the command given there didn’t work for me. These are the commands and the responses I got when I run them:

sudo chown -R $USER:www-data storage : No such file or directory sudo chmod -R 777 storage : No such file or directory chown -R www-data:www-data /var/www/html/laravel: No such file or directory composer install : composer could not find a composer.json in /root

Please everyone what do I do to solve this problem to get my site working fine. Thank


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.


It looks like that there is no such directory /var/www/html/laravel, that is why your chmod command is failing.

What you need to do is run the following command instead:

chown -R www-data:www-data /var/www/html

Then this should work as normal as Apache would have access to the Laravel log file.

Hope that this helps! Regards, Bobby