08. Creating a Web Interface - Part 1/3

What is a Web Interface (WI)?

Take a look at mine and see for yourself.

To create a WI you will need three pieces of software, and this is the reason for me splitting this tutorial into three sections.

IMPORTANT:
Many ISP's now, especially on home connections, block outbound port 25 to prevent compromised machines spamming, and instead force you to relay through their SMTP servers. This means that WI will not work, as the email confirmation will not get through (as it needs Port 25).

To test if your ISP blocks port Port 25, download the free utility Putty. Open Putty, and put the following:

Hostname: gmail-smtp-in.l.google.com
Port: 25
Connection Type: Telnet

Click Open

A DOS-like window should open, and you should get a response similar to this:

220 mx.google.com ESMTP b17si7069788fka.27

If you do you are good to go and can proceed with this tutorial. If you don't get a response then you cannot use email for new user confirmation or for group messages, however, you can use Captcha instead for new user confirmation, and this is described in Part 3.

Now hit the Enter key in that DOS-like window, and type QUIT (in capitals). That will close the window and Putty.

Software Required
The first piece of software you need is WAMP. WAMP stands for Apache, MySQL, PHP on Windows (sort of back-to-front I know). This free suite is amazing.

Basically the suite installs:

Apache: this will turn your server into a fully-fledged web-server

PHP: this will enable your server to run php scripts to run things such as a Web-Interface

MySQL: the preferred database engine for opensim

The suite has some great tools included too, such as phpMyAdmin which allows you to explore and change your MySQL database.

Before we start, if you already have MySQL installed on your machine, you should make a backup of your database, and uninstall MySQL. To do this:

a) Create a Backup of your database
Open a command console window (go to Start, Run, and type 'cmd' (without the quotes) in the Open: box.). In the command console type the following:

mysqldump -u root -p opensim > c:\opensim.sql

This command starts the mysqldump backup utility. The full syntax for this command is:

mysqldump -u [username] -p [databasename] > [backupfile.sql]

where:

username = the user name you use in MySQL, usually 'root' the -p switch will prompt you for the password you use for MySQL

databasename = the name of the database you wish to backup, in our case this is 'opensim'

backupfile.sql = the path and name of the backup file, can be anything, for example, c:\opensim.sql'

b) Uninstall MySQL
If MySQL is running as a Windows service you must first stop it. To do this go to Start, Settings, Control Panel, Administrative Tools, Services. Scroll down till you see MySQL, select it, and choose Stop the Service from the left-pane.

It is much easier to use the same User name and Password for your new MySQL so make a note of it now, before uninstalling.

You can now uninstall MySQL in the normal way, by going to Start, Settings, Control Panel, Add or Remove Programs. Scroll down until you see MySQL Server 5.0, select it, and choose Remove.

Step 1: Installing WAMP
You can download your copy of WampServer from here. I do not intend to reinvent the wheel, as there is an excellent step-by-steo guide to installing WampServer, with screenshots, on the JLBN website. Just follow their steps, to the bottom of the page, then it will ask, When you are ready, click here to go to the next page, and so on to the end.

Once WampServer is installed you will see the icon in the System Tray, left-click it, and at the bottom of the Wamp menu you will see Put Online, choose this, then select Start All Services. Wamp and its services are now running.

Step 2: Configure MySQL
From the Wamp menu select phpMyAdmin.
In the left pane select mysql.
Check the checkbox besides 'user' and then click the Browse icon to its right.
The first entry should be 'localhost' 'root', check the checkbox then click the Pencil edit.
The first three Fields are Host, User and Password.
For Host, make the Value localhost. Leave the Function blank.
For User, make the Value root (or whatever MySQL username you chose). Leave the Function blank.
For Password, make the Value the MySQL password you chose. For Function, select PASSWORD from the drop-down box. This is very IMPORTANT.
At the bottom of this table you will see a Go button, hit it.
In the left pane, at the top, you will see a little Home icon, click this.
In the right pane you will see the option to Reload Privileges, hit this, it should say Reloaded Successfully.
Now click on Databases, and in the Create new database box, type 'opensim' (without the quotes) or whatever name you have used for your MySQL opensim database.

If you get an 'Access denied' error at this point, do the following:

Open Explorer and navigate to wamp\apps\phpmyadmin
Open the config.inc.php file in Notepad
Find the line: $cfg['Servers'][$i]['password'] =
The password in the quotes will be blank, enter your MySQL password here, save.
Close down phpMyAdmin, then reopen it (to clear the cache)
Click on the Home icon, and you should be able to create a database now

Use the same name for your database that you used previously (if you were using MySQl previously).
Once the database has been created it will appear in the left pane.
Close phpMyAdmin

Step 3: Configure Apache
Click on the Wamp system tray icon, go to Apache, Service, and Stop the service.
Using Explorer navigate to wamp\bin\apache\apache2.2.8\bin
Open the file php.ini and scroll down to Language Options
Find the line that says: short_open_tag = Off and change this to On
A couple of lines below should be: asp_tags = Off, change this to On too
Now scroll down till you find the [Mail Function] section
Under Win 32 there should be a line that says
;sendmail_from = me@example.com
Remove the leading semicolon
Save and close.

Apache also needs the TCP port 80 opening in your firewall, so do this now.

Now click on the Wamp system tray icon, go to Apache, Service, and Start the service.


Step 4: Import your MySQL database
We are now ready to import the previously backed-up opensim database (c:\opensim.sql)

Navigate to c:\opensim.sql (or wherever you saved it to, right-click and choose Cut
Navigate to: wamp\bin\mysql\mysql5.0.51b\bin and paste the file there
Open a cmd window, and change directory (cd) until you get to the bin folder above
Now type the command: mysql -uroot -p opensim < opensim.sql

You will know when the database has finished loading when you see the dos prompt again.


Step 5: Check that all is OK

You might want to check at this point that you can see your Wamp server page. Go to your domain (or IP address) in a web browser, with no port number, (for example, mine was http://anubia.servegame.org), and you should see the Wamp server page.

If this is OK you can now start the next part of this tutorial and install the Web-Interface software.

18 comments:

  1. Rock, change the line to restore the database please! it caused a minor panic.

    ReplyDelete
  2. Hi Carly,

    Can you tell me which Step and which line in that step is causing the problem?

    Rock

    ReplyDelete
  3. Well at the time it appeared to me as Now type the command: mysql -uroot -p opensim (left carat) style="font - weight: bold, " (right carat)Step 5:

    I see it was just my browser sabotaging me with a little HTML tag. Never mind.

    ReplyDelete
  4. yeah, the line under Step 4 that starts with 'now type the command:' is showing your html tag for what is supposed to be Step 5...

    Using Maxthon v1.6.4b20

    ReplyDelete
  5. Thanks guys. The html is now corrected so Step 5 now shows properly.

    Rock

    ReplyDelete
  6. Rock,
    Love your tutorials. just throught you might want to update the path for latest version of mysql in wamp downloaded yesterday:
    C:\wamp\bin\mysql\mysql5.1.30\bin>

    Not that I have gotten the restore command to work. feels like I'm missing a step:C:\wamp\bin\mysql\mysql5.1.30\bin>mysql -uroot -p opensimdata
    Enter password: ********
    Welcome to the MySQL monitor. Commands end with ; or \g.
    Your MySQL connection id is 15
    Server version: 5.1.30-community-log MySQL Community Server (GPL)

    Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

    mysql>

    ReplyDelete
  7. Update
    from mysql>
    source opensimdata \g

    restored the database

    ReplyDelete
  8. source opensim.sql ;
    Is what I fianlly got to work from the mysql prompt.

    Love these tuts!

    ReplyDelete
  9. WAMP Server link is dead now.

    ReplyDelete
  10. I just use VNC and Desktop sharing to do what i need to do :)

    ReplyDelete
  11. can i use xampp instead of wamp?

    ReplyDelete
  12. I try to run this on IIS7 with opensimulater 0.6.6 in Hypergrid mode. But I don't get out of this SQL Error Nightmare. I've of course did all the things like short_tags, asp, etc. but without success.

    Is opensimwi only for sims in grid mode???

    ReplyDelete
  13. yeah pretty much

    ReplyDelete
  14. This tutorial may have been written a few years ago, but still,,, there is no front end for opensim robust, nobody has been able to make a fully working front end, so that the option of running a grid can be used out-of-the-box, it seems to have that option only the masters of php and mysql programming will be able to run their own grids.
    the current wiredux(redux) is 100% unstable and non working resulting in numerous database errors for non existing tables, that should have been created in the sql file, EG:- Database error: Invalid SQL: SELECT UUID, currentRegion FROM agents where agentOnline = 1 AND logintime < (UNIX_TIMESTAMP(FROM_UNIXTIME(UNIX_TIMESTAMP(now())))) AND logoutTime < (UNIX_TIMESTAMP(FROM_UNIXTIME(UNIX_TIMESTAMP(now())))) ORDER BY logintime DESC
    MySQL error: 1146 (Table 'opensim.agents' doesn't exist)

    ReplyDelete
  15. ADDENDUM to previous post:-

    and this error too when trying to access the admin section:-

    Database error: Invalid SQL: SELECT count(*) FROM users
    MySQL error: 1146 (Table 'opensim.users' doesn't exist)
    Session halted.

    SO, it seems the administrators of grids that are running, such as OSGrid, want to be the only grid(s) outside Second Life and don't like it when someone else asks for their help in setting up a grid, otherwise, they would help, but they DON'T.

    Surely, someone has to come up with a brand new opensim front end and just trash wiredux(redux), then integrate it into the opensim package, with an installer for both Windows and Linux.

    ReplyDelete
  16. Hi all,
    Solved "Database error: Invalid SQL: SELECT count(*) FROM users
    MySQL error: 1146 (Table 'opensim.users' doesn't exist)
    Session halted."

    Simply Rename the wi_users.sql to users.sql
    Then follow the import step again just for the users.sql
    This solved the problem for me, Still buggy as hell but at least now have the admin menu and have the majority of the interface working

    ReplyDelete
  17. With doing the Above you will also need to "If all software is up to date" keep the "useraccounts" in the "opensim" DB Sync with the new "user" DB.

    The upgrade "Not sure what version" changed the name of the db the web interface called for, from "user" to "useraccounts"

    ReplyDelete
  18. All is working using localhost but as soon i use my ip address with port 80 open in/out it says can't find etc ...

    ReplyDelete