Se" /> Se" /> Se"/>

two Virtual host not working on debian 7 server

249 Views Asked by At

the first one already working great with this virtual host conf file et-project and target "et-project.net" domain.

<VirtualHost et-project.net:80>
    ServerAdmin [email protected]
    ServerName  et-project.net
    ServerAlias www.et-project.net

    # Les documents du site (Souvent /var/www/monsite ou /home/monsite)
    DocumentRoot /var/www/et-project.net

    # Les options du site (comme dans un .htaccess)
    <Directory /var/www/et-project.net/>
        # On autorise tous le monde a voir le site
        Order allow,deny
        allow from all
    </Directory>

    # Les logs (historiques des IPs et des fichiers envoyés)
    ErrorLog /var/log/apache2/et-project.net-error_log
    TransferLog /var/log/apache2/et-project.net-access_log
</VirtualHost>

This my second subdomain conf file dev.et-project.net who need to target on dev.et-project.net:

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName  dev.et-project.net

    # Les documents du site (Souvent /var/www/monsite ou /home/monsite)
    DocumentRoot /var/www/dev.et-project.net

    # Les options du site (comme dans un .htaccess)
    <Directory "/var/www/dev.et-project.net/">
        # On autorise tous le monde a voir le site
        Options -Indexes +FollowSymLinks +MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    # Les logs (historiques des IPs et des fichiers envoyés)
    ErrorLog /var/log/apache2/dev.et-project.net-error_log
    TransferLog /var/log/apache2/dev.et-project.net-access_log
</VirtualHost>

i was already create dev.et-project.net folder in /var/www and add chmod 755 -r on him

My problem is this one : when i tape dev.et-project.net i already be redirect on et-project.net ... but when i tape my_ip_server/dev.et-project.net i see my dev subdomain directory.

  • i was already add my_ip_server dev.et-project.net into my hosts file.
  • i was already activate my vhost conf with a2ensite command and restart apache2 on my debian server.

so if you have some advise or know why my dev.et-project.net subdomain don't work with apache2 vhost , let me know plz.

regard

2

There are 2 best solutions below

1
f14284 On

This is the wrong part of your second vhost:

<VirtualHost *:80>
    ServerName  dev.et-project.net

must be:

<VirtualHost dev.et-project.net:80>
    ServerName  dev.et-project.net

And the first

<VirtualHost et-project.net:80>
    ServerName  et-project.net
    ServerAlias www.et-project.net

In the /etc/hosts file:

127.0.0.1   et-project.net www.et-project.net dev.et-project.net

And then

systemctl restart apache2

And clean your webbrowser cache. (close and reopen is a good solution)

I have try, on a fresh install, putting the wildcard '*' ,same as you, and i have the same error.

<VirtualHost dev.et-project.net:80>

is require for telling apache2 to find correct root folder of host.

I you see sudirectory : http://127.0.0.1/dev.example.com then you have another vhost listenning with documentroot /var/www (see into /etc/apache2/apache2.conf) but is not a problem, your problem is: you use wildcard. You can confirm that: you use -Index into your vhost directory configuration .But apache2 list your subdirectory http://127.0.0.1/dev.example.com then your vhost is not the current loaded vhost because this option disallow index listing. Sorry for my english.

EDIT: for this problem in particular , the CNAME DNS record was missing.

13
elderyn On

@f14284

i was change all, but nothing working yet. only et-project.net working.

if you are french, we will maybe continue on skype or other way for solved my problem ... are you ok for that ?

at the moment, that is my conf files vhosts and host.

dev.et-project

<VirtualHost dev.et-project.net:80>
    ServerAdmin [email protected]
    ServerName  dev.et-project.net

    # Les documents du site (Souvent /var/www/monsite ou /home/monsite)
    DocumentRoot /var/www/dev.et-project.net

    # Les options du site (comme dans un .htaccess)
    <Directory "/var/www/dev.et-project.net/">
        # On autorise tous le monde a voir le site
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    # Les logs (historiques des IPs et des fichiers envoyés)
    ErrorLog /var/log/apache2/dev.et-project.net-error_log
    TransferLog /var/log/apache2/dev.et-project.net-access_log
</VirtualHost>

here my et-project

<VirtualHost et-project.net:80>
    ServerAdmin [email protected]
    ServerName  et-project.net
    ServerAlias www.et-project.net

    # Les documents du site (Souvent /var/www/monsite ou /home/monsite)
    DocumentRoot /var/www/et-project.net

    # Les options du site (comme dans un .htaccess)
    <Directory /var/www/et-project.net/>
        # On autorise tous le monde a voir le site
        Order allow,deny
        allow from all
    </Directory>

    # Les logs (historiques des IPs et des fichiers envoyés)
    ErrorLog /var/log/apache2/et-project.net-error_log
    TransferLog /var/log/apache2/et-project.net-access_log
</VirtualHost>

and my dedicate server hosts

127.0.0.1       localhost et-project.net www.et-project.net dev.et-project.net
#127.0.1.1      sd-66352.dedibox.fr project
62.210.127.101  et-project.net project
62.210.127.101  et-project.net www.et-project.net dev.et-project.net

all my config is here now and it's so sad for me to don't solved this problem since one week.

regard