Make directory writable on /var/www/html (Centos 7)












0















This below question are related to my question on Stack Overflow.



I got following error when I went to generate an image on a particular directory:



imagejpeg(/var/www/html/assets/files/captcha/1465029891.5357.jpg): failed to open stream: Permission denied


I want to make the directory are writable and I’ve been use this command below to make the directory are writable but it doesn’t impact at all.



chown -R apache:apache /var/www/html/assets/files/captcha
chmod 755 /var/www/html/assets/files/captcha


Below is when I run the ps -aux|grep -i httpd:



root     30846  0.0  0.1 423604 17476 ?        Ss   15:43   0:00 /usr/sbin/httpd -DFOREGROUND
apache 30848 0.0 0.1 424024 12892 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
apache 30849 0.0 0.0 423736 10032 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
apache 30850 0.0 0.0 423912 11680 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
apache 30851 0.0 0.0 423736 9280 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
apache 30852 0.0 0.0 423736 9276 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
apache 30854 0.0 0.0 423736 9268 ? S 15:44 0:00 /usr/sbin/httpd -DFOREGROUND
apache 30855 0.0 0.0 423736 9032 ? S 15:44 0:00 /usr/sbin/httpd -DFOREGROUND
apache 30856 0.0 0.0 423736 9032 ? S 15:44 0:00 /usr/sbin/httpd -DFOREGROUND
root 30860 0.0 0.0 112648 988 pts/1 S+ 15:51 0:00 grep --color=auto -i httpd


I’ve checked on the server and it’s run by Apache, I’ve changed the user, group and changed the permissions but still get above error. Which part did I miss?










share|improve this question





























    0















    This below question are related to my question on Stack Overflow.



    I got following error when I went to generate an image on a particular directory:



    imagejpeg(/var/www/html/assets/files/captcha/1465029891.5357.jpg): failed to open stream: Permission denied


    I want to make the directory are writable and I’ve been use this command below to make the directory are writable but it doesn’t impact at all.



    chown -R apache:apache /var/www/html/assets/files/captcha
    chmod 755 /var/www/html/assets/files/captcha


    Below is when I run the ps -aux|grep -i httpd:



    root     30846  0.0  0.1 423604 17476 ?        Ss   15:43   0:00 /usr/sbin/httpd -DFOREGROUND
    apache 30848 0.0 0.1 424024 12892 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
    apache 30849 0.0 0.0 423736 10032 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
    apache 30850 0.0 0.0 423912 11680 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
    apache 30851 0.0 0.0 423736 9280 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
    apache 30852 0.0 0.0 423736 9276 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
    apache 30854 0.0 0.0 423736 9268 ? S 15:44 0:00 /usr/sbin/httpd -DFOREGROUND
    apache 30855 0.0 0.0 423736 9032 ? S 15:44 0:00 /usr/sbin/httpd -DFOREGROUND
    apache 30856 0.0 0.0 423736 9032 ? S 15:44 0:00 /usr/sbin/httpd -DFOREGROUND
    root 30860 0.0 0.0 112648 988 pts/1 S+ 15:51 0:00 grep --color=auto -i httpd


    I’ve checked on the server and it’s run by Apache, I’ve changed the user, group and changed the permissions but still get above error. Which part did I miss?










    share|improve this question



























      0












      0








      0








      This below question are related to my question on Stack Overflow.



      I got following error when I went to generate an image on a particular directory:



      imagejpeg(/var/www/html/assets/files/captcha/1465029891.5357.jpg): failed to open stream: Permission denied


      I want to make the directory are writable and I’ve been use this command below to make the directory are writable but it doesn’t impact at all.



      chown -R apache:apache /var/www/html/assets/files/captcha
      chmod 755 /var/www/html/assets/files/captcha


      Below is when I run the ps -aux|grep -i httpd:



      root     30846  0.0  0.1 423604 17476 ?        Ss   15:43   0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30848 0.0 0.1 424024 12892 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30849 0.0 0.0 423736 10032 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30850 0.0 0.0 423912 11680 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30851 0.0 0.0 423736 9280 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30852 0.0 0.0 423736 9276 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30854 0.0 0.0 423736 9268 ? S 15:44 0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30855 0.0 0.0 423736 9032 ? S 15:44 0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30856 0.0 0.0 423736 9032 ? S 15:44 0:00 /usr/sbin/httpd -DFOREGROUND
      root 30860 0.0 0.0 112648 988 pts/1 S+ 15:51 0:00 grep --color=auto -i httpd


      I’ve checked on the server and it’s run by Apache, I’ve changed the user, group and changed the permissions but still get above error. Which part did I miss?










      share|improve this question
















      This below question are related to my question on Stack Overflow.



      I got following error when I went to generate an image on a particular directory:



      imagejpeg(/var/www/html/assets/files/captcha/1465029891.5357.jpg): failed to open stream: Permission denied


      I want to make the directory are writable and I’ve been use this command below to make the directory are writable but it doesn’t impact at all.



      chown -R apache:apache /var/www/html/assets/files/captcha
      chmod 755 /var/www/html/assets/files/captcha


      Below is when I run the ps -aux|grep -i httpd:



      root     30846  0.0  0.1 423604 17476 ?        Ss   15:43   0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30848 0.0 0.1 424024 12892 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30849 0.0 0.0 423736 10032 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30850 0.0 0.0 423912 11680 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30851 0.0 0.0 423736 9280 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30852 0.0 0.0 423736 9276 ? S 15:43 0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30854 0.0 0.0 423736 9268 ? S 15:44 0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30855 0.0 0.0 423736 9032 ? S 15:44 0:00 /usr/sbin/httpd -DFOREGROUND
      apache 30856 0.0 0.0 423736 9032 ? S 15:44 0:00 /usr/sbin/httpd -DFOREGROUND
      root 30860 0.0 0.0 112648 988 pts/1 S+ 15:51 0:00 grep --color=auto -i httpd


      I’ve checked on the server and it’s run by Apache, I’ve changed the user, group and changed the permissions but still get above error. Which part did I miss?







      permissions apache-http-server centos






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited May 23 '17 at 12:41









      Community

      1




      1










      asked Jun 4 '16 at 10:49









      Amir RachmanAmir Rachman

      113




      113






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I've found a clue regarding my issue, because i use the CentOS 7, there is some security call SE Linux (Security Enhance Linux), it's hidden firewall for Centos.



          I'm following this article and my captcha working correctly right know, because they can write into the particular directory.



          https://blog.lysender.com/2015/07/centos-7-selinux-php-apache-cannot-writeaccess-file-no-matter-what/



          ---- Update ----



          sudo chown apache:apache -R /data/www/html/sites/mysite
          cd /data/www/html/sites/mysite



          find . -type f -exec chmod 0644 {} ;



          find . -type d -exec chmod 0755 {} ;



          sudo chcon -t httpd_sys_content_t /data/www/html/sites/mysite -R



          sudo chcon -t httpd_sys_rw_content_t /data/www/html/sites/mysite/logs -R
          sudo chcon -t httpd_sys_rw_content_t /data/www/html/sites/mysite/uploads -R






          share|improve this answer


























          • chcon would not survive or persist if system ever does relabelling. So better use semanage -fcontext and then restorecon

            – pun
            Jun 4 '16 at 15:15











          • so it's not permanent ?, currently it's working i hope it will still working...

            – Amir Rachman
            Jun 4 '16 at 15:31











          • Yes changes made via chcon are not permanent and they are lost upon system relabelling or running restorecon command. Read further and update your answer so that it provides more accurate and reliable information

            – pun
            Jun 4 '16 at 16:25






          • 1





            In general, it's better to make posts self-contained. Links break, in which case your answer would be just a clue. Include the essential information within the post and use the link for reference. from Low Quality Post review queue

            – fixer1234
            Jun 4 '16 at 17:54











          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1084345%2fmake-directory-writable-on-var-www-html-centos-7%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I've found a clue regarding my issue, because i use the CentOS 7, there is some security call SE Linux (Security Enhance Linux), it's hidden firewall for Centos.



          I'm following this article and my captcha working correctly right know, because they can write into the particular directory.



          https://blog.lysender.com/2015/07/centos-7-selinux-php-apache-cannot-writeaccess-file-no-matter-what/



          ---- Update ----



          sudo chown apache:apache -R /data/www/html/sites/mysite
          cd /data/www/html/sites/mysite



          find . -type f -exec chmod 0644 {} ;



          find . -type d -exec chmod 0755 {} ;



          sudo chcon -t httpd_sys_content_t /data/www/html/sites/mysite -R



          sudo chcon -t httpd_sys_rw_content_t /data/www/html/sites/mysite/logs -R
          sudo chcon -t httpd_sys_rw_content_t /data/www/html/sites/mysite/uploads -R






          share|improve this answer


























          • chcon would not survive or persist if system ever does relabelling. So better use semanage -fcontext and then restorecon

            – pun
            Jun 4 '16 at 15:15











          • so it's not permanent ?, currently it's working i hope it will still working...

            – Amir Rachman
            Jun 4 '16 at 15:31











          • Yes changes made via chcon are not permanent and they are lost upon system relabelling or running restorecon command. Read further and update your answer so that it provides more accurate and reliable information

            – pun
            Jun 4 '16 at 16:25






          • 1





            In general, it's better to make posts self-contained. Links break, in which case your answer would be just a clue. Include the essential information within the post and use the link for reference. from Low Quality Post review queue

            – fixer1234
            Jun 4 '16 at 17:54
















          0














          I've found a clue regarding my issue, because i use the CentOS 7, there is some security call SE Linux (Security Enhance Linux), it's hidden firewall for Centos.



          I'm following this article and my captcha working correctly right know, because they can write into the particular directory.



          https://blog.lysender.com/2015/07/centos-7-selinux-php-apache-cannot-writeaccess-file-no-matter-what/



          ---- Update ----



          sudo chown apache:apache -R /data/www/html/sites/mysite
          cd /data/www/html/sites/mysite



          find . -type f -exec chmod 0644 {} ;



          find . -type d -exec chmod 0755 {} ;



          sudo chcon -t httpd_sys_content_t /data/www/html/sites/mysite -R



          sudo chcon -t httpd_sys_rw_content_t /data/www/html/sites/mysite/logs -R
          sudo chcon -t httpd_sys_rw_content_t /data/www/html/sites/mysite/uploads -R






          share|improve this answer


























          • chcon would not survive or persist if system ever does relabelling. So better use semanage -fcontext and then restorecon

            – pun
            Jun 4 '16 at 15:15











          • so it's not permanent ?, currently it's working i hope it will still working...

            – Amir Rachman
            Jun 4 '16 at 15:31











          • Yes changes made via chcon are not permanent and they are lost upon system relabelling or running restorecon command. Read further and update your answer so that it provides more accurate and reliable information

            – pun
            Jun 4 '16 at 16:25






          • 1





            In general, it's better to make posts self-contained. Links break, in which case your answer would be just a clue. Include the essential information within the post and use the link for reference. from Low Quality Post review queue

            – fixer1234
            Jun 4 '16 at 17:54














          0












          0








          0







          I've found a clue regarding my issue, because i use the CentOS 7, there is some security call SE Linux (Security Enhance Linux), it's hidden firewall for Centos.



          I'm following this article and my captcha working correctly right know, because they can write into the particular directory.



          https://blog.lysender.com/2015/07/centos-7-selinux-php-apache-cannot-writeaccess-file-no-matter-what/



          ---- Update ----



          sudo chown apache:apache -R /data/www/html/sites/mysite
          cd /data/www/html/sites/mysite



          find . -type f -exec chmod 0644 {} ;



          find . -type d -exec chmod 0755 {} ;



          sudo chcon -t httpd_sys_content_t /data/www/html/sites/mysite -R



          sudo chcon -t httpd_sys_rw_content_t /data/www/html/sites/mysite/logs -R
          sudo chcon -t httpd_sys_rw_content_t /data/www/html/sites/mysite/uploads -R






          share|improve this answer















          I've found a clue regarding my issue, because i use the CentOS 7, there is some security call SE Linux (Security Enhance Linux), it's hidden firewall for Centos.



          I'm following this article and my captcha working correctly right know, because they can write into the particular directory.



          https://blog.lysender.com/2015/07/centos-7-selinux-php-apache-cannot-writeaccess-file-no-matter-what/



          ---- Update ----



          sudo chown apache:apache -R /data/www/html/sites/mysite
          cd /data/www/html/sites/mysite



          find . -type f -exec chmod 0644 {} ;



          find . -type d -exec chmod 0755 {} ;



          sudo chcon -t httpd_sys_content_t /data/www/html/sites/mysite -R



          sudo chcon -t httpd_sys_rw_content_t /data/www/html/sites/mysite/logs -R
          sudo chcon -t httpd_sys_rw_content_t /data/www/html/sites/mysite/uploads -R







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Jun 20 '16 at 3:35

























          answered Jun 4 '16 at 15:00









          Amir RachmanAmir Rachman

          113




          113













          • chcon would not survive or persist if system ever does relabelling. So better use semanage -fcontext and then restorecon

            – pun
            Jun 4 '16 at 15:15











          • so it's not permanent ?, currently it's working i hope it will still working...

            – Amir Rachman
            Jun 4 '16 at 15:31











          • Yes changes made via chcon are not permanent and they are lost upon system relabelling or running restorecon command. Read further and update your answer so that it provides more accurate and reliable information

            – pun
            Jun 4 '16 at 16:25






          • 1





            In general, it's better to make posts self-contained. Links break, in which case your answer would be just a clue. Include the essential information within the post and use the link for reference. from Low Quality Post review queue

            – fixer1234
            Jun 4 '16 at 17:54



















          • chcon would not survive or persist if system ever does relabelling. So better use semanage -fcontext and then restorecon

            – pun
            Jun 4 '16 at 15:15











          • so it's not permanent ?, currently it's working i hope it will still working...

            – Amir Rachman
            Jun 4 '16 at 15:31











          • Yes changes made via chcon are not permanent and they are lost upon system relabelling or running restorecon command. Read further and update your answer so that it provides more accurate and reliable information

            – pun
            Jun 4 '16 at 16:25






          • 1





            In general, it's better to make posts self-contained. Links break, in which case your answer would be just a clue. Include the essential information within the post and use the link for reference. from Low Quality Post review queue

            – fixer1234
            Jun 4 '16 at 17:54

















          chcon would not survive or persist if system ever does relabelling. So better use semanage -fcontext and then restorecon

          – pun
          Jun 4 '16 at 15:15





          chcon would not survive or persist if system ever does relabelling. So better use semanage -fcontext and then restorecon

          – pun
          Jun 4 '16 at 15:15













          so it's not permanent ?, currently it's working i hope it will still working...

          – Amir Rachman
          Jun 4 '16 at 15:31





          so it's not permanent ?, currently it's working i hope it will still working...

          – Amir Rachman
          Jun 4 '16 at 15:31













          Yes changes made via chcon are not permanent and they are lost upon system relabelling or running restorecon command. Read further and update your answer so that it provides more accurate and reliable information

          – pun
          Jun 4 '16 at 16:25





          Yes changes made via chcon are not permanent and they are lost upon system relabelling or running restorecon command. Read further and update your answer so that it provides more accurate and reliable information

          – pun
          Jun 4 '16 at 16:25




          1




          1





          In general, it's better to make posts self-contained. Links break, in which case your answer would be just a clue. Include the essential information within the post and use the link for reference. from Low Quality Post review queue

          – fixer1234
          Jun 4 '16 at 17:54





          In general, it's better to make posts self-contained. Links break, in which case your answer would be just a clue. Include the essential information within the post and use the link for reference. from Low Quality Post review queue

          – fixer1234
          Jun 4 '16 at 17:54


















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Super User!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1084345%2fmake-directory-writable-on-var-www-html-centos-7%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          How to make a Squid Proxy server?

          Is this a new Fibonacci Identity?

          Touch on Surface Book