I already updated Magento system from 2.4.0 to 2.4.4, met the same problem at Can't setup sitemap but I can’t solve it by running the commands sudo chown magento:www-data /var/www/html and sudo chmod 775 /var/www/html as the superuser “god” from within any directory.
User “god” is the superuser as “craig”
User “magento2” is the user as “magento”
The results of ls -la are same after running the above commands by those 2 users and
And I found that the “elasticsearch-7.6.0-amd64.deb” shows in red color when I was logging in as superuser “god”.
Is this folder abnormally large or has an error occurred? Please let me know the solution of setting up the sitemap and turn the folder “elasticsearch-7.6.0-amd64.deb” to normal for stable operation in the further.
Firstly, let’s address the elasticsearch files. Those are only temporary files that you would have downloaded in order to install Elasticsearch. This is why I recommended downloading the files to your “My Documents” directory (e.g. /home/god/). As they’re only used to installing elasticsearch, you don’t need them anymore. So, just delete them.
As you’ve clearly identified, magento2 user has appropriate permissions to write to the /var/www/html/ Directory However, you should ask yourself:
"But who is trying to write to the/var/www/html/Directory?"
If memory serves, crontab is responsible for actually creating the sitemap files. Therefore, in your case you should check that you have setup crontab under the correct user. Because if you accidently setup crontab up as god user (for example), then it’s god user trying to write the file, not magento2 user.
Hi Craig, thank you so much for finest efficiency of teaching.
Unfortunately I am still a beginner with less experience . The problem is still here.
I found that I might set a cron tasks by root user.
I deleted that cron tasks and emptied all users’ cron tasks with crontab -r, run sudo chown -R magento:www-data /var/www/html/ && sudo chmod 775 /var/www/html by “god” .
Finally, run bin/magento cron:install without any cron tasks by “magento2” . There is still the same situation we are facing with.
May I know more about what steps I did wrong or what should I do at the next step please?