Visual Studio Coder - Unable to write to the cache directory path "./cache/production/". Ensure that the web server user

Questions about applications and software
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Post Reply
barhaqodes
Level 3
Level 3
Posts: 112
Joined: Mon Mar 27, 2023 3:33 pm

Visual Studio Coder - Unable to write to the cache directory path "./cache/production/". Ensure that the web server user

Post by barhaqodes »

Hello guys,
I have installed Visual Studio Code. First time I tried to run/debug a project - phpBB3.
This is from debug console: "Unable to write to the cache directory path "./cache/production/". Ensure that the web server user can write to the cache folder."
Does that mean ~/.cache? or ~/usr/share? or even /var/www?
Can you tell me what folder exactly I have to set permissions or chown? I have apache, mysql on Mint 21.3
dave0808
Level 5
Level 5
Posts: 987
Joined: Sat May 16, 2015 1:02 pm

Re: Visual Studio Coder - Unable to write to the cache directory path "./cache/production/". Ensure that the web server

Post by dave0808 »

It's not possible to answer your question without seeing your Apache configuration. However, if you installed phpBB in /var/www then it means /var/www/cache.

That said, when deploying a web application in Apache, it's best to do so in a separate "site" configuration which can be enabled/disabled as required. As part of that configuration you will specify the top level directory (DocumentRoot) where the application is stored. This should not be part of your home directory, nor /var/www, but somewhere else. It could be in /usr/local/share/www/phpbb or /home/www/phpbb for example.

To protect your system, this directory should be owned (and grouped) by the user www-data, which is what Apache uses to access files on the system.
barhaqodes
Level 3
Level 3
Posts: 112
Joined: Mon Mar 27, 2023 3:33 pm

Re: Visual Studio Coder - Unable to write to the cache directory path "./cache/production/". Ensure that the web server

Post by barhaqodes »

but why then the DocumentRoot directory is /var/www/html by default?

it's not clear to me if I set the directory owned by www-data ... /var/www/ to 774 I cannot read it or cd to it. But I understood no one of users should read it for savfety reasons. So how could I brows files then, because I am user, not www-data, not root. I cannot use command sudo cd www ... and it would be so bad to write in front of every command sudo...
barhaqodes
Level 3
Level 3
Posts: 112
Joined: Mon Mar 27, 2023 3:33 pm

Re: Visual Studio Coder - Unable to write to the cache directory path "./cache/production/". Ensure that the web server

Post by barhaqodes »

Also regarding debuging if I set chmod 777 to www-data:www-data folder www,
then I can run the VSC debugger. I added a breakpoint to the index.php but even that no errors are present there, I don't see it running. Should I expect it to see it step by step debugging in the VSC? And there should I expect the output? Is it necessary to set Browser in config to view the results?
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Visual Studio Coder - Unable to write to the cache directory path "./cache/production/". Ensure that the web server

Post by AndyMH »

This may be a complete red herring, my web development needs are limited (as are my skills). I have the live server extension installed in VScode. When I "go live", it opens my browser showing the end result. Every time I make a change and save it gets updated in my browser. It has made my life in this area a lot easier.
Workspace 1_002.png
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
barhaqodes
Level 3
Level 3
Posts: 112
Joined: Mon Mar 27, 2023 3:33 pm

Re: Visual Studio Coder - Unable to write to the cache directory path "./cache/production/". Ensure that the web server

Post by barhaqodes »

I have the live server install and enabled. I check it again and they have some help there. I see there should be same bar with icons to run the live server. I can use hotkey alt+l, alt+o to start the live server. Vivaldi opened on server location in folder of phpBB3, then I click on index.php and I got dialog window to download the file. This doen't look like it is connected to apache. Maybe it uses incorrect port? OK, I got it. Live Server is for static websites only. Not for php.
User avatar
AndyMH
Level 21
Level 21
Posts: 13759
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Visual Studio Coder - Unable to write to the cache directory path "./cache/production/". Ensure that the web server

Post by AndyMH »

barhaqodes wrote: Tue Mar 26, 2024 5:21 pm Not for php.
Well I have learnt something.
Thinkcentre M720Q - LM21.3 cinnamon, 4 x T430 - LM21.3 cinnamon, Homebrew desktop i5-8400+GTX1080 Cinnamon 19.0
dave0808
Level 5
Level 5
Posts: 987
Joined: Sat May 16, 2015 1:02 pm

Re: Visual Studio Coder - Unable to write to the cache directory path "./cache/production/". Ensure that the web server

Post by dave0808 »

barhaqodes wrote: Tue Mar 26, 2024 3:41 pm but why then the DocumentRoot directory is /var/www/html by default?
It's where you would put your static pages.

Of course, if you want to, you can put your phpBB in there, it's just not the best practice for a live site accessible to the world. Consider a website that has some static information, it runs a CMS, a forum, a photo gallery. These things should be in separate "sites" so that they can be enabled/disabled as necessary without affecting the rest of the website.

Or, perhaps you are testing phpBB this month, and later on you're going to move onto test another forum application. Again, separate sites are better for this.

If you are only ever going to have this instance of phpBB and nothing else, then by all means use /var/www/html.
barhaqodes wrote: Tue Mar 26, 2024 3:41 pm it's not clear to me if I set the directory owned by www-data ... /var/www/ to 774 I cannot read it or cd to it. But I understood no one of users should read it for savfety reasons. So how could I brows files then, because I am user, not www-data, not root. I cannot use command sudo cd www ... and it would be so bad to write in front of every command sudo...
Set all files to be owned by you, grouped by www-data, then mode 750 for all directories, 640 for all files. Then set mode 770/660 for directories/files that www-data needs to write to.
barhaqodes wrote: Tue Mar 26, 2024 3:44 pm then I can run the VSC debugger. I added a breakpoint to the index.php but even that no errors are present there, I don't see it running. Should I expect it to see it step by step debugging in the VSC?
It's Apache that's running the web application not VSC, so you'll need to setup remote (process) debugging. For php that requires something like Xdebug, but I've never used it so can't help further.
Post Reply

Return to “Software & Applications”