Change default Document Root path in cent os 7












1














I have cento os 7 and installing php website and by default i have to upload code to /var/www/html but i want my code to pick from /home/magento.



How to rewrite Document Root path in cento os .










share|improve this question
















bumped to the homepage by Community 2 days ago


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















  • I'm just revisiting some questions, how did you get on with this?
    – I_GNU_it_all_along
    Nov 11 '16 at 16:09
















1














I have cento os 7 and installing php website and by default i have to upload code to /var/www/html but i want my code to pick from /home/magento.



How to rewrite Document Root path in cento os .










share|improve this question
















bumped to the homepage by Community 2 days ago


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















  • I'm just revisiting some questions, how did you get on with this?
    – I_GNU_it_all_along
    Nov 11 '16 at 16:09














1












1








1







I have cento os 7 and installing php website and by default i have to upload code to /var/www/html but i want my code to pick from /home/magento.



How to rewrite Document Root path in cento os .










share|improve this question















I have cento os 7 and installing php website and by default i have to upload code to /var/www/html but i want my code to pick from /home/magento.



How to rewrite Document Root path in cento os .







centos apache-httpd






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 15 '16 at 12:34









I_GNU_it_all_along

1,127420




1,127420










asked Sep 15 '16 at 11:29









Pradeep SankuPradeep Sanku

10615




10615





bumped to the homepage by Community 2 days 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 2 days ago


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














  • I'm just revisiting some questions, how did you get on with this?
    – I_GNU_it_all_along
    Nov 11 '16 at 16:09


















  • I'm just revisiting some questions, how did you get on with this?
    – I_GNU_it_all_along
    Nov 11 '16 at 16:09
















I'm just revisiting some questions, how did you get on with this?
– I_GNU_it_all_along
Nov 11 '16 at 16:09




I'm just revisiting some questions, how did you get on with this?
– I_GNU_it_all_along
Nov 11 '16 at 16:09










2 Answers
2






active

oldest

votes


















0














You can change the DocumentRoot directive in your httpd.conf (this should be found in /etc).



The file should contain a line like:



DocumentRoot "/var/www/html"


Change it to:



DocumentRoot "/home/magento"


If you add more directories in different locations that you want published you'll need to start making use of VirtualHost files



Also, if SELinux is set to enforcing, you'll need to set the SELinux context of the directory to match that of your /var/www directory. To find out whether or not SELinux is in operation use:



getenforce


If the output is "permissive" then it's not enforcing.



If the output is "enforcing" then it's enforcing.



In order to change the context of the directory and its contents run the following:



semanage -a -t httpd_sys_content_t "/home/magento(/.*)?"


Now when you run ls -dZ /home/magento the "httpd_sys_content_t" context should be present in the output.



You will likely also have to set an SELinux boolean to allow publishing home dirs. To do this use:



setsebool -P httpd_enable_homedirs true


Note: the apache user will also need permissions to read the directory's contents.






share|improve this answer























  • i had changed documentroot to /home/magento and still website is not picking from /home/magento
    – Pradeep Sanku
    Sep 15 '16 at 11:45










  • Have you checked if SELinux is enforcing?
    – I_GNU_it_all_along
    Sep 15 '16 at 11:46










  • i didnt undersand what to do with SELinux is set to enforcing. i had checked getenforce it outputs enforcing
    – Pradeep Sanku
    Sep 15 '16 at 11:46










  • its enforcing...
    – Pradeep Sanku
    Sep 15 '16 at 11:46










  • Edited my answer with some more info.
    – I_GNU_it_all_along
    Sep 15 '16 at 12:02



















0














Use these commands one by one:



chcon -R --reference=/var/www/html/ /home/magento 
chcon -R -t httpd_sys_content_t /home/magento/
semanage fcontext -a -t httpd_sys_content_t "/home/magento(/.*)?"
setsebool -P httpd_enable_homedirs true
chmod 755 /home/magento # important !!
service httpd restart





