Cannot change permissions for path "/var/www/html/magento2/pub/media/captcha/admin" Warning!chmod(): Operation not permitted
#0 /var/www/html/magento2/lib/internal/Magento/Framework/Filesystem/Directory/Write.php(191): Magento\Framework\Filesystem\Driver\File->changePermissions('/var/www/html/m...', 504)
#1 /var/www/html/magento2/app/code/Magento/Captcha/Helper/Data.php(153): Magento\Framework\Filesystem\Directory\Write->changePermissions('/captcha/admin', 504)
#2 /var/www/html/magento2/app/code/Magento/Captcha/Model/DefaultModel.php(280): Magento\Captcha\Helper\Data->getImgDir()
#3 /var/www/html/magento2/vendor/magento/zendframework1/library/Zend/Captcha/Image.php(441): Magento\Captcha\Model\DefaultModel->getImgDir()
#4 /var/www/html/magento2/app/code/Magento/Captcha/Block/Captcha/DefaultCaptcha.php(73): Zend_Captcha_Image->generate()
#5 /var/www/html/magento2/lib/internal/Magento/Framework/View/Element/AbstractBlock.php(652): Magento\Captcha\Block\Captcha\DefaultCaptcha->_toHtml()
#6 /var/www/html/magento2/app/code/Magento/Captcha/Block/Captcha.php(48): Magento\Framework\View\Element\AbstractBlock->toHtml()
#7 /var/www/html/magento2/lib/internal/Magento/Framework/View/Element/AbstractBlock.php(652): Magento\Captcha\Block\Captcha->_toHtml()
#8 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(542): Magento\Framework\View\Element\AbstractBlock->toHtml()
#9 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(518): Magento\Framework\View\Layout->_renderBlock('captcha')
#10 /var/www/html/magento2/var/generation/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('captcha')
#11 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(472): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('captcha')
#12 /var/www/html/magento2/var/generation/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('captcha', true)
#13 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(569): Magento\Framework\View\Layout\Interceptor->renderElement('captcha')
#14 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(520): Magento\Framework\View\Layout->_renderContainer('form.additional...')
#15 /var/www/html/magento2/var/generation/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('form.additional...')
#16 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(472): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('form.additional...')
#17 /var/www/html/magento2/var/generation/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('form.additional...', true)
#18 /var/www/html/magento2/lib/internal/Magento/Framework/View/Element/AbstractBlock.php(492): Magento\Framework\View\Layout\Interceptor->renderElement('form.additional...', true)
#19 /var/www/html/magento2/app/code/Magento/Backend/view/adminhtml/templates/admin/login.phtml(47): Magento\Framework\View\Element\AbstractBlock->getChildHtml('form.additional...')
#20 /var/www/html/magento2/lib/internal/Magento/Framework/View/TemplateEngine/Php.php(59): include('/var/www/html/m...')
#21 /var/www/html/magento2/lib/internal/Magento/Framework/View/Element/Template.php(255): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Backend\Block\Template), '/var/www/html/m...', Array)
#22 /var/www/html/magento2/lib/internal/Magento/Framework/View/Element/Template.php(279): Magento\Framework\View\Element\Template->fetchView('/var/www/html/m...')
#23 /var/www/html/magento2/app/code/Magento/Backend/Block/Template.php(104): Magento\Framework\View\Element\Template->_toHtml()
#24 /var/www/html/magento2/lib/internal/Magento/Framework/View/Element/AbstractBlock.php(652): Magento\Backend\Block\Template->_toHtml()
#25 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(542): Magento\Framework\View\Element\AbstractBlock->toHtml()
#26 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(518): Magento\Framework\View\Layout->_renderBlock('admin.login')
#27 /var/www/html/magento2/var/generation/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('admin.login')
#28 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(472): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('admin.login')
#29 /var/www/html/magento2/var/generation/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('admin.login', true)
#30 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(569): Magento\Framework\View\Layout\Interceptor->renderElement('admin.login')
#31 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(520): Magento\Framework\View\Layout->_renderContainer('login.content')
#32 /var/www/html/magento2/var/generation/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('login.content')
#33 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(472): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('login.content')
#34 /var/www/html/magento2/var/generation/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('login.content', true)
#35 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(569): Magento\Framework\View\Layout\Interceptor->renderElement('login.content')
#36 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(520): Magento\Framework\View\Layout->_renderContainer('root')
#37 /var/www/html/magento2/var/generation/Magento/Framework/View/Layout/Interceptor.php(206): Magento\Framework\View\Layout->renderNonCachedElement('root')
#38 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(472): Magento\Framework\View\Layout\Interceptor->renderNonCachedElement('root')
#39 /var/www/html/magento2/var/generation/Magento/Framework/View/Layout/Interceptor.php(193): Magento\Framework\View\Layout->renderElement('root', true)
#40 /var/www/html/magento2/lib/internal/Magento/Framework/View/Layout.php(938): Magento\Framework\View\Layout\Interceptor->renderElement('root')
#41 /var/www/html/magento2/var/generation/Magento/Framework/View/Layout/Interceptor.php(492): Magento\Framework\View\Layout->getOutput()
#42 /var/www/html/magento2/lib/internal/Magento/Framework/View/Result/Page.php(241): Magento\Framework\View\Layout\Interceptor->getOutput()
#43 /var/www/html/magento2/lib/internal/Magento/Framework/View/Result/Layout.php(162): Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\Http\Interceptor))
#44 /var/www/html/magento2/var/generation/Magento/Backend/Model/View/Result/Page/Interceptor.php(193): Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#45 /var/www/html/magento2/lib/internal/Magento/Framework/App/Http.php(119): Magento\Backend\Model\View\Result\Page\Interceptor->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#46 /var/www/html/magento2/lib/internal/Magento/Framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#47 /var/www/html/magento2/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#48 {main}You should setup the following filesystem permissions for Magento 2: http://devdocs.magento.com/guides/v2.0/install-gde/prereq/file-system-perms.html
Hi, Dmitry_Fedyuk
Thanks very much for your help! I appreciate.
I did the steps following your suggestion http://devdocs.magento.com/guides/v2.0/install-gde/prereq/file-system-perms.html, but I still hit same error message in the Firefox browser.
Cannot change permissions for path "/var/www/html/magento2/pub/media/captcha/admin" Warning!chmod(): Operation not permitted
#0 /var/www/html/magento2/lib/internal/Magento/Framework/Filesystem/Directory/Write.php(191): Magento\Framework\Filesystem\Driver\File->changePermissions('/var/www/html/m...', 504)
#1 /var/www/html/magento2/app/code/Magento/Captcha/Helper/Data.php(153): Magento\Framework\Filesystem\Directory\Write->changePermissions('/captcha/admin', 504)
#2 /var/www/html/magento2/app/code/Magento/Captcha/Model/DefaultModel.php(280): Magento\Captcha\Helper\Data->getImgDir()
#3 /var/www/html/magento2/vendor/magento/zendframework1/library/Zend/Captcha/Image.php(441): Magento\Captcha\Model\DefaultModel->getImgDir()
#4 /var/www/html/magento2/app/code/Magento/Captcha/Block/Captcha/DefaultCaptcha.php(73): Zend_Captcha_Image->generate()
As the error is related to the file/directory ownership and permission. So I checked more details.
My machine's hostname is "test". Magento files and directories owner user name is "tester". OS: Red Hat Linux R6.
[root@test magento2]# su - apache
This account is currently not available.
You have mail in /var/spool/mail/root
[root@test magento2]# su - tester
[tester@test ~]$
[tester@test magento2]$ grep apache /etc/passwd
apache:x:48:48:Apache:/var/www:/sbin/nologin
[tester@test magento2]$ groups apache
apache : apache
During the magento2 installation, I exactly followed http://devdocs.magento.com/guides/v2.0/install-gde/prereq/apache-user.html and did:
1. adduser tester
Note: This user "tester" is added to own the Magento files and directories.
2. passwd tester
3.[tester@test ~]$ egrep -i '^user|^group' /etc/httpd/conf/httpd.conf
User apache
Group apache
4. usermod -g apache tester
5. [tester@test magento2]$ groups tester
tester : apache
6. Login as user root, service httpd restart
7. Checked all files and directories under /var/www/html/magento2 are owned by tester:apache.
The interesting thing is why captcha codes want to use chmod command to change the permission of "/var/www/html/magento2/pub/media/captcha/admin" which is owned by (user)tester: (group)apache then hit Operation not permitted. I guess the code tried to do this as (user)apache: (group)apache.
[tester@test magento2]$ ll /var/www/html/magento2/
total 732
......
drwxrwx---. 6 tester apache 4096 Dec 18 23:42 pub
.........
[tester@test magento2]$ ll /var/www/html/magento2/pub
total 32
......
drwxrwx---. 10 tester apache 4096 Dec 22 22:51 media
.......
[tester@test magento2]$ ll /var/www/html/magento2/pub/media
total 344
drwxrwx---. 4 tester apache 4096 Dec 20 16:30 captcha
.....
[tester@test magento2]$ ll /var/www/html/magento2/pub/media/captcha
total 8
drwxrwx---. 2 tester apache 4096 Dec 20 16:30 admin
drwxrwx---. 2 tester apache 4096 Dec 20 16:30 base
[tester@test magento2]$ ll /var/www/html/magento2/pub/media/captcha/admin
total 0
[tester@test magento2]$
Did I miss any steps?
Thanks again!