How to Install & Use Ajax Chat
AJAX Chat is a relatively old innovation, and the project is abandoned, but it still works. It doesn’t just work. It works quite well. If you want a way to engage with your community and have your community engage with themselves, then look into AJAX Chat. In this tutorial, I will show you how to install and use AJAX Chat.
What You Need
There are several prerequisites for installing AJAX Chat. Here they are:
- A Website (See the tutorial on How to Make Your Own Website For Free (Except Domain Names)).
- A working installation of PHP
- A MySQL Server
- myBB or other forum software (optional)
- HTML5 (Client-Side)
- An internet connection
Alright, so let’s get on with the tutorial. This will be a bit more difficult than most tutorials, but it will still be doable.
Downloading AJAX Chat
As you need to download AJAX Chat to your server instead of just to your computer. I will send you the website to download the zip file, but also send the command to download it straight to your site. Here is the link to the downloads on the site (use this link if you want to integrate it with myBB or another forum software): https://frug.github.io/AJAX-Chat/. Now, here is the command to download the standalone directly to your server directory:
sudo wget https://github.com/Frug/AJAX-Chat/archive/0.8.8-standalone.tar.gz
Installing AJAX Chat
Alright, time for the installation. In this tutorial, we will be using the .tar.gz. If you downloaded the zip, use the unzip command. Otherwise, follow my instructions. (Replace AJAX-Chat-0.8.8-standalone with the tar you downloaded.)
sudo tar -xvzf AJAX-Chat-0.8.8-standalone.tar.gz
sudo rm AJAX-Chat-0.8.8-standalone.tar.gz
Now that we have extracted all of the files, it is time to proceed with the installation of the chat program. Perform the following command:
sudo mv AJAX-Chat-0.8.8-standalone/chat .
Set up MySQL
Now, it is time to set up AJAX Chat with the MySQL Server. Log into your SQL server and enter in the following queries:
CREATE DATABASE Ajax_Chat;
CREATE USER 'ajax_chat' IDENTIFIED BY '[PASSWORD]';
GRANT ALL PRIVILEGES ON 'Ajax_Chat' . * TO 'ajax_chat';
Now, you will want to tell AJAX Chat what user it will be logging in on. Enter in the following commands:
sudo cp config.php.example config.php
sudo nano config.php
Now, you should be in an editor. Replace the following lines in the document:
$config['dbConnection']['host'] = 'localhost';
$config['dbConnection']['user'] = 'root';
$config['dbConnection']['pass'] = '';
$config['dbConnection']['name'] = 'chat';
With the following values:
$config['dbConnection']['host'] = '[SQL SERVER IP]';
$config['dbConnection']['user'] = 'ajax_chat';
$config['dbConnection']['pass'] = '[AJAX_CHAT USER PASSWORD]';
$config['dbConnection']['name'] = 'Ajax_Chat';
Now that you have done that, it’s time to write the tables.
Writing the AJAX Chat Tables
In your web browser, go to the following URL: [YOUR WEBSITE]/chat/install.php
This will write the tables to your database, and you will be all set. Now, it is time to create your Admin user.
Creating the Admin User
If you are using AJAX Chat will myBB or another forum integration, you will not need to do this step. However, if you aren’t, you will have to manually write each user credentials, or figure out a way to write a custom registration page (I may have a tutorial on this later, but it won’t be easy.)
To do that, perform the following commands:
sudo nano users.php
This users file is filled with vulnerabilities. You will want to get rid of the example users as soon as possible. To start with, delete all of the users except for the very top one, which is necessary if you want to have guest users. Now, write the following user in for yourself:
$users = array();
$users['userRole'] = AJAX_CHAT_ADMIN;
$users['userName'] = '[YOUR USERNAME]';
$users['password'] = '[YOUR PASSWORD]';
$users['channels'] = array(0, 1);
Now that you have done that feel free to write down any friends. You can use the roles AJAX_CHAT_USER and AJAX_CHAT_MODERATOR to elevate the ranks of your friends.
Logging in is very simple. Just go to www.[YOUR WEBSITE].com/chat/. Now, enter the username and password you put in the users.php file. Now, enjoy your chat. I will probably be adding many more tutorials on AJAX Chat in the future, as it is highly customizable and incredibly useful. My friend Ashton who runs a subsite at https://buttered.infotoast.org has his chat, and he loves to use it (even though he can’t get many people to join it.)