share|improve this answer























    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%2f310070%2fchange-default-document-root-path-in-cent-os-7%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    You can change the DocumentRoot directive in your httpd.conf (this should be found in /etc).



    The file should contain a line like:



    DocumentRoot "/var/www/html"


    Change it to:



    DocumentRoot "/home/magento"


    If you add more directories in different locations that you want published you'll need to start making use of VirtualHost files



    Also, if SELinux is set to enforcing, you'll need to set the SELinux context of the directory to match that of your /var/www directory. To find out whether or not SELinux is in operation use:



    getenforce


    If the output is "permissive" then it's not enforcing.



    If the output is "enforcing" then it's enforcing.



    In order to change the context of the directory and its contents run the following:



    semanage -a -t httpd_sys_content_t "/home/magento(/.*)?"


    Now when you run ls -dZ /home/magento the "httpd_sys_content_t" context should be present in the output.



    You will likely also have to set an SELinux boolean to allow publishing home dirs. To do this use:



    setsebool -P httpd_enable_homedirs true


    Note: the apache user will also need permissions to read the directory's contents.






    share|improve this answer























    • i had changed documentroot to /home/magento and still website is not picking from /home/magento
      – Pradeep Sanku
      Sep 15 '16 at 11:45










    • Have you checked if SELinux is enforcing?
      – I_GNU_it_all_along
      Sep 15 '16 at 11:46










    • i didnt undersand what to do with SELinux is set to enforcing. i had checked getenforce it outputs enforcing
      – Pradeep Sanku
      Sep 15 '16 at 11:46










    • its enforcing...
      – Pradeep Sanku
      Sep 15 '16 at 11:46










    • Edited my answer with some more info.
      – I_GNU_it_all_along
      Sep 15 '16 at 12:02
















    0














    You can change the DocumentRoot directive in your httpd.conf (this should be found in /etc).



    The file should contain a line like:



    DocumentRoot "/var/www/html"


    Change it to:



    DocumentRoot "/home/magento"


    If you add more directories in different locations that you want published you'll need to start making use of VirtualHost files



    Also, if SELinux is set to enforcing, you'll need to set the SELinux context of the directory to match that of your /var/www directory. To find out whether or not SELinux is in operation use:



    getenforce


    If the output is "permissive" then it's not enforcing.



    If the output is "enforcing" then it's enforcing.



    In order to change the context of the directory and its contents run the following:



    semanage -a -t httpd_sys_content_t "/home/magento(/.*)?"


    Now when you run ls -dZ /home/magento the "httpd_sys_content_t" context should be present in the output.



    You will likely also have to set an SELinux boolean to allow publishing home dirs. To do this use:



    setsebool -P httpd_enable_homedirs true


    Note: the apache user will also need permissions to read the directory's contents.






    share|improve this answer























    • i had changed documentroot to /home/magento and still website is not picking from /home/magento
      – Pradeep Sanku
      Sep 15 '16 at 11:45










    • Have you checked if SELinux is enforcing?
      – I_GNU_it_all_along
      Sep 15 '16 at 11:46










    • i didnt undersand what to do with SELinux is set to enforcing. i had checked getenforce it outputs enforcing
      – Pradeep Sanku
      Sep 15 '16 at 11:46










    • its enforcing...
      – Pradeep Sanku
      Sep 15 '16 at 11:46










    • Edited my answer with some more info.
      – I_GNU_it_all_along
      Sep 15 '16 at 12:02














    0












    0








    0






    You can change the DocumentRoot directive in your httpd.conf (this should be found in /etc).



    The file should contain a line like:



    DocumentRoot "/var/www/html"


    Change it to:



    DocumentRoot "/home/magento"


    If you add more directories in different locations that you want published you'll need to start making use of VirtualHost files



    Also, if SELinux is set to enforcing, you'll need to set the SELinux context of the directory to match that of your /var/www directory. To find out whether or not SELinux is in operation use:



    getenforce


    If the output is "permissive" then it's not enforcing.



    If the output is "enforcing" then it's enforcing.



    In order to change the context of the directory and its contents run the following:



    semanage -a -t httpd_sys_content_t "/home/magento(/.*)?"


    Now when you run ls -dZ /home/magento the "httpd_sys_content_t" context should be present in the output.



    You will likely also have to set an SELinux boolean to allow publishing home dirs. To do this use:



    setsebool -P httpd_enable_homedirs true


    Note: the apache user will also need permissions to read the directory's contents.






    share|improve this answer














    You can change the DocumentRoot directive in your httpd.conf (this should be found in /etc).



    The file should contain a line like:



    DocumentRoot "/var/www/html"


    Change it to:



    DocumentRoot "/home/magento"


    If you add more directories in different locations that you want published you'll need to start making use of VirtualHost files



    Also, if SELinux is set to enforcing, you'll need to set the SELinux context of the directory to match that of your /var/www directory. To find out whether or not SELinux is in operation use:



    getenforce


    If the output is "permissive" then it's not enforcing.



    If the output is "enforcing" then it's enforcing.



    In order to change the context of the directory and its contents run the following:



    semanage -a -t httpd_sys_content_t "/home/magento(/.*)?"


    Now when you run ls -dZ /home/magento the "httpd_sys_content_t" context should be present in the output.



    You will likely also have to set an SELinux boolean to allow publishing home dirs. To do this use:



    setsebool -P httpd_enable_homedirs true


    Note: the apache user will also need permissions to read the directory's contents.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Sep 15 '16 at 12:02

























    answered Sep 15 '16 at 11:34









    I_GNU_it_all_alongI_GNU_it_all_along

    1,127420




    1,127420












    • i had changed documentroot to /home/magento and still website is not picking from /home/magento
      – Pradeep Sanku
      Sep 15 '16 at 11:45










    • Have you checked if SELinux is enforcing?
      – I_GNU_it_all_along
      Sep 15 '16 at 11:46










    • i didnt undersand what to do with SELinux is set to enforcing. i had checked getenforce it outputs enforcing
      – Pradeep Sanku
      Sep 15 '16 at 11:46










    • its enforcing...
      – Pradeep Sanku
      Sep 15 '16 at 11:46










    • Edited my answer with some more info.
      – I_GNU_it_all_along
      Sep 15 '16 at 12:02


















    • i had changed documentroot to /home/magento and still website is not picking from /home/magento
      – Pradeep Sanku
      Sep 15 '16 at 11:45










    • Have you checked if SELinux is enforcing?
      – I_GNU_it_all_along
      Sep 15 '16 at 11:46










    • i didnt undersand what to do with SELinux is set to enforcing. i had checked getenforce it outputs enforcing
      – Pradeep Sanku
      Sep 15 '16 at 11:46










    • its enforcing...
      – Pradeep Sanku
      Sep 15 '16 at 11:46










    • Edited my answer with some more info.
      – I_GNU_it_all_along
      Sep 15 '16 at 12:02
















    i had changed documentroot to /home/magento and still website is not picking from /home/magento
    – Pradeep Sanku
    Sep 15 '16 at 11:45




    i had changed documentroot to /home/magento and still website is not picking from /home/magento
    – Pradeep Sanku
    Sep 15 '16 at 11:45












    Have you checked if SELinux is enforcing?
    – I_GNU_it_all_along
    Sep 15 '16 at 11:46




    Have you checked if SELinux is enforcing?
    – I_GNU_it_all_along
    Sep 15 '16 at 11:46












    i didnt undersand what to do with SELinux is set to enforcing. i had checked getenforce it outputs enforcing
    – Pradeep Sanku
    Sep 15 '16 at 11:46




    i didnt undersand what to do with SELinux is set to enforcing. i had checked getenforce it outputs enforcing
    – Pradeep Sanku
    Sep 15 '16 at 11:46












    its enforcing...
    – Pradeep Sanku
    Sep 15 '16 at 11:46




    its enforcing...
    – Pradeep Sanku
    Sep 15 '16 at 11:46












    Edited my answer with some more info.
    – I_GNU_it_all_along
    Sep 15 '16 at 12:02




    Edited my answer with some more info.
    – I_GNU_it_all_along
    Sep 15 '16 at 12:02













    0














    Use these commands one by one:



    chcon -R --reference=/var/www/html/ /home/magento 
    chcon -R -t httpd_sys_content_t /home/magento/
    semanage fcontext -a -t httpd_sys_content_t "/home/magento(/.*)?"
    setsebool -P httpd_enable_homedirs true
    chmod 755 /home/magento # important !!
    service httpd restart





    share|improve this answer




























      0














      Use these commands one by one:



      chcon -R --reference=/var/www/html/ /home/magento 
      chcon -R -t httpd_sys_content_t /home/magento/
      semanage fcontext -a -t httpd_sys_content_t "/home/magento(/.*)?"
      setsebool -P httpd_enable_homedirs true
      chmod 755 /home/magento # important !!
      service httpd restart





      share|improve this answer


























        0












        0








        0






        Use these commands one by one:



        chcon -R --reference=/var/www/html/ /home/magento 
        chcon -R -t httpd_sys_content_t /home/magento/
        semanage fcontext -a -t httpd_sys_content_t "/home/magento(/.*)?"
        setsebool -P httpd_enable_homedirs true
        chmod 755 /home/magento # important !!
        service httpd restart





        share|improve this answer














        Use these commands one by one:



        chcon -R --reference=/var/www/html/ /home/magento 
        chcon -R -t httpd_sys_content_t /home/magento/
        semanage fcontext -a -t httpd_sys_content_t "/home/magento(/.*)?"
        setsebool -P httpd_enable_homedirs true
        chmod 755 /home/magento # important !!
        service httpd restart






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 24 '17 at 11:59









        Archemar

        19.7k93570




        19.7k93570










        answered Nov 24 '17 at 11:28









        Rahul NagpalRahul Nagpal

        1




        1






























            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.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • 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%2f310070%2fchange-default-document-root-path-in-cent-os-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 reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

            is 'sed' thread safe

            How to make a Squid Proxy server?