1

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

johann
  • 1,115
  • 8
  • 34
  • 60

1 Answers1

1

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
arg
  • 187
  • 1
  • 12
  • Actually I have many VirtualHosts. Each of them owns its own servername. In my /etc/hosts, il only have: 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 .. No ideas ? – johann May 28 '13 at 07:30
  • Then you should add a new VirtualHost with a ServerName yy-project.com and add the following line to /etc/hosts: "127.0.1.1 yy-project.com" in your server and "SERVER_IP yy-project.com" in your development machine. That way, when you point your browser to yy.project.com the petition will arrive to your server, where the new VirtualHost will process it. There you can change your DocumentRoot – arg May 28 '13 at 12:28
  • Sorry for the delay in responding. Your method works like a charm ! thank you ! Can you post an answer with the same content (for validation) – johann Jun 02 '13 at 07:19
  • There you go. Sorrry for the delay, I just saw it. – arg Jun 10 '13 at 09:40