I accidentally delete the pub/static by running the command "rm -rf pub/static*" instead of "rm -rf pub/static/*". Now, i need to run "setup:static-content:deploy -f "in developer mode every time I deleted the static folder. i tried copy and paste the .htaccess file actually the whole pub folder from the magento sample data to my current project, but the issue is not fixed. any tips will be greatly thankful.

  • magento version 2.2.7 – kevin Mar 28 '19 at 18:54

It is not advisable to provide full access 777 to pub directory. Instead use this command in developer mode to provide write access to the pub directory

find var generated pub/static pub/media app/etc -type f -exec chmod g+w {} + && find var generated pub/static pub/media app/etc -type d -exec chmod g+ws {} +

Execute this command as a root user from the Magento root directory. Once done change the ownership of Magento directory to Magento user. So you can execute static-content deploy in developer mode as Magento user without any permission issues.

Please find the two links which you useful to set the pre installation and ownership access to Magento directory, files systems access permission commands in developer and production modes.



| improve this answer | |

You need the create permissions:

chmod -Rf 777 ./pub/static

Please read this article from Magento Devdoc.

| improve this answer | |

Thanks for all answer. I fixed the issues just after i posted the question. so didnt have chance to try all your tips. The way i fixed my issues is i deleted Magento core folder in the vendor folder and run composer install. sorry for replying back late. again thank for answering the question.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.