An AJAX Chat
| | |

How to Make a Live Group Chat on Your Website for Free, With No Discord

How to Install & Use Ajax Chat

AJAX Chat is a relatively old innovation, and the project has been abandoned, but it still works—it doesn’t just work—it works quite well. If you want to engage with your community and have them engage with themselves, then look into AJAX Chat. In this tutorial, I will show you how to install and use AJAX Chat.

An AJAX Chat
This is my friend’s AJAX Chat on his site.

What You Need

There are several prerequisites for installing AJAX Chat. Here they are:

  1. A Website (See the tutorial on How to Make Your Own Website For Free (Except Domain Names)).
  2. A working installation of PHP
  3. A MySQL Server
  4. myBB or other forum software (optional)
  5. HTML5 (Client-Side)
  6. JavaScript (Client-Side)
  7. An internet connection

Tutorial

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

You need to download AJAX Chat to your server instead of just to your computer. Below is the website to download and a 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:

cd /var/www/html
sudo wget https://github.com/Frug/AJAX-Chat/archive/0.8.8-standalone.tar.gz

The AJAX Chat Website
The AJAX Chat Website

Installing AJAX Chat

Alright, it’s 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.)

See also  How To Install OptiFine on Chromebook

cd /var/www/html
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

It is time to set up AJAX Chat with the MySQL Server. Log into your SQL server and enter the following queries:

CREATE DATABASE Ajax_Chat;
CREATE USER 'ajax_chat' IDENTIFIED BY '[PASSWORD]';
GRANT ALL PRIVILEGES ON 'Ajax_Chat' . * TO 'ajax_chat';
FLUSH PRIVILEGES;

Now, you will want to tell AJAX Chat what user it will be logging in on. Enter in the following commands:

cd /var/www/html/chat/lib
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';

The Variables You Will Want to Edit
The Database Variables on 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 with 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’s credentials or figure out how to write a custom registration page (I may have a tutorial on this later, but it won’t be easy).

See also  The Poor Man's Guide to Making a Supercomputer

To do that, perform the following commands:

cd /var/www/html/chat/lib/data
sudo nano users.php

This user file is filled with vulnerabilities. You will want to eliminate the example users as soon as possible.  To start with, delete all users except for the very top one, which is necessary if you want guest users. Now, write the following user in for yourself:

$users[1] = array();
$users[1]['userRole'] = AJAX_CHAT_ADMIN;
$users[1]['userName'] = '[YOUR USERNAME]';
$users[1]['password'] = '[YOUR PASSWORD]';
$users[1]['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 your friends’ ranks.

Do NOT Mess with the Guest Variable
Do NOT mess with these guest user variables at the top of users.php

Logging In

Logging in is very simple. Just go to www.[YOUR WEBSITE].com/chat/. Enter the username and password you put in the users.php file, and enjoy your chat. I will probably add many more tutorials on AJAX Chat in the future, as it is highly customizable and incredibly useful.

My friend's website, Buttered
My friend’s website, Buttered. Check it out. It’s a great site!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *