Pergunta

I'm trying to enable multiple domains in my environment Development, but am not succeeding the way I tried below, at which point I'm wrong?


I installed httpd and changed DocumentRoot in httpd.conf to:

C:/Webserver/www


*I changed the Windows hosts file to(in Italics would like to access):
If I switch to 127.0.0.1 api.rotadorock the address resolves to www/ but the right is www/rotadorock/api.

127.0.0.1                       localhost
127.0.0.1                       webserver
127.0.0.1/rotadorock/ecommerce  rotadorock
127.0.0.1/rotadorock/api        api.rotadorock
127.0.0.1/rotadorock/ecommerce  ecommerce.rotadorock
127.0.0.1/rotadorock/mobile     mobile.rotadorock
127.0.0.1/rotadorock/sistema    sistema.rotadorock
127.0.0.1/rotadorock/social     social.rotadorock

*Update(windows hosts file)

I removed the hosts file changes I mentioned above, because as @Volker Birk said are not necessary. But even so, still can not access as desire (api.rotadorock/ or localhost/api.rotadorock/ and should point to C:/Webserver/www/rotadorock/api). What could be wrong?


And finally changed httpd-vhost.conf for:

NameVirtualHost webserver:80

<Directory "C:/Webserver/www">
    Options All
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

<VirtualHost *:80>
    ServerName localhost
    DocumentRoot "c:/Webserver/www"
    ServerAlias localhost
    ErrorLog "logs/httpd-error.log"
    CustomLog "logs/httpd-access.log" common
</VirtualHost>

<VirtualHost *:80>
    ServerName webserver
    DocumentRoot "c:/Webserver/www"
    ServerAlias webserver
    ErrorLog "logs/httpd-error.log"
    CustomLog "logs/httpd-access.log" common
</VirtualHost>

<VirtualHost rotadorock:80>
    ServerName rotadorock
    DocumentRoot "c:/Webserver/www/rotadorock/ecommerce"
    ServerAlias rotadorock
    ErrorLog "logs/httpd-error.log"
    CustomLog "logs/httpd-access.log" common
</VirtualHost>

<VirtualHost api.rotadorock:80>
    ServerName api.rotadorock
    DocumentRoot "c:/Webserver/www/rotadorock/api"
    ServerAlias api.rotadorock
    ErrorLog "logs/httpd-error.log"
    CustomLog "logs/httpd-access.log" common
</VirtualHost>

<VirtualHost ecommerce.rotadorock:80>
    ServerName ecommerce.rotadorock
    DocumentRoot "c:/Webserver/www/rotadorock/ecommerce"
    ServerAlias ecommerce.rotadorock
    ErrorLog "logs/httpd-error.log"
    CustomLog "logs/httpd-access.log" common
</VirtualHost>

<VirtualHost mobile.rotadorock:80>
    ServerName mobile.rotadorock
    DocumentRoot "c:/Webserver/www/rotadorock/mobile"
    ServerAlias mobile.rotadorock
    ErrorLog "logs/httpd-error.log"
    CustomLog "logs/httpd-access.log" common
</VirtualHost>

<VirtualHost sistema.rotadorock:80>
    ServerName sistema.rotadorock
    DocumentRoot "c:/Webserver/www/rotadorock/sistema"
    ServerAlias sistema.rotadorock
    ErrorLog "logs/httpd-error.log"
    CustomLog "logs/httpd-access.log" common
</VirtualHost>

<VirtualHost social.rotadorock:80>
    ServerName social.rotadorock
    DocumentRoot "c:/Webserver/www/rotadorock/social"
    ServerAlias social.rotadorock
    ErrorLog "logs/httpd-error.log"
    CustomLog "logs/httpd-access.log" common
</VirtualHost>
Foi útil?

Solução 2

Finally solved the problem. And I could just using the Windows hosts file and httpd-vhosts.conf httpd together.

Let me give an example of what was done to enable multiple subdomains accessing locally. On Windows hosts file to add, for each domain and subdomain you want something like this:

127.0.0.1    api.rotadorock #my subdomain
127.0.0.1    rotadorock #my domain

And then the httpd-vhosts apache httpd:

# Accessing the API
<VirtualHost 127.0.0.1>
    DocumentRoot "C:/Webserver/www/rotadorock/api"
    ServerName api.rotadorock
    ServerAlias ​​api.rotadorock

    <Directory "C:/Webserver/www/rotadorock/api">
        All Options Includes Indexes
    </ Directory>
</VirtualHost>

# Accessing the domain
<VirtualHost 127.0.0.1>
    DocumentRoot "C:/Webserver/www/rotadorock/"
    ServerName rotadorock
    ServerAlias ​​*.rotadorock

    <Directory "C:/Webserver/www/rotadorock/">
        All Options Includes Indexes
    </Directory>
</VirtualHost>

And then that way I could access api.rotadorock/ and rotadorock/ locally. I tried all ways without the hosts file. But just gotta use it. If someone can explain to me how it should have done so it would not need to use the hosts I would be grateful.

Outras dicas

You don't need the hosts file. Have a look into the documentation:

http://httpd.apache.org/docs/2.2/en/vhosts/name-based.html

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top