After I installed fresh magento ( I did step by step - https://digitalstartup.co.uk/magento/how-to-install-magento-23/)
Everything is good, and everything is working very well.
For example, I select magento user and If I run this chmod command,
chmod -R 777 var
I saw this issue:
chmod: changing permissions of ‘XXXXX’: Operation not permitted
You should not need to change anything to 777. I’m not sure why you would do that.
If you are seeing this error (chmod: changing permissions of ‘XXXXX’: Operation not permitted), whilst trying to run the command as magento user then it means:
During the installation process you didn’t switch users before running some of the commands - So all of the ownerships are incorrect
If you type ls -l /var/www/html/ in the command line, it will show a list of everything in your web directory. If your magento user and file owners don’t match, then this confirms the the reason.
It’s extremely important that you double-check each step before executing a command. If these don’t match then you need to completely reset the ownership of your Magento folders and files. To do this, run the following command as the superuser.
Hi Craig,
I need some help because I cannot handle my problem.
So, I installed Magento 2.3 as you did. Everything was ok, I set permisson, etc.
I did not get errors.
After I installed a theme, also was everything ok under installation process, but after installation a lot of directories and files permission were changed.
I made a photos before theme installation and after theme installation.
I see the new template well, but when I login to Magento backend and I would like to choose an other layout from this theme I get an error about permission problem.
Warning: mkdir(): Permission denied in /var/www/html/app/code/MageBig/MbFrame/Controller/Adminhtml/Theme/Save.php on line 265
I do not know how to set again that permission rigths what was before I installed the theme.
I used this command as a superuser: sudo chown -R magento:www-data /var/www/html/
and after I run sudo chown magento:www-data /var/www/html/
After I login as magento user and I used this command: find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + && find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + && chown -R :www-data . && chmod u+x bin/magento
I am confused so much, I tired a lot of varians, but my problem is did not dissapeared.
One thing:
When I installed Magento 2.2.6 as your video instruction and after I used this commands always when I installed anything and works, but this commands not work now.
find . -type f -exec chmod 644 {} ;
find . -type d -exec chmod 755 {} ;
find ./var -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
The following 2 commands (as you mentioned) would normally work for an issue like the one you’ve described:
Reset Ownership and Group:
Run from any directory as superuser
sudo chown -R magento:www-data /var/www/html/
Reset Folder and File Permissions:
Run from Magento root directory as magento user
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + && find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + && chmod u+x bin/magento
So let’s dig a little deeper into the following error:
“Warning: mkdir(): Permission denied in /var/www/html/app/code/MageBig/MbFrame/Controller/Adminhtml/Theme/Save.php on line 265”
This would suggest that either the Ownership, Group or File Permissions are incorrect. Therefore when Magento tries to make a new directory, it can’t. But obviously that shouldn’t be the case as you’ve already reset those with the above commands.
Apparently, on line 265 there is a command being executed (probably make directory). This gives us 2 things to go on.
First, you should see what the code is for line 265 of the Save.php file. This can be done by opening the Save.php file in nano and jumping to line 256:
I checked system.log and same message than I pasted in the first comment.
I paste few lines from about this save.php file. This is the 265 line, but you can see this part to see all codes.
265 line is:
mkdir($pathDir, 0755, true);
"protected function createLess($pathDir, $dataValue)
{
$section = 'mbdesign';
$pathToLessFile = $pathDir . '_' . $section . '.less';
if (!is_dir($pathDir)) {
mkdir($pathDir, 0755, true);
}
if (!is_writable($pathDir)) {
@chmod($pathDir, '0755');
}
if (is_file($pathToLessFile) && !is_writable($pathToLessFile)) {
@chmod($pathToLessFile, '0644');
}
$file = @fopen($pathToLessFile, 'w') or die('error: Can not open ' . $pathToLessFile . ' file');
$configs = [];
//$settingHelper = $this->_objectManager->get('\MageBig\MbFrame\Helper\Data');"
@digitalstartup
Of course.
To tell the truth, I restored the image from snapshot (digitalocean)so, this is a fresh status after I installed the theme but I did not run permission commands, only when you ran in the video.
So, If I understand well you say me that all permission is ok?
Pls. explain me again this two command works:
sudo chown magento:www-data /var/www/html/ - Is this command give owner rigths for magento user.
If I would like to reset this rights, I run sudo chown -R magento:www-data /var/www/html/ ??
Furtermore, is this long comands set the permission for this files and directories?
find var generated vendor pub/static pub/media app/etc -type f -exec chmod g+w {} + && find var generated vendor pub/static pub/media app/etc -type d -exec chmod g+ws {} + && chown -R :www-data . && chmod u+x bin/magento
By the way, I see the before last line chown -R… Could you explain what does it mean? We take the right from www-data?
Sorry for the late response.
Craig, your explanation is fantastic.
I appreciate your detailed answer for my problem.
Solution was the following:
I set only /app/design folders permission.
755 and 644 change to 775 and 664.
As a matter of fact, your videos are impressive and very useful. I learned much more from your videos than from all of others in the web.
Thank you so much and I hope you to continue this way.