1

I have 2 projects in my htdocs folder: project1 and project2. I am running my project1 on MAMP server. It's located on localhost:8888 (default location provided by MAMP). I want to run my second project2. What changes do I need to do to make it happen?

I added httpd.conf file like this, but it's not working. Is there any elegant way to do this?

<VirtualHost *:8888>
ServerName zf2-tutorial.localhost
DocumentRoot /Applications/MAMP/htdocs/zf2-tutorial-1/public
SetEnv APPLICATION_ENV "development"
<Directory /Applications/MAMP/htdocs/zf2-tutorial-1/public>
    DirectoryIndex index.php
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

<VirtualHost *:8888/secondproject>
ServerName zf2-tutorial2.localhost
DocumentRoot /Applications/MAMP/htdocs/zf2-tutorial-2/public
SetEnv APPLICATION_ENV "development"
<Directory /Applications/MAMP/htdocs/zf2-tutorial-2/public>
    DirectoryIndex index.php
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
</VirtualHost>

Am I doing something wrong?

edigu
  • 9,878
  • 5
  • 57
  • 80
user231791
  • 301
  • 2
  • 5
  • 14
  • define not working ? This might be better at superuser / serverfault. Assuming you have a NameVirtualHost config line in your httpd.conf and both zf2-tutorial.localhost and teamleads.localhost resolve to 127.0.0.1 it *should* work. but what is the exact error / issue you are seeing. – Doon Aug 23 '13 at 15:04
  • second project is not running. Ok.. I am getting this. Where do I need to setup 127.0.0.1 as in server name? – user231791 Aug 23 '13 at 15:06
  • your browser needs to send the host header, so you need to access it via http://teamleads.localhost:8080/ it appears that you are on a Mac, so you would need to add teamleads.localhost to your /etc/hosts file – Doon Aug 23 '13 at 15:08

1 Answers1

1

Seems good, except that <VirtualHost *:8888/secondproject> is supposed to be just <VirtualHost *:8888>. Also, don't forget to add lines binding zf2-tutorial.localhost and zf2-tutorial2.localhost to 127.0.0.1 to your /etc/hosts file and restart Apache.

bredikhin
  • 8,875
  • 3
  • 40
  • 44
  • I did it, as you have described. But, I am accessing project 1 only even if I change my URL for second project. I got same result for zf1.tutorial1.localhost:8888 and zf2-tutorial2.localhost:8888 – user231791 Aug 23 '13 at 15:20
  • Make sure the [NameVirtualHost](http://httpd.apache.org/docs/2.2/mod/core.html#namevirtualhost) directive is uncommented, in your case it should be `NameVirtualHost *:8888`. – bredikhin Aug 23 '13 at 15:42
  • I have 2 virtual hosts in httpd.conf file. When I uncomment 1 of these then it runs fine. But still if I change URL names then I am getting the same directory access.. In this case if I need to access 1 of these project, then I have to uncomment 1 virtualhost every time. – user231791 Aug 23 '13 at 18:20
  • [Here](http://httpd.apache.org/docs/2.2/vhosts/examples.html) you can find an example of virtual host configuration. Just change 80 to 8888 if you want Apache to listen on a non-standard port. – bredikhin Aug 23 '13 at 18:31