I am new to Magento and have just installed Magento 2.3 on Ubuntu 18.04. Magento is up and running, but I have some issues getting it to work correctly.
I notice that Magento will make a directoy called 'generated' in the main installation dir and then generate more subfolders and files under this 'generated' directory.
My problem is that sometimes this 'generated' folder, or a subfolder, has 'root' as owner and file permission is 775 (i think). This means that if the user 'www-data' (who runs the webserver) tries to create a file or folder under one of the folders owned by 'root' permission is denied.
Why are the files/folders sometimes owned by 'root' and other times owned by 'www-data'?
How can I fix this issue to make sure the generation of files/folders never fails?
Thanks in advance for any help!!
Solved! Go to Solution.
Thanks for help, but I think I have solved the problem.
I had run 'magento cron:install' as root, so when cron was generating files/directories Apache didnt have write permission to the generated directories.
I thought Apache was generating the files/folders as 'root' and that was what was confusing me
Have you tried setting the file system ownership as described in https://devdocs.magento.com/guides/v2.3/cloud/before/before-workspace-file-sys-owner.html ?
Hello @dala_dahlgren ,
I think you have to give me permission at once below way
find . -type f -exec chmod 644 {} \; find . -type d -exec chmod 755 {} \; find ./var -type d -exec chmod 777 {} \; find ./generated -type d -exec chmod 777 {} \; find ./pub/media -type d -exec chmod 777 {} \; find ./pub/static -type d -exec chmod 777 {} \; chmod 777 ./app/etc chmod 644 ./app/etc/*.xml chown -R :<web server group> . chmod u+x bin/magento
Before give above permission, Please deploy static content by below command
php bin/magento cache:clean php bin/magento cache:flush php bin/magento setup:upgrade rm -rf pub/static/frontend/* pub/static/adminhtml/* var/cache/ var/generation/ var/page_cache/ var/view_preprocessed/ var/composer_home generated/ php -dmemory_limit=6G bin/magento setup:static-content:deploy -f chmod -Rf 777 pub/ var/ generated/ php bin/magento cache:clean
--
If my answer is useful, please Accept as Solution & give Kudos
Thanks for help, but I think I have solved the problem.
I had run 'magento cron:install' as root, so when cron was generating files/directories Apache didnt have write permission to the generated directories.
I thought Apache was generating the files/folders as 'root' and that was what was confusing me