7 min read

(For more resources on Flash, see here.)

We are going to download and install Apache and MySQL server package. These kinds of server package features have easy install that auto-configures most of the server settings. It will also install some essential tool for beginners to manage the server easily, such as GUI server administration panel.

Installing WAMP on Windows

WampServer is an open source HTTP and database server solution on Windows. WAMP stands for Windows, Apache, MySQL, and PHP package.

  1. Go to http://www.wampserver.com/en/download.php.
  2. Click on Download WampServer to download the installer.
  3. Run the installer with all default settings.
  4. The server is configured and ready.

The WampServer can run by launching from Start | Programs | WampServer | Start WampServer.

Flash Multiplayer Virtual Worlds

It will be in the task bar and the server management operation can be found by clicking the WampServer icon. We can start the server by putting the server online in the menu.

Installing MAMP on Mac OSX

Similar to WampServer, MAMP is the one package web server solution that stands for Mac, Apache, MySQL, and PHP package. The MAMP package can be downloaded at http://www.mamp.info/.

  1. Download the MAMP package from the official website.
  2. Double-click on the downloaded MAMP dmg file to mount it.
  3. Drag the MAMP folder into the Applications folder.

To run the MAMP server, go to Applications | MAMP and double-click on the MAMP.app.

Installing LAMP on Linux

As the same naming convention, the “L” stands for Linux here. Different Linux distributions use different ways to install applications. There may not be a oneclick install method on some Linux branch which requires us to install the Apache and MySQL individually. Some Linux may provide graphic user interface to install LAMP by just selecting it in the applications list. We will use Ubuntu to demonstrate the installation of LAMP.

  1. Launch terminal from Applications | Accessories | Terminal.
  2. Type following command to install LAMP.

    sudo tasksel install lamp-server

  3. The installer will progress and configure different modules.
  4. A dialog will prompt several times asking for a new MySQL root password. You can set your own MySQL password, while in the example we will leave the root password blank.

Flash Multiplayer Virtual Worlds

After the completion of the installation, the MySQL server is set up as service in the system. It runs automatically and we do not need to manually launch it to use it.

Connecting SmartFoxServer and MySQL server

SmartFoxServer is a Java application and Java database connection driver is needed to connect from SmartFoxServer to MySQL database.

Downloading JDBC Driver for MySQL

JDBC is a Java database connection driver that we need to establish connections between the Java-based SmartFoxServer and the MySQL server. The JDBC driver for MySQL is called Connector/J. We are going to install it to enable MySQL connection from SmartFoxServer.

  1. Go to http://dev.mysql.com/downloads/connector/j/5.1.html in web browser.
  2. Download the Platform Independent Zip Archive.
  3. It may ask you to log in to MySQL.com account. Click on No thanks, just take me to the downloads! to bypass the login step.
  4. Choose a mirror to download by clicking on HTTP.

Setting up the JDBC driver

The MySQL Java connector comes with a bunch of files. We only need two among them.

  1. Extract the mysql-connector-java-5.1.10.zip file to a temporary folder.
  2. Open the folder and find the mysql-connector-java-5.1.10-bin.jar file.
  3. Copy that jar file into SmartFoxServer installation directory | jre | lib | ext.
  4. Go into the src directory of the extracted directory and copy the org directory to SmartFoxServer installation directory | jre | lib | ext.

Configuring the server settings

The configuration file of SmartFoxServer is an XML file that allows us to configure many server settings. It can configure the initial zone or room creation, server address, admin authorization, value tuning for performance, and a lot more. We are going to set the database connection for testing our setup in this article (core settings are out of scope of this article).

The configuration file is called config.xml and is located in the SmartFoxServer installation directory under the Server directory.

Configuring MySQL server connection in SmartFoxServer

  1. Open the config.xml in your favorite text editor.
  2. Go to line 203 of the config.xml. This line should be within the structure of a Zone tag with name as dbZone.
  3. Change the lines 203-218 from the config.xml:
    Original code:

    <DatabaseManager active=”false”>
    Example connecting to MySQL




    <TestSQL><![CDATA[SELECT COUNT(*) FROM contacts]]></TestSQL>

  4. Replace the code in lines 203-218 with the following code:

    <DatabaseManager active=”true”>

    <TestSQL><![CDATA[SELECT NOW()]]></TestSQL>


The new setting activates the DatabaseManager and configures the JDBC driver to the MySQL connector that we just downloaded.

We also changed the user name and password of the connection to the database to “root” and empty password.

We will use the empty password through out the development process but it is strongly recommended to set your own database user password.

There is a TestSQL setting where we can write a simple database query so that the SmartFoxServer will try to run it to test if the database connection is correct. As we have not created any new databases for the virtual world, we will test the database connection by querying the current server time.

Restarting the server

We’ve just set up the connection between SmartFoxServer and third-party database. It is time to test the new setting by restarting the SmartFoxServer.

To stop the SmartFoxServer in Windows and Linux, press Ctrl + C. To stop it in Mac OS X, click on the Cancel button in the SmartFoxServer log window.

There is a log that appears as usual after we start up the server again. It is important to check the log carefully every time the config.xml is changed. The logfile can provide details of any errors that occur when it tries to load the configure file.

For example, if we configure the database connection just now but forget to activate the DatabaseManager, the server will start up correctly. Then you may spend a lot of time debugging why the database connection is not working until you find that the DatabaseManager is not active at all. This happened to me several times while I was developing my first flash virtual world.

If the server is running with the new database connection settings, the following lines will be appearing in the log. There can be different database manager settings for each zone. When checking the log, we should be aware which zone the log is referring to. We are configuring the database manager of dbZone zone now.

DB Manager Activated ( org.gjt.mm.mysql.Driver )

Zone: dbZone

If we forget to activate the DatabaseManager, we will not see the DB Manager Activated wording. Instead, the following message may appear in the log:

DB Manager is not active in this Zone!

Moreover, if the SmartFoxServer faces some fatal error on start up, it will terminate itself with more detailed error logs. The following lines are an example for error logs that appear when the MySQL connector file is missing:

Can’t load db driver: org.gjt.mm.mysql.Driver

[ Servre ] > DbManager could not retrive a connection. Java.sql.SQLException: Configuration file not found

DbManagerException: The Test SQL statement failed! Please check your configuration.

These lines state that the testing SQL failed to run, which we just set to test the connection. It also describes what exception has caused this error to help the debugging.

Flash Multiplayer Virtual Worlds


Please enter your comment!
Please enter your name here