Hello everyone!

We have been investing plenty of personal time and energy for many years to share our knowledge with you all. However, we now need your help to keep this blog running. All you have to do is just click one of the adverts on the site, otherwise it will sadly be taken down due to hosting etc. costs. Thank you.

In this example we're going to install more than one symfony applications in a single vagrant box and accessing them via same IP but different ports. This prevents you from setting up one vagrant box per application. Follow example below to accomplish it.

e.g.
Sport application: http://192.168.50.10:8081/
Country application: http://192.168.50.10:8082/

I'm assuming that you're capable of setting up a vagrant box and a basic symfony application so I won't touch upon how they're done.


Vagrantfile


# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/trusty64"

config.vm.define :symfony do |symfony_config|
symfony_config.vm.hostname = 'symfony'
symfony_config.vm.network "private_network", ip: "192.168.50.10"
end

config.vm.provider :virtualbox do |virtualbox_config|
virtualbox_config.name = "Symfony - Ubuntu 14.04"
end

config.vm.synced_folder "", "/var/www/html", nfs: true, mount_options: ["actimeo=2"]
end

Applications


I assume that you already have setup your vagrant box with Vagrantfile above and created "sport" and "country" symfony applications under /var/www/html.


Virtual host settings


Sport


# vagrant@symfony $ cat /etc/apache2/sites-available/sport.dev.conf

<VirtualHost *:8081>
ServerName country.dev
DocumentRoot "/var/www/html/sport/web"

<Directory "/var/www/html/sport/web">
Options Indexes FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/sport.dev.error.log
CustomLog ${APACHE_LOG_DIR}/sport.dev.access.log combined
</VirtualHost>

Country


# vagrant@symfony $ cat /etc/apache2/sites-available/country.dev.conf

<VirtualHost *:8082>
ServerName country.dev
DocumentRoot "/var/www/html/country/web"

<Directory "/var/www/html/country/web">
Options Indexes FollowSymlinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/country.dev.error.log
CustomLog ${APACHE_LOG_DIR}/country.dev.access.log combined
</VirtualHost>

Ports settings


# vagrant@symfony $ cat /etc/apache2/ports.conf 

Listen 80

# inanzzz
Listen 8081 #Sport
Listen 8082 #Country
#

<IfModule ssl_module>
Listen 443
</IfModule>

<IfModule mod_gnutls.c>
Listen 443
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet