0

I have a problem that I have been looking for a solution for for a long time and I still haven't found.

I use Apache with the userdir module and somehow isolate each site/application in its respective $HOME.

However, I have two types of platforms that are escaping this "isolation", which are sites made with Wordpress and Laravel.

For Wordpress I need to give Apache (www-data) write permission for the "wp-content" folder, and for Laravel I need to give write permission for the "vendor" and "storage" folders.

This is an example:

[php:error] [pid 99340] [client 175.xxx.xxx.xxx:15954] PHP Fatal error: Uncaught ErrorException: file_put_contents(/var/www/user/public_html/storage/framework/views/3e2d446afa85e2bbfa14dffb12f4a2a7a3423ced.php): Failed to open stream: Permission denied in /var/www/user/public_html/vendor/laravel/framework/src/Illuminate/Filesystem/Filesystem.php:190 

By not granting write permission to the Apache user (www-data) I get a "500" error when accessing the site.

My intention is to not allow the Apache user to have write access to these folders, but to allow the user assigned to that $HOME to have write access.

Is there any way this can be done?

Thanks.

3
  • Yes. There are several approaches to set up more isolation between sites/applications rather than the classical shared apache setup. For example; run each site/application in it's own container and/or stop using mod_php but leverage php_fpm. For each site/application run a dedicated php_fpm instance/pool. That can allow you to run php as a different user for each site, with different settings and even different php versions. Commented Feb 14 at 14:25
  • Thanks. I wwill study about it. Commented Feb 14 at 17:33
  • To make Apache2 processes run on behalf of the user in whose directory the site is located, make sure you use mpm_itk. Then in the site settings you can specify the AssignUserID parameter with the user and group name. In this case, the processes will be launched on his behalf. You can read more about this here: mpm-itk.sesse.net Commented Feb 22 at 18:39

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.