Time for a new tutorial and this time I will try and explain how you set up and configure your Flashcom Server with multiple vhosts. It should be noted that only the Professional Edition supports vhosts so if you run the Developer or Personal Edition then you will not be able to add additional vhosts. Dev and Personal Edition will only run apps under the _defaultVhost_

The following steps apply to the Windows version of Flashcom Server but apart from Windows style filepaths you can take a lot away from this tutorial for Linux installations, too.

Flashcom Server uses XML files for configuration and these work in several levels starting at the server level (Server.xml) down to adapter (Adapter.xml) and vhost level (Vhost.xml) The last level is Application.xml which as the name says is responsible for configurations on an Application level.
The XML files are well commented and essentially pretty easy to maintain. To set up a working vhost you will normally need to edit 3 files:
- Server.xml, Vhost.xml and Application.xml

Server.xml can be found in the root of the /conf directory; Adapter.xml can be found inside the _defaultRoot_ directory and both Application.xml and Vhost.xml can be found under _defaultVHost_

This is how your file structure would look like after a standard Flashcom installation in Windows (only _defaultVHost_ is available)


Server.xml
Strictly speaking you do not have to edit server.xml to add a vhost. This is because the vhost entry in server.xml is only needed so that you can later add vhost administrators via the admin console. Adding a vhost to server.xml does NOT actually add the vhost to the server config. This might be a bit confusing but it's actually the process of creating the necessary folders under your adapter level which creates the vhost.

Having said that I would always recommend you add your vhost to server.xml to keep things organised. This will also allow you later to modify the vhost admins via the admin console. So here's how you add the entry to Server.xml. you need to copy the entire <VirtualHost....>...</Virtualhost> entry, basically the whole chunk that you see in the pic below.

Next you need to give your new vhost a name. This is important and you should always name it after the domain (or subdomain) the you use to later access it. Say for example your main domain is myflashcomhost.com then why not call this vhost vhost1.myflashcomhost.com. It is important to understand that this new subdomain must resolve to your Flashcomserver IP address. If it doesn't then you'll never be able to connect!

So for this example I will call my vhost vhost1.myflashcomhost.com and this is how the entry in server.xml should look like:

Adding the vhost folder
This next step is important as it will actually create your vhost. You have to create a new folder under your adapter level (in our example under ...\conf\_defaultRoot_), on the same level as _defaultVHost_. I sometimes just copy the entire _defaultVHost_ and then rename it. Warning: The name of this folder needs to correspond to your domain that you will use to access this vhost, in our example vhost1.myflashcomhost.com.

Your folder structure under /conf/_defaultRoot_ should now look like this:

This has in effect created the new vhost on your server.

But in order to be able to actually use the vhost you need to configure the <ScriptLibPath> in Application.xml and also the <AppsDir> in Vhost.xml. If you have created your new folder by copying _defaultVHost_ then those 2 files already exist inside your new vhost folder. If they don't then you need to copy them over from an existing vhost. You should also create a folder called 'admin' inside vhost1.myflashcomhost.com if you want this vhost to be able to accept admin connections. Have a look inside _defaultVHost_ for an example.

Adding the corresponding applications folder for your vhost
The Flashcom Server configuration is usually split up in 2 parts: the admin files under /conf to which only the server admin has access to and the vhost folders themselves (yet to be created) which will host your actual serverside scripts such as main.asc. The vhost folders can be made available via FTP for example to allow access for vhost admins. It is also a good idea to add a dedicated scriptlib to each running vhost.

In a nutshell what you have to do is create another folder to which you map your appsdir and scriptlib. This folder should not reside under /conf and it should not be accessible from the web, only via FTP. This applications folder is not the place from which you serve your swf files!
If you are planning on running a webserver on the same machine as your Flashcom Server then I recommend you read my tutorial on IIS and Flashcom, it gives some tips in regards to IP addresses and ports.

In my example the applications folder lives under C:\Inetpub\flashcom\applications (note that it is not under wwwroot and therefore not accessible from the web) but you can basically map it to wherever you see fit.
I call my new folder 'vhost1' and create 2 more folders inside it called 'apps' and 'scriptlib'. I then copy my scriptlib files from abother vhost into the scriptlib folder. My folder structure now looks like this:

Now we need to map appsdir to C:\Inetpub\flashcom\applications\vhost1\apps and map scriptlibdir to C:\Inetpub\flashcom\applications\vhost1\scriptlib

The correct XML entry therefore look like this for Application.xml

and like this for Vhost.xml


And that is pretty much all there is to it. It sounds a lot more complicated than it really is and I recommend you just try it out. I always restart my server just for good measure although I have been told that this is not strictly necessary.

a coomon problem oftne is that the new vhost domain (in our example vhost1.myflashcomhost.com) doesn't actually resolve correctly to the FCS IP and in that case you will never successfully connect. I therefore always open my admin console and check if my connection attempt actually hits the server - and I keep a particular close eye on the fact that the connection attempt does not connect to _defaultVHost_. If it does connect to _defaultVHost_ instead of your new vhost then you might have a config problem.

If your connection does not hit the server at all then the problem is likely DNS related.

If your connection does hit the Flashcom box but fails in some other way then nine times out of ten the admin console will give you some clues as to what is going wrong.

If you are still stuck after that then I recommend reading the Flashcom Server docs at http://www.macromedia.com/support/flashcom/documentation.html and in particular the first 2 PDF's called Installing Flash Communication Server and Managing Flash Communication Server.

There are also some interesting Live Docs available at http://www.macromedia.com/livedocs/flashcom/mx2004/index.html