Apache Server setup issue












0















I have installed and configured apache on RedHat 7 Image on AWS. But I have issues with permissions/ownership while uploading files by ssh using filezilla.



I Setup a ssh user and added its home dir to apache /var/www/html/ and installed Magento on it.



Original Setup:




  1. User:Group of /var/www/html/ is apache

  2. User: root / Group: apache for /var/lib/php/session dir(not sure but I think magento stores session files there as well as i get write error when owner is changed)

  3. httpd.conf User:Group is apache

  4. With these settings, cannot upload files with ftp or sftp - permission error.


When I changed to:




  1. User:Group of /var/www/html/ is ssh_user

  2. User: ssh_user / Group: ssh_user for /var/lib/php/session dir

  3. httpd.conf User:Group is ssh_user

  4. With these, i was able to upload but cache files are generated as root.


What I want is:




  1. User:Group of /var/www/html/ is ssh_user

  2. Default settings for /var/lib/php/session dir

  3. httpd.conf User:Group is apache


I want to be able to upload files through ftp or sftp by regular user.



How do i acheive this? This is the first time i have setup apache so just trying to learn how to do it right way.










share|improve this question
















bumped to the homepage by Community 19 secs ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    0















    I have installed and configured apache on RedHat 7 Image on AWS. But I have issues with permissions/ownership while uploading files by ssh using filezilla.



    I Setup a ssh user and added its home dir to apache /var/www/html/ and installed Magento on it.



    Original Setup:




    1. User:Group of /var/www/html/ is apache

    2. User: root / Group: apache for /var/lib/php/session dir(not sure but I think magento stores session files there as well as i get write error when owner is changed)

    3. httpd.conf User:Group is apache

    4. With these settings, cannot upload files with ftp or sftp - permission error.


    When I changed to:




    1. User:Group of /var/www/html/ is ssh_user

    2. User: ssh_user / Group: ssh_user for /var/lib/php/session dir

    3. httpd.conf User:Group is ssh_user

    4. With these, i was able to upload but cache files are generated as root.


    What I want is:




    1. User:Group of /var/www/html/ is ssh_user

    2. Default settings for /var/lib/php/session dir

    3. httpd.conf User:Group is apache


    I want to be able to upload files through ftp or sftp by regular user.



    How do i acheive this? This is the first time i have setup apache so just trying to learn how to do it right way.










    share|improve this question
















    bumped to the homepage by Community 19 secs ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0








      I have installed and configured apache on RedHat 7 Image on AWS. But I have issues with permissions/ownership while uploading files by ssh using filezilla.



      I Setup a ssh user and added its home dir to apache /var/www/html/ and installed Magento on it.



      Original Setup:




      1. User:Group of /var/www/html/ is apache

      2. User: root / Group: apache for /var/lib/php/session dir(not sure but I think magento stores session files there as well as i get write error when owner is changed)

      3. httpd.conf User:Group is apache

      4. With these settings, cannot upload files with ftp or sftp - permission error.


      When I changed to:




      1. User:Group of /var/www/html/ is ssh_user

      2. User: ssh_user / Group: ssh_user for /var/lib/php/session dir

      3. httpd.conf User:Group is ssh_user

      4. With these, i was able to upload but cache files are generated as root.


      What I want is:




      1. User:Group of /var/www/html/ is ssh_user

      2. Default settings for /var/lib/php/session dir

      3. httpd.conf User:Group is apache


      I want to be able to upload files through ftp or sftp by regular user.



      How do i acheive this? This is the first time i have setup apache so just trying to learn how to do it right way.










      share|improve this question
















      I have installed and configured apache on RedHat 7 Image on AWS. But I have issues with permissions/ownership while uploading files by ssh using filezilla.



      I Setup a ssh user and added its home dir to apache /var/www/html/ and installed Magento on it.



      Original Setup:




      1. User:Group of /var/www/html/ is apache

      2. User: root / Group: apache for /var/lib/php/session dir(not sure but I think magento stores session files there as well as i get write error when owner is changed)

      3. httpd.conf User:Group is apache

      4. With these settings, cannot upload files with ftp or sftp - permission error.


      When I changed to:




      1. User:Group of /var/www/html/ is ssh_user

      2. User: ssh_user / Group: ssh_user for /var/lib/php/session dir

      3. httpd.conf User:Group is ssh_user

      4. With these, i was able to upload but cache files are generated as root.


      What I want is:




      1. User:Group of /var/www/html/ is ssh_user

      2. Default settings for /var/lib/php/session dir

      3. httpd.conf User:Group is apache


      I want to be able to upload files through ftp or sftp by regular user.



      How do i acheive this? This is the first time i have setup apache so just trying to learn how to do it right way.







      permissions apache-httpd sftp






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 18 '17 at 19:38









      Jeff Schaller

      39.9k1054126




      39.9k1054126










      asked Apr 18 '17 at 17:50









      Syed MudabbirSyed Mudabbir

      237




      237





      bumped to the homepage by Community 19 secs ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 19 secs ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Please check your apache httpd.conf. There you can see ServerRoot and ServerAdmin as well. There, you will be having:



          ServerRoot "/etc/httpd"
          ServerAdmin root@localhost


          Access permissions to server installation or configuration must be root as shown above and not suggested to modify.



          But, For docroot location which usually /var/www/html, User and group will be apache. It can be changed to any other user except root. It is important to change the owner for docroot or DocumentRoot directory location which is /var/www/ or /var/www/html with either apache or any other not root user.
          You can change it to user of your choice. root is not suggested to set as user and group in httpd.conf



          User apache
          Group apache


          make sure you must change the owner of docroot directory with the same user as mentioned in httpd.conf.By default the user and group are apache.
          So, you will need to change the owner of docroot directory /var/www/html to apache as shown below:



          sudo chown -vR apache. /var/www/html


          Now your website pages will start to create cache whenever you visit a webpage loaded by apache.



          In your scenario, As you are using and ssh_user as user, You can set User:Group your desired directory location and all its internal hierarchy, for.eg., for the path /var/www/html/, then you can make it with below command.



          Syntax: sudo chown -vR username:groupname {path-of-directory-location}



          sudo chown -vR ssh_user:ssh_user /var/www/html
          sudo chown -vR apache:apache /var/lib/php/session


          If you want to be able to upload or transfer files through ftp or sftp by regular user., You can use any of either FileZilla Server or WinSCP, it is suggested to login with the user owning the directory and then transfer the files.



          Make sure if you have either user or group permissions to the directory you are trying to access.






          share|improve this answer


























          • The issue here was /var/www/html is owned by apache(user/group=apache) so I am unable to upload by ftp using regular users. So root@localhost change to ssh_user@localhost?

            – Syed Mudabbir
            Apr 18 '17 at 20:45











          • @SyedMudabbir It is always suggested to perform apache using root only. It is also fine if a root user and apache are members of a same group. But again group level permissions must be proper

            – Srikanth Popuri
            Apr 18 '17 at 20:55













          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "106"
          };
          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: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          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%2funix.stackexchange.com%2fquestions%2f359747%2fapache-server-setup-issue%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














          Please check your apache httpd.conf. There you can see ServerRoot and ServerAdmin as well. There, you will be having:



          ServerRoot "/etc/httpd"
          ServerAdmin root@localhost


          Access permissions to server installation or configuration must be root as shown above and not suggested to modify.



          But, For docroot location which usually /var/www/html, User and group will be apache. It can be changed to any other user except root. It is important to change the owner for docroot or DocumentRoot directory location which is /var/www/ or /var/www/html with either apache or any other not root user.
          You can change it to user of your choice. root is not suggested to set as user and group in httpd.conf



          User apache
          Group apache


          make sure you must change the owner of docroot directory with the same user as mentioned in httpd.conf.By default the user and group are apache.
          So, you will need to change the owner of docroot directory /var/www/html to apache as shown below:



          sudo chown -vR apache. /var/www/html


          Now your website pages will start to create cache whenever you visit a webpage loaded by apache.



          In your scenario, As you are using and ssh_user as user, You can set User:Group your desired directory location and all its internal hierarchy, for.eg., for the path /var/www/html/, then you can make it with below command.



          Syntax: sudo chown -vR username:groupname {path-of-directory-location}



          sudo chown -vR ssh_user:ssh_user /var/www/html
          sudo chown -vR apache:apache /var/lib/php/session


          If you want to be able to upload or transfer files through ftp or sftp by regular user., You can use any of either FileZilla Server or WinSCP, it is suggested to login with the user owning the directory and then transfer the files.



          Make sure if you have either user or group permissions to the directory you are trying to access.






          share|improve this answer


























          • The issue here was /var/www/html is owned by apache(user/group=apache) so I am unable to upload by ftp using regular users. So root@localhost change to ssh_user@localhost?

            – Syed Mudabbir
            Apr 18 '17 at 20:45











          • @SyedMudabbir It is always suggested to perform apache using root only. It is also fine if a root user and apache are members of a same group. But again group level permissions must be proper

            – Srikanth Popuri
            Apr 18 '17 at 20:55


















          0














          Please check your apache httpd.conf. There you can see ServerRoot and ServerAdmin as well. There, you will be having:



          ServerRoot "/etc/httpd"
          ServerAdmin root@localhost


          Access permissions to server installation or configuration must be root as shown above and not suggested to modify.



          But, For docroot location which usually /var/www/html, User and group will be apache. It can be changed to any other user except root. It is important to change the owner for docroot or DocumentRoot directory location which is /var/www/ or /var/www/html with either apache or any other not root user.
          You can change it to user of your choice. root is not suggested to set as user and group in httpd.conf



          User apache
          Group apache


          make sure you must change the owner of docroot directory with the same user as mentioned in httpd.conf.By default the user and group are apache.
          So, you will need to change the owner of docroot directory /var/www/html to apache as shown below:



          sudo chown -vR apache. /var/www/html


          Now your website pages will start to create cache whenever you visit a webpage loaded by apache.



          In your scenario, As you are using and ssh_user as user, You can set User:Group your desired directory location and all its internal hierarchy, for.eg., for the path /var/www/html/, then you can make it with below command.



          Syntax: sudo chown -vR username:groupname {path-of-directory-location}



          sudo chown -vR ssh_user:ssh_user /var/www/html
          sudo chown -vR apache:apache /var/lib/php/session


          If you want to be able to upload or transfer files through ftp or sftp by regular user., You can use any of either FileZilla Server or WinSCP, it is suggested to login with the user owning the directory and then transfer the files.



          Make sure if you have either user or group permissions to the directory you are trying to access.






          share|improve this answer


























          • The issue here was /var/www/html is owned by apache(user/group=apache) so I am unable to upload by ftp using regular users. So root@localhost change to ssh_user@localhost?

            – Syed Mudabbir
            Apr 18 '17 at 20:45











          • @SyedMudabbir It is always suggested to perform apache using root only. It is also fine if a root user and apache are members of a same group. But again group level permissions must be proper

            – Srikanth Popuri
            Apr 18 '17 at 20:55
















          0












          0








          0







          Please check your apache httpd.conf. There you can see ServerRoot and ServerAdmin as well. There, you will be having:



          ServerRoot "/etc/httpd"
          ServerAdmin root@localhost


          Access permissions to server installation or configuration must be root as shown above and not suggested to modify.



          But, For docroot location which usually /var/www/html, User and group will be apache. It can be changed to any other user except root. It is important to change the owner for docroot or DocumentRoot directory location which is /var/www/ or /var/www/html with either apache or any other not root user.
          You can change it to user of your choice. root is not suggested to set as user and group in httpd.conf



          User apache
          Group apache


          make sure you must change the owner of docroot directory with the same user as mentioned in httpd.conf.By default the user and group are apache.
          So, you will need to change the owner of docroot directory /var/www/html to apache as shown below:



          sudo chown -vR apache. /var/www/html


          Now your website pages will start to create cache whenever you visit a webpage loaded by apache.



          In your scenario, As you are using and ssh_user as user, You can set User:Group your desired directory location and all its internal hierarchy, for.eg., for the path /var/www/html/, then you can make it with below command.



          Syntax: sudo chown -vR username:groupname {path-of-directory-location}



          sudo chown -vR ssh_user:ssh_user /var/www/html
          sudo chown -vR apache:apache /var/lib/php/session


          If you want to be able to upload or transfer files through ftp or sftp by regular user., You can use any of either FileZilla Server or WinSCP, it is suggested to login with the user owning the directory and then transfer the files.



          Make sure if you have either user or group permissions to the directory you are trying to access.






          share|improve this answer















          Please check your apache httpd.conf. There you can see ServerRoot and ServerAdmin as well. There, you will be having:



          ServerRoot "/etc/httpd"
          ServerAdmin root@localhost


          Access permissions to server installation or configuration must be root as shown above and not suggested to modify.



          But, For docroot location which usually /var/www/html, User and group will be apache. It can be changed to any other user except root. It is important to change the owner for docroot or DocumentRoot directory location which is /var/www/ or /var/www/html with either apache or any other not root user.
          You can change it to user of your choice. root is not suggested to set as user and group in httpd.conf



          User apache
          Group apache


          make sure you must change the owner of docroot directory with the same user as mentioned in httpd.conf.By default the user and group are apache.
          So, you will need to change the owner of docroot directory /var/www/html to apache as shown below:



          sudo chown -vR apache. /var/www/html


          Now your website pages will start to create cache whenever you visit a webpage loaded by apache.



          In your scenario, As you are using and ssh_user as user, You can set User:Group your desired directory location and all its internal hierarchy, for.eg., for the path /var/www/html/, then you can make it with below command.



          Syntax: sudo chown -vR username:groupname {path-of-directory-location}



          sudo chown -vR ssh_user:ssh_user /var/www/html
          sudo chown -vR apache:apache /var/lib/php/session


          If you want to be able to upload or transfer files through ftp or sftp by regular user., You can use any of either FileZilla Server or WinSCP, it is suggested to login with the user owning the directory and then transfer the files.



          Make sure if you have either user or group permissions to the directory you are trying to access.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Apr 21 '17 at 11:59

























          answered Apr 18 '17 at 20:36









          Srikanth PopuriSrikanth Popuri

          12




          12













          • The issue here was /var/www/html is owned by apache(user/group=apache) so I am unable to upload by ftp using regular users. So root@localhost change to ssh_user@localhost?

            – Syed Mudabbir
            Apr 18 '17 at 20:45











          • @SyedMudabbir It is always suggested to perform apache using root only. It is also fine if a root user and apache are members of a same group. But again group level permissions must be proper

            – Srikanth Popuri
            Apr 18 '17 at 20:55





















          • The issue here was /var/www/html is owned by apache(user/group=apache) so I am unable to upload by ftp using regular users. So root@localhost change to ssh_user@localhost?

            – Syed Mudabbir
            Apr 18 '17 at 20:45











          • @SyedMudabbir It is always suggested to perform apache using root only. It is also fine if a root user and apache are members of a same group. But again group level permissions must be proper

            – Srikanth Popuri
            Apr 18 '17 at 20:55



















          The issue here was /var/www/html is owned by apache(user/group=apache) so I am unable to upload by ftp using regular users. So root@localhost change to ssh_user@localhost?

          – Syed Mudabbir
          Apr 18 '17 at 20:45





          The issue here was /var/www/html is owned by apache(user/group=apache) so I am unable to upload by ftp using regular users. So root@localhost change to ssh_user@localhost?

          – Syed Mudabbir
          Apr 18 '17 at 20:45













          @SyedMudabbir It is always suggested to perform apache using root only. It is also fine if a root user and apache are members of a same group. But again group level permissions must be proper

          – Srikanth Popuri
          Apr 18 '17 at 20:55







          @SyedMudabbir It is always suggested to perform apache using root only. It is also fine if a root user and apache are members of a same group. But again group level permissions must be proper

          – Srikanth Popuri
          Apr 18 '17 at 20:55




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Unix & Linux Stack Exchange!


          • 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%2funix.stackexchange.com%2fquestions%2f359747%2fapache-server-setup-issue%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

          Loup dans la culture

          How to solve the problem of ntp “Unable to contact time server” from KDE?

          ASUS Zenbook UX433/UX333 — Configure Touchpad-embedded numpad on Linux