Multiple virtual host in Centos 7 is not working together











up vote
1
down vote

favorite












My server information is



Server version: Apache/2.4.6 (CentOS)
Server built: Nov 19 2015 21:43:13


I am trying to configure virtual host for 2 different sites: biz.example.com and pin.example.com which are hosted on the same server. There are 2 different folders located under 'var/www/html/' named 'biz' and 'pin' with their respected project files for the above mentioned 2 websites. I am trying to configure it on the below way.



Within /etc/hosts below configuration



127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

xxx.xxx.xxx.xxx biz.example.com
xxx.xxx.xxx.xxx pin.example.com


xxx.xxx.xxx.xxx is replaced by the server IP address.



Within /etc/httpd/conf/httpd.conf



IncludeOptional sites-enabled/*.conf


Now, under /etc/httpd/sites-available there are biz.conf and pin.conf file. I also have the folder sites-enabled under /etc/httpd which has 2 files that points to the biz.conf and pin.conf of sites-available folder using the below command



ln -s /etc/httpd/sites-available/biz.conf /etc/httpd/sites-enabled/biz.conf

ln -s /etc/httpd/sites-available/pin.conf /etc/httpd/sites-enabled/pin.conf


biz.conf has the followings



<VirtualHost *:80>
ServerName http://biz.example.com/
ServerAlias http://biz.example.com/
DocumentRoot "/var/www/html/biz"
<directory "/var/www/html/biz">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from 127.0.0.1
</directory>
</VirtualHost>


And the configuration within pin.conf file is mentioned as



<VirtualHost *:80>
ServerName http://pin.example.com/
ServerAlias http://pin.example.com/
DocumentRoot "/var/www/html/pin"
<directory "/var/www/html/pin">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from 127.0.0.1
</directory>
</VirtualHost>


On this setup, if i try to access http://biz.example.com/ , the correct website (biz website) is loading. But if i try to access http://pin.example.com/ , then also biz website is loading instead of pin website. Multiple configuration is not working together.



I also tried to merge the virtual configuration of biz.conf and pin.conf within a single file, biz.conf, but it didn't work as well.










share|improve this question






















  • Are there error messages from Apache (this is Apache, right?) in its own log files or syslog messages?
    – Ned64
    Feb 15 at 14:39










  • I know is late post - but don't need http just domain example.com and you don't need trailing slash or quotes.. and allow from 127.0.0,1 - would that mean that only localhost can access localhost? surely access from all and enable cphulk?
    – treyBake
    Mar 5 at 17:06















up vote
1
down vote

favorite












My server information is



Server version: Apache/2.4.6 (CentOS)
Server built: Nov 19 2015 21:43:13


I am trying to configure virtual host for 2 different sites: biz.example.com and pin.example.com which are hosted on the same server. There are 2 different folders located under 'var/www/html/' named 'biz' and 'pin' with their respected project files for the above mentioned 2 websites. I am trying to configure it on the below way.



Within /etc/hosts below configuration



127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

xxx.xxx.xxx.xxx biz.example.com
xxx.xxx.xxx.xxx pin.example.com


xxx.xxx.xxx.xxx is replaced by the server IP address.



Within /etc/httpd/conf/httpd.conf



IncludeOptional sites-enabled/*.conf


Now, under /etc/httpd/sites-available there are biz.conf and pin.conf file. I also have the folder sites-enabled under /etc/httpd which has 2 files that points to the biz.conf and pin.conf of sites-available folder using the below command



ln -s /etc/httpd/sites-available/biz.conf /etc/httpd/sites-enabled/biz.conf

ln -s /etc/httpd/sites-available/pin.conf /etc/httpd/sites-enabled/pin.conf


biz.conf has the followings



<VirtualHost *:80>
ServerName http://biz.example.com/
ServerAlias http://biz.example.com/
DocumentRoot "/var/www/html/biz"
<directory "/var/www/html/biz">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from 127.0.0.1
</directory>
</VirtualHost>


And the configuration within pin.conf file is mentioned as



<VirtualHost *:80>
ServerName http://pin.example.com/
ServerAlias http://pin.example.com/
DocumentRoot "/var/www/html/pin"
<directory "/var/www/html/pin">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from 127.0.0.1
</directory>
</VirtualHost>


On this setup, if i try to access http://biz.example.com/ , the correct website (biz website) is loading. But if i try to access http://pin.example.com/ , then also biz website is loading instead of pin website. Multiple configuration is not working together.



I also tried to merge the virtual configuration of biz.conf and pin.conf within a single file, biz.conf, but it didn't work as well.










share|improve this question






















  • Are there error messages from Apache (this is Apache, right?) in its own log files or syslog messages?
    – Ned64
    Feb 15 at 14:39










  • I know is late post - but don't need http just domain example.com and you don't need trailing slash or quotes.. and allow from 127.0.0,1 - would that mean that only localhost can access localhost? surely access from all and enable cphulk?
    – treyBake
    Mar 5 at 17:06













up vote
1
down vote

favorite









up vote
1
down vote

favorite











My server information is



Server version: Apache/2.4.6 (CentOS)
Server built: Nov 19 2015 21:43:13


I am trying to configure virtual host for 2 different sites: biz.example.com and pin.example.com which are hosted on the same server. There are 2 different folders located under 'var/www/html/' named 'biz' and 'pin' with their respected project files for the above mentioned 2 websites. I am trying to configure it on the below way.



Within /etc/hosts below configuration



127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

xxx.xxx.xxx.xxx biz.example.com
xxx.xxx.xxx.xxx pin.example.com


xxx.xxx.xxx.xxx is replaced by the server IP address.



Within /etc/httpd/conf/httpd.conf



IncludeOptional sites-enabled/*.conf


Now, under /etc/httpd/sites-available there are biz.conf and pin.conf file. I also have the folder sites-enabled under /etc/httpd which has 2 files that points to the biz.conf and pin.conf of sites-available folder using the below command



ln -s /etc/httpd/sites-available/biz.conf /etc/httpd/sites-enabled/biz.conf

ln -s /etc/httpd/sites-available/pin.conf /etc/httpd/sites-enabled/pin.conf


biz.conf has the followings



<VirtualHost *:80>
ServerName http://biz.example.com/
ServerAlias http://biz.example.com/
DocumentRoot "/var/www/html/biz"
<directory "/var/www/html/biz">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from 127.0.0.1
</directory>
</VirtualHost>


And the configuration within pin.conf file is mentioned as



<VirtualHost *:80>
ServerName http://pin.example.com/
ServerAlias http://pin.example.com/
DocumentRoot "/var/www/html/pin"
<directory "/var/www/html/pin">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from 127.0.0.1
</directory>
</VirtualHost>


On this setup, if i try to access http://biz.example.com/ , the correct website (biz website) is loading. But if i try to access http://pin.example.com/ , then also biz website is loading instead of pin website. Multiple configuration is not working together.



I also tried to merge the virtual configuration of biz.conf and pin.conf within a single file, biz.conf, but it didn't work as well.










share|improve this question













My server information is



Server version: Apache/2.4.6 (CentOS)
Server built: Nov 19 2015 21:43:13


I am trying to configure virtual host for 2 different sites: biz.example.com and pin.example.com which are hosted on the same server. There are 2 different folders located under 'var/www/html/' named 'biz' and 'pin' with their respected project files for the above mentioned 2 websites. I am trying to configure it on the below way.



Within /etc/hosts below configuration



127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6

xxx.xxx.xxx.xxx biz.example.com
xxx.xxx.xxx.xxx pin.example.com


xxx.xxx.xxx.xxx is replaced by the server IP address.



Within /etc/httpd/conf/httpd.conf



IncludeOptional sites-enabled/*.conf


Now, under /etc/httpd/sites-available there are biz.conf and pin.conf file. I also have the folder sites-enabled under /etc/httpd which has 2 files that points to the biz.conf and pin.conf of sites-available folder using the below command



ln -s /etc/httpd/sites-available/biz.conf /etc/httpd/sites-enabled/biz.conf

ln -s /etc/httpd/sites-available/pin.conf /etc/httpd/sites-enabled/pin.conf


biz.conf has the followings



<VirtualHost *:80>
ServerName http://biz.example.com/
ServerAlias http://biz.example.com/
DocumentRoot "/var/www/html/biz"
<directory "/var/www/html/biz">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from 127.0.0.1
</directory>
</VirtualHost>


And the configuration within pin.conf file is mentioned as



<VirtualHost *:80>
ServerName http://pin.example.com/
ServerAlias http://pin.example.com/
DocumentRoot "/var/www/html/pin"
<directory "/var/www/html/pin">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
Allow from 127.0.0.1
</directory>
</VirtualHost>


On this setup, if i try to access http://biz.example.com/ , the correct website (biz website) is loading. But if i try to access http://pin.example.com/ , then also biz website is loading instead of pin website. Multiple configuration is not working together.



I also tried to merge the virtual configuration of biz.conf and pin.conf within a single file, biz.conf, but it didn't work as well.







centos apache-httpd apache-virtualhost virtual-host vhost






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Dec 16 '16 at 11:38









Debashis

10613




10613












  • Are there error messages from Apache (this is Apache, right?) in its own log files or syslog messages?
    – Ned64
    Feb 15 at 14:39










  • I know is late post - but don't need http just domain example.com and you don't need trailing slash or quotes.. and allow from 127.0.0,1 - would that mean that only localhost can access localhost? surely access from all and enable cphulk?
    – treyBake
    Mar 5 at 17:06


















  • Are there error messages from Apache (this is Apache, right?) in its own log files or syslog messages?
    – Ned64
    Feb 15 at 14:39










  • I know is late post - but don't need http just domain example.com and you don't need trailing slash or quotes.. and allow from 127.0.0,1 - would that mean that only localhost can access localhost? surely access from all and enable cphulk?
    – treyBake
    Mar 5 at 17:06
















Are there error messages from Apache (this is Apache, right?) in its own log files or syslog messages?
– Ned64
Feb 15 at 14:39




Are there error messages from Apache (this is Apache, right?) in its own log files or syslog messages?
– Ned64
Feb 15 at 14:39












I know is late post - but don't need http just domain example.com and you don't need trailing slash or quotes.. and allow from 127.0.0,1 - would that mean that only localhost can access localhost? surely access from all and enable cphulk?
– treyBake
Mar 5 at 17:06




I know is late post - but don't need http just domain example.com and you don't need trailing slash or quotes.. and allow from 127.0.0,1 - would that mean that only localhost can access localhost? surely access from all and enable cphulk?
– treyBake
Mar 5 at 17:06










2 Answers
2






active

oldest

votes

















up vote
0
down vote













Answer:



1) Have to remove the trailing slash from ServerName and ServerAlias



2) Here, we can remove the ServerAlias as well as ServerName and ServerAlias both are same.






share|improve this answer




























    up vote
    0
    down vote













    Remove double quotes from your path



    DocumentRoot /var/www/html/pin
    <directory /var/www/html/pin>





    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',
      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%2f330825%2fmultiple-virtual-host-in-centos-7-is-not-working-together%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








      up vote
      0
      down vote













      Answer:



      1) Have to remove the trailing slash from ServerName and ServerAlias



      2) Here, we can remove the ServerAlias as well as ServerName and ServerAlias both are same.






      share|improve this answer

























        up vote
        0
        down vote













        Answer:



        1) Have to remove the trailing slash from ServerName and ServerAlias



        2) Here, we can remove the ServerAlias as well as ServerName and ServerAlias both are same.






        share|improve this answer























          up vote
          0
          down vote










          up vote
          0
          down vote









          Answer:



          1) Have to remove the trailing slash from ServerName and ServerAlias



          2) Here, we can remove the ServerAlias as well as ServerName and ServerAlias both are same.






          share|improve this answer












          Answer:



          1) Have to remove the trailing slash from ServerName and ServerAlias



          2) Here, we can remove the ServerAlias as well as ServerName and ServerAlias both are same.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 16 '16 at 12:15









          Debashis

          10613




          10613
























              up vote
              0
              down vote













              Remove double quotes from your path



              DocumentRoot /var/www/html/pin
              <directory /var/www/html/pin>





              share|improve this answer

























                up vote
                0
                down vote













                Remove double quotes from your path



                DocumentRoot /var/www/html/pin
                <directory /var/www/html/pin>





                share|improve this answer























                  up vote
                  0
                  down vote










                  up vote
                  0
                  down vote









                  Remove double quotes from your path



                  DocumentRoot /var/www/html/pin
                  <directory /var/www/html/pin>





                  share|improve this answer












                  Remove double quotes from your path



                  DocumentRoot /var/www/html/pin
                  <directory /var/www/html/pin>






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 6 '17 at 18:27









                  Anastes Mp

                  11




                  11






























                       

                      draft saved


                      draft discarded



















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f330825%2fmultiple-virtual-host-in-centos-7-is-not-working-together%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

                      Morgemoulin

                      Scott Moir

                      Souastre