Pergunta

I have several PHP and python projects running under apache 2.2.

In my httpd.conf file:

DocumentRoot "/var/www/html"

NameVirtualHost xx.my.ip.xxx:80
...


# Virtual host for xx project
<VirtualHost xx.my.ip.xxx:80>
    ...
    DocumentRoot /var/www/html/xx.com
    ServerName xx-project.com
</VirtualHost>

...

When accessing by server name (xx-project.com), [/var/www/html/xx.com] is used as DocumentRoot without any problems.

However I have added a new project under [/var/www/html]. Since I have not yet server name for this project, I try to access it with xx.my.ip.xxx:80/mynewprojectPath... but [/var/www/html/xx.com] was used as DocumentRoot.

Any ideas ?

Thank you for reading

Foi útil?

Solução

I would use a temporary NameServer (say yy-project.com) and overwrite the /etc/hosts file in both your server and your developer machine. That way you can specify a second VirtualHost and start testing your application. When you get a second domain, you only have to replace it in your VirtualHost and remove the lines in your /etc/hosts files.

(edited)

The temporary vhost:

<VirtualHost *:80>
ServerName yy-project.com
ErrorLog /var/log/apache2/yy-project_error.log
TransferLog /var/log/apache2/ryy-project_access.log
LogLevel warn
DocumentRoot /var/www/html/yy.com
....
</VirtualHost>

Add this line in the /etc/hosts file in the server:

127.0.0.1   yy-project.com

And add this in the /etc/hosts file in your client machine:

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