Apache 2.4 vhost not working












0















We have a new Centos server installed with Apache 2.4.9. I'm trying to get the vhost working. DNS resolves to the right machine, and I can see the default Apache page, so it's not a firewall issue and Apache runs.



/etc/httpd/conf/httpd.conf



Include conf.d/*.conf


/etc/httpd/conf.d/vhosts.conf



<VirtualHost *>
ServerName www.abctest.com
DocumentRoot /websites/abctest.com/htdocs
<Directory /websites/abctest.com/htdocs/public>
AllowOverride All
</Directory>
</VirtualHost>


ls /etc/httpd/modules



modules/mod_vhost_alias.so


website



In /websites/abctest.com/htdocs is an index.php file with helloworld in it. After restarting httpd, I still get the Apache page, not the helloworld text.



How can I get this working?










share|improve this question























  • This is an old question, but the first thing you should do in a case like this is to check the output of apachectl -S which will dump your web server configuration in a quite readable format. Make sure that the vhost is listed, and if not, check to see why it isn't. The vhost will never work if it isn't included in that output.

    – a CVn
    May 28 '16 at 13:57
















0















We have a new Centos server installed with Apache 2.4.9. I'm trying to get the vhost working. DNS resolves to the right machine, and I can see the default Apache page, so it's not a firewall issue and Apache runs.



/etc/httpd/conf/httpd.conf



Include conf.d/*.conf


/etc/httpd/conf.d/vhosts.conf



<VirtualHost *>
ServerName www.abctest.com
DocumentRoot /websites/abctest.com/htdocs
<Directory /websites/abctest.com/htdocs/public>
AllowOverride All
</Directory>
</VirtualHost>


ls /etc/httpd/modules



modules/mod_vhost_alias.so


website



In /websites/abctest.com/htdocs is an index.php file with helloworld in it. After restarting httpd, I still get the Apache page, not the helloworld text.



How can I get this working?










share|improve this question























  • This is an old question, but the first thing you should do in a case like this is to check the output of apachectl -S which will dump your web server configuration in a quite readable format. Make sure that the vhost is listed, and if not, check to see why it isn't. The vhost will never work if it isn't included in that output.

    – a CVn
    May 28 '16 at 13:57














0












0








0








We have a new Centos server installed with Apache 2.4.9. I'm trying to get the vhost working. DNS resolves to the right machine, and I can see the default Apache page, so it's not a firewall issue and Apache runs.



/etc/httpd/conf/httpd.conf



Include conf.d/*.conf


/etc/httpd/conf.d/vhosts.conf



<VirtualHost *>
ServerName www.abctest.com
DocumentRoot /websites/abctest.com/htdocs
<Directory /websites/abctest.com/htdocs/public>
AllowOverride All
</Directory>
</VirtualHost>


ls /etc/httpd/modules



modules/mod_vhost_alias.so


website



In /websites/abctest.com/htdocs is an index.php file with helloworld in it. After restarting httpd, I still get the Apache page, not the helloworld text.



How can I get this working?










share|improve this question














We have a new Centos server installed with Apache 2.4.9. I'm trying to get the vhost working. DNS resolves to the right machine, and I can see the default Apache page, so it's not a firewall issue and Apache runs.



/etc/httpd/conf/httpd.conf



Include conf.d/*.conf


/etc/httpd/conf.d/vhosts.conf



<VirtualHost *>
ServerName www.abctest.com
DocumentRoot /websites/abctest.com/htdocs
<Directory /websites/abctest.com/htdocs/public>
AllowOverride All
</Directory>
</VirtualHost>


ls /etc/httpd/modules



modules/mod_vhost_alias.so


website



In /websites/abctest.com/htdocs is an index.php file with helloworld in it. After restarting httpd, I still get the Apache page, not the helloworld text.



How can I get this working?







linux centos apache-http-server






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 12 '14 at 15:33









SPRBRNSPRBRN

3,22173968




3,22173968













  • This is an old question, but the first thing you should do in a case like this is to check the output of apachectl -S which will dump your web server configuration in a quite readable format. Make sure that the vhost is listed, and if not, check to see why it isn't. The vhost will never work if it isn't included in that output.

    – a CVn
    May 28 '16 at 13:57



















  • This is an old question, but the first thing you should do in a case like this is to check the output of apachectl -S which will dump your web server configuration in a quite readable format. Make sure that the vhost is listed, and if not, check to see why it isn't. The vhost will never work if it isn't included in that output.

    – a CVn
    May 28 '16 at 13:57

















This is an old question, but the first thing you should do in a case like this is to check the output of apachectl -S which will dump your web server configuration in a quite readable format. Make sure that the vhost is listed, and if not, check to see why it isn't. The vhost will never work if it isn't included in that output.

– a CVn
May 28 '16 at 13:57





This is an old question, but the first thing you should do in a case like this is to check the output of apachectl -S which will dump your web server configuration in a quite readable format. Make sure that the vhost is listed, and if not, check to see why it isn't. The vhost will never work if it isn't included in that output.

– a CVn
May 28 '16 at 13:57










4 Answers
4






active

oldest

votes


















0














Try putting a specific ip and port in each of your VirtualHost blocks. So put:



<VirtualHost 127.0.0.1:80>





share|improve this answer































    0














    Your VirtualHost configuration indicates that apache accepts request from any of the interfaces in the host but it should have a Host: www.abctest.com header to select DocumentRoot as /websites/abctest.com/htdocs. Generally any other Host header will cause apache to use the default VirtualHost to be used.



    In case if you are trying to open the webpage with http://localhost then you would end up getting pages from default DocumentRoot.



    You can check this out more easily with curl command.



    curl -L 'http://www.abctest.com'


    And also make sure that you have a IP to host mapping for www.abctest.com in /etc/hosts file some thing as below.



    127.0.0.1   www.abctest.com www





    share|improve this answer































      0














      A couple of items to check:



      Make sure you do not have other VirtualHost entries that may be getting called afterwards.



      Typically the * entry in VirtualHosts is used for requests without a ServerName so, although I would have expected that to work, try changing the first line from:



      <VirtualHost *>


      to



      <VirtualHost www.abctest.com:80>


      (Assuming you are using the default port 80 for the host).



      Those random items aside, take a look at your access_log and error_log. They may help you identify what path is being utilized to then locate within your .conf file to help narrow down the conflict/cause.






      share|improve this answer

































        -1














        You need to enable name-based virtual hosting.



        On my Centos box it's towards the bottom of /etc/httpd/conf/httpd.conf as



        # NameVirtualHost *:80


        You need to remove the '#' symbol from the start of the line to enable it and then restart Apache.



        Without the above, Apache is using IP based virtual host. As (I presume) the name of your host and of the virtual host resolve to the same IP address then the first one matched wins, which in your case is the Apache start page.






        share|improve this answer
























        • I don't see that line in any of the config files inside /etc/httpd. In the Apache 2.4 upgrade page it says that The NameVirtualHost directive no longer has any effect, other than to emit a warning. Any address/port combination appearing in multiple virtual hosts is implicitly treated as a name-based virtual host. See httpd.apache.org/docs/2.4/upgrading.html

          – SPRBRN
          Jun 13 '14 at 12:34











        • Oops! I homed in on the CentOS bit instead of Apache 2.4! My CentOS runs Apache 2.2. I've just looked at my Fedora 20, which runs Apache 2.4 and I've a similar <VirtualHost> entry to yours with the exception that I've added it to the end of the main httpd.conf file (oh! and it also differs in that it works :-p). Maybe worth trying it there just to see if it makes a difference?

          – garethTheRed
          Jun 13 '14 at 20:51











        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%2f767990%2fapache-2-4-vhost-not-working%23new-answer', 'question_page');
        }
        );

        Post as a guest















        Required, but never shown

























        4 Answers
        4






        active

        oldest

        votes








        4 Answers
        4






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        0














        Try putting a specific ip and port in each of your VirtualHost blocks. So put:



        <VirtualHost 127.0.0.1:80>





        share|improve this answer




























          0














          Try putting a specific ip and port in each of your VirtualHost blocks. So put:



          <VirtualHost 127.0.0.1:80>





          share|improve this answer


























            0












            0








            0







            Try putting a specific ip and port in each of your VirtualHost blocks. So put:



            <VirtualHost 127.0.0.1:80>





            share|improve this answer













            Try putting a specific ip and port in each of your VirtualHost blocks. So put:



            <VirtualHost 127.0.0.1:80>






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Dec 10 '14 at 11:40









            AasAas

            1




            1

























                0














                Your VirtualHost configuration indicates that apache accepts request from any of the interfaces in the host but it should have a Host: www.abctest.com header to select DocumentRoot as /websites/abctest.com/htdocs. Generally any other Host header will cause apache to use the default VirtualHost to be used.



                In case if you are trying to open the webpage with http://localhost then you would end up getting pages from default DocumentRoot.



                You can check this out more easily with curl command.



                curl -L 'http://www.abctest.com'


                And also make sure that you have a IP to host mapping for www.abctest.com in /etc/hosts file some thing as below.



                127.0.0.1   www.abctest.com www





                share|improve this answer




























                  0














                  Your VirtualHost configuration indicates that apache accepts request from any of the interfaces in the host but it should have a Host: www.abctest.com header to select DocumentRoot as /websites/abctest.com/htdocs. Generally any other Host header will cause apache to use the default VirtualHost to be used.



                  In case if you are trying to open the webpage with http://localhost then you would end up getting pages from default DocumentRoot.



                  You can check this out more easily with curl command.



                  curl -L 'http://www.abctest.com'


                  And also make sure that you have a IP to host mapping for www.abctest.com in /etc/hosts file some thing as below.



                  127.0.0.1   www.abctest.com www





                  share|improve this answer


























                    0












                    0








                    0







                    Your VirtualHost configuration indicates that apache accepts request from any of the interfaces in the host but it should have a Host: www.abctest.com header to select DocumentRoot as /websites/abctest.com/htdocs. Generally any other Host header will cause apache to use the default VirtualHost to be used.



                    In case if you are trying to open the webpage with http://localhost then you would end up getting pages from default DocumentRoot.



                    You can check this out more easily with curl command.



                    curl -L 'http://www.abctest.com'


                    And also make sure that you have a IP to host mapping for www.abctest.com in /etc/hosts file some thing as below.



                    127.0.0.1   www.abctest.com www





                    share|improve this answer













                    Your VirtualHost configuration indicates that apache accepts request from any of the interfaces in the host but it should have a Host: www.abctest.com header to select DocumentRoot as /websites/abctest.com/htdocs. Generally any other Host header will cause apache to use the default VirtualHost to be used.



                    In case if you are trying to open the webpage with http://localhost then you would end up getting pages from default DocumentRoot.



                    You can check this out more easily with curl command.



                    curl -L 'http://www.abctest.com'


                    And also make sure that you have a IP to host mapping for www.abctest.com in /etc/hosts file some thing as below.



                    127.0.0.1   www.abctest.com www






                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Dec 26 '14 at 18:37









                    Kannan MohanKannan Mohan

                    37816




                    37816























                        0














                        A couple of items to check:



                        Make sure you do not have other VirtualHost entries that may be getting called afterwards.



                        Typically the * entry in VirtualHosts is used for requests without a ServerName so, although I would have expected that to work, try changing the first line from:



                        <VirtualHost *>


                        to



                        <VirtualHost www.abctest.com:80>


                        (Assuming you are using the default port 80 for the host).



                        Those random items aside, take a look at your access_log and error_log. They may help you identify what path is being utilized to then locate within your .conf file to help narrow down the conflict/cause.






                        share|improve this answer






























                          0














                          A couple of items to check:



                          Make sure you do not have other VirtualHost entries that may be getting called afterwards.



                          Typically the * entry in VirtualHosts is used for requests without a ServerName so, although I would have expected that to work, try changing the first line from:



                          <VirtualHost *>


                          to



                          <VirtualHost www.abctest.com:80>


                          (Assuming you are using the default port 80 for the host).



                          Those random items aside, take a look at your access_log and error_log. They may help you identify what path is being utilized to then locate within your .conf file to help narrow down the conflict/cause.






                          share|improve this answer




























                            0












                            0








                            0







                            A couple of items to check:



                            Make sure you do not have other VirtualHost entries that may be getting called afterwards.



                            Typically the * entry in VirtualHosts is used for requests without a ServerName so, although I would have expected that to work, try changing the first line from:



                            <VirtualHost *>


                            to



                            <VirtualHost www.abctest.com:80>


                            (Assuming you are using the default port 80 for the host).



                            Those random items aside, take a look at your access_log and error_log. They may help you identify what path is being utilized to then locate within your .conf file to help narrow down the conflict/cause.






                            share|improve this answer















                            A couple of items to check:



                            Make sure you do not have other VirtualHost entries that may be getting called afterwards.



                            Typically the * entry in VirtualHosts is used for requests without a ServerName so, although I would have expected that to work, try changing the first line from:



                            <VirtualHost *>


                            to



                            <VirtualHost www.abctest.com:80>


                            (Assuming you are using the default port 80 for the host).



                            Those random items aside, take a look at your access_log and error_log. They may help you identify what path is being utilized to then locate within your .conf file to help narrow down the conflict/cause.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jul 5 '16 at 3:28









                            Micho

                            10515




                            10515










                            answered Jun 12 '14 at 19:51









                            user124user124

                            30622




                            30622























                                -1














                                You need to enable name-based virtual hosting.



                                On my Centos box it's towards the bottom of /etc/httpd/conf/httpd.conf as



                                # NameVirtualHost *:80


                                You need to remove the '#' symbol from the start of the line to enable it and then restart Apache.



                                Without the above, Apache is using IP based virtual host. As (I presume) the name of your host and of the virtual host resolve to the same IP address then the first one matched wins, which in your case is the Apache start page.






                                share|improve this answer
























                                • I don't see that line in any of the config files inside /etc/httpd. In the Apache 2.4 upgrade page it says that The NameVirtualHost directive no longer has any effect, other than to emit a warning. Any address/port combination appearing in multiple virtual hosts is implicitly treated as a name-based virtual host. See httpd.apache.org/docs/2.4/upgrading.html

                                  – SPRBRN
                                  Jun 13 '14 at 12:34











                                • Oops! I homed in on the CentOS bit instead of Apache 2.4! My CentOS runs Apache 2.2. I've just looked at my Fedora 20, which runs Apache 2.4 and I've a similar <VirtualHost> entry to yours with the exception that I've added it to the end of the main httpd.conf file (oh! and it also differs in that it works :-p). Maybe worth trying it there just to see if it makes a difference?

                                  – garethTheRed
                                  Jun 13 '14 at 20:51
















                                -1














                                You need to enable name-based virtual hosting.



                                On my Centos box it's towards the bottom of /etc/httpd/conf/httpd.conf as



                                # NameVirtualHost *:80


                                You need to remove the '#' symbol from the start of the line to enable it and then restart Apache.



                                Without the above, Apache is using IP based virtual host. As (I presume) the name of your host and of the virtual host resolve to the same IP address then the first one matched wins, which in your case is the Apache start page.






                                share|improve this answer
























                                • I don't see that line in any of the config files inside /etc/httpd. In the Apache 2.4 upgrade page it says that The NameVirtualHost directive no longer has any effect, other than to emit a warning. Any address/port combination appearing in multiple virtual hosts is implicitly treated as a name-based virtual host. See httpd.apache.org/docs/2.4/upgrading.html

                                  – SPRBRN
                                  Jun 13 '14 at 12:34











                                • Oops! I homed in on the CentOS bit instead of Apache 2.4! My CentOS runs Apache 2.2. I've just looked at my Fedora 20, which runs Apache 2.4 and I've a similar <VirtualHost> entry to yours with the exception that I've added it to the end of the main httpd.conf file (oh! and it also differs in that it works :-p). Maybe worth trying it there just to see if it makes a difference?

                                  – garethTheRed
                                  Jun 13 '14 at 20:51














                                -1












                                -1








                                -1







                                You need to enable name-based virtual hosting.



                                On my Centos box it's towards the bottom of /etc/httpd/conf/httpd.conf as



                                # NameVirtualHost *:80


                                You need to remove the '#' symbol from the start of the line to enable it and then restart Apache.



                                Without the above, Apache is using IP based virtual host. As (I presume) the name of your host and of the virtual host resolve to the same IP address then the first one matched wins, which in your case is the Apache start page.






                                share|improve this answer













                                You need to enable name-based virtual hosting.



                                On my Centos box it's towards the bottom of /etc/httpd/conf/httpd.conf as



                                # NameVirtualHost *:80


                                You need to remove the '#' symbol from the start of the line to enable it and then restart Apache.



                                Without the above, Apache is using IP based virtual host. As (I presume) the name of your host and of the virtual host resolve to the same IP address then the first one matched wins, which in your case is the Apache start page.







                                share|improve this answer












                                share|improve this answer



                                share|improve this answer










                                answered Jun 13 '14 at 12:15









                                garethTheRedgarethTheRed

                                2,020912




                                2,020912













                                • I don't see that line in any of the config files inside /etc/httpd. In the Apache 2.4 upgrade page it says that The NameVirtualHost directive no longer has any effect, other than to emit a warning. Any address/port combination appearing in multiple virtual hosts is implicitly treated as a name-based virtual host. See httpd.apache.org/docs/2.4/upgrading.html

                                  – SPRBRN
                                  Jun 13 '14 at 12:34











                                • Oops! I homed in on the CentOS bit instead of Apache 2.4! My CentOS runs Apache 2.2. I've just looked at my Fedora 20, which runs Apache 2.4 and I've a similar <VirtualHost> entry to yours with the exception that I've added it to the end of the main httpd.conf file (oh! and it also differs in that it works :-p). Maybe worth trying it there just to see if it makes a difference?

                                  – garethTheRed
                                  Jun 13 '14 at 20:51



















                                • I don't see that line in any of the config files inside /etc/httpd. In the Apache 2.4 upgrade page it says that The NameVirtualHost directive no longer has any effect, other than to emit a warning. Any address/port combination appearing in multiple virtual hosts is implicitly treated as a name-based virtual host. See httpd.apache.org/docs/2.4/upgrading.html

                                  – SPRBRN
                                  Jun 13 '14 at 12:34











                                • Oops! I homed in on the CentOS bit instead of Apache 2.4! My CentOS runs Apache 2.2. I've just looked at my Fedora 20, which runs Apache 2.4 and I've a similar <VirtualHost> entry to yours with the exception that I've added it to the end of the main httpd.conf file (oh! and it also differs in that it works :-p). Maybe worth trying it there just to see if it makes a difference?

                                  – garethTheRed
                                  Jun 13 '14 at 20:51

















                                I don't see that line in any of the config files inside /etc/httpd. In the Apache 2.4 upgrade page it says that The NameVirtualHost directive no longer has any effect, other than to emit a warning. Any address/port combination appearing in multiple virtual hosts is implicitly treated as a name-based virtual host. See httpd.apache.org/docs/2.4/upgrading.html

                                – SPRBRN
                                Jun 13 '14 at 12:34





                                I don't see that line in any of the config files inside /etc/httpd. In the Apache 2.4 upgrade page it says that The NameVirtualHost directive no longer has any effect, other than to emit a warning. Any address/port combination appearing in multiple virtual hosts is implicitly treated as a name-based virtual host. See httpd.apache.org/docs/2.4/upgrading.html

                                – SPRBRN
                                Jun 13 '14 at 12:34













                                Oops! I homed in on the CentOS bit instead of Apache 2.4! My CentOS runs Apache 2.2. I've just looked at my Fedora 20, which runs Apache 2.4 and I've a similar <VirtualHost> entry to yours with the exception that I've added it to the end of the main httpd.conf file (oh! and it also differs in that it works :-p). Maybe worth trying it there just to see if it makes a difference?

                                – garethTheRed
                                Jun 13 '14 at 20:51





                                Oops! I homed in on the CentOS bit instead of Apache 2.4! My CentOS runs Apache 2.2. I've just looked at my Fedora 20, which runs Apache 2.4 and I've a similar <VirtualHost> entry to yours with the exception that I've added it to the end of the main httpd.conf file (oh! and it also differs in that it works :-p). Maybe worth trying it there just to see if it makes a difference?

                                – garethTheRed
                                Jun 13 '14 at 20:51


















                                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%2f767990%2fapache-2-4-vhost-not-working%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

                                Mouse cursor on multiple screens with different PPI

                                Agildo Ribeiro

                                Sometime when accessing a menu: “Ubuntu 16.04 has experienced an internal error”