Make a Website

How to Make Your Own Chat Room Website for Free

Three ways to run a chat room on your own domain: a ready-made PHP script, self-hosted open source like Rocket.Chat, or your own build. Costs, security and the trade-offs of each.

A browser chat room running on a personal website

A chat room on your own website is not hard to set up. The hard part is choosing how, because the three common routes suit very different people.

This guide walks through all three, tells you honestly what each costs, and covers the security basics most tutorials skip — the ones that matter the moment strangers start using your chat.

Which route should you take?

RouteGood forTimeCost
Ready-made PHP scriptYou want it working today1–2 hours$0–$50 once
Self-hosted open sourceTeams, communities, growthHalf a day$5–$10 / month
Build it yourselfLearning, or odd requirementsDays to weeksYour time

Most people reading this want route one. Start there, and switch later if you outgrow it.

What you need before anything else

  • A domain name — about $10 a year.
  • Web hosting with PHP and MySQL — shared hosting is fine for routes one and three. Route two needs a VPS.
  • An SSL certificate — free, and not optional. Browsers now block microphone and camera access on plain HTTP, so voice and video will silently fail without it.

If you do not have hosting yet, read what actually matters in cheap web hosting first.

Route 1: Install a ready-made PHP chat script

This is the fastest path. You buy or download a PHP chat script, upload it, point it at a database, and it runs.

Step 1: Upload the files

Log into your hosting control panel and open File Manager. Go to public_html, upload the script zip, then use Extract. Uploading a single zip and extracting on the server is far faster than uploading hundreds of loose files.

If you want the chat at your main address, extract into public_html itself. For yoursite.com/chat/, make a chat folder and extract there.

Step 2: Create the database

In cPanel, open MySQL Databases and do three things in order:

  1. Create a database, for example chatroom
  2. Create a user with a strong password
  3. Add that user to the database with All Privileges

Write down all three values. cPanel usually prefixes them with your account name, so the real database name looks like youruser_chatroom. Missing that prefix is the most common install failure.

Step 3: Run the installer

Open your domain in a browser. The installer asks for the language, sometimes a licence code, then the database details from the step above. It creates the tables and asks you to make the first admin account.

After installing you will normally have an admin panel at yourdomain.com/admin and the user login at yourdomain.com/login.

Step 4: Force HTTPS

In the admin settings, change the site URL from http:// to https://. Do this even if the site already loads over HTTPS — scripts often store the address and build links from it, and a stored http:// will break file uploads and media.

Need the certificate itself? See how to install a free SSL certificate.

Step 5: Delete the installer

Almost every script ships with an install/ folder. Delete it once setup is finished. If it stays, anyone who finds it can re-run the installer and take over your site. This single step is skipped constantly and it is the most common way small sites get hijacked.

What these scripts usually include

  • Responsive layout that works on phones
  • One-to-one and group rooms
  • Image, audio and video sharing with previews
  • File transfer
  • Online and offline status
  • Profile pictures and themes
  • Blocking and banning users

Route 2: Self-host open-source chat

If the chat is for a team, a community, or anything you expect to grow, a ready-made script will start to feel limiting. Self-hosted open-source chat is a better long-term home.

SoftwareBest forNotes
Rocket.ChatCommunities and teamsClosest to Slack. Web, desktop and mobile apps.
MattermostTeams and companiesLighter on resources, strong permissions.
OpenfireChat that also feeds mobile appsXMPP standard. Pairs with Android apps.

All three are free. You pay only for the server, around $5 to $10 a month. They need a VPS rather than shared hosting, because they run continuously as services.

If you plan to add an Android app later, choose Openfire — see how to set up Openfire on Ubuntu, and then how to create a chat app in Android Studio that connects to it.

Route 3: Build it yourself

Worth doing if you are learning, or if your requirements are unusual enough that nothing off the shelf fits. A basic chat needs surprisingly little:

  • Database — two tables are enough to start: users and messages.
  • Sending — a form posts to a PHP file that inserts the message.
  • Receiving — the simple version asks the server for new messages every two seconds. It works, and it is fine for a handful of users.
  • Scaling up — once you have more than a few dozen people, that polling hammers your server. Move to WebSockets with something like Ratchet for PHP or Socket.IO with Node.js.

Expect days rather than hours, and expect the hard parts to be the ones nobody mentions: handling disconnects, stopping spam, and keeping message order correct.

Security: do these five things

The moment strangers can type into your site, it becomes a target. None of this is optional.

  1. Delete the install folder. Said twice on purpose.
  2. Force HTTPS everywhere. Without it, logins travel in plain text.
  3. Escape everything users type. If a user can post <script> tags and they run for other people, you have an XSS hole. Ready-made scripts usually handle this; your own code will not unless you do it.
  4. Rate-limit messages. One person with a script can post thousands of messages a minute and fill your database.
  5. Keep the script updated. Chat scripts are a popular target precisely because so many installs are abandoned and never patched.

What it costs

ItemRoute 1Route 2Route 3
Domain$10/yr$10/yr$10/yr
Hosting$3/mo shared$5–10/mo VPS$3/mo shared
Software$0–$50 onceFreeFree
SSLFreeFreeFree
Your time1–2 hoursHalf a dayDays

Common problems

Blank white page after upload

A PHP error with error display turned off. Check the error log in cPanel. Most often the PHP version is wrong — try switching between 7.4 and 8.x in Select PHP Version.

"Database connection failed"

Nine times out of ten the cPanel prefix is missing. The name is youruser_chatroom, not chatroom. Also confirm the user was actually added to the database with all privileges.

Messages send but images do not

The uploads folder needs write permission — set it to 755. Also check upload_max_filesize in Select PHP Version → Options; the default is often only 2 MB.

Voice or video does not start

Browsers block the microphone and camera on plain HTTP. The site must be on HTTPS, with no mixed-content warnings.

Where to go next

Once the chat works, the usual next steps are a mobile app so people are not tied to a browser, and push notifications so they see messages while away.

For the mobile side, read how to create a chat app in Android Studio — it uses the same XMPP server, so one back end can serve both your website and your app.

Questions people ask

Can I make a chat room website completely free?
The software can be free — Rocket.Chat, Mattermost and Openfire all are, and some PHP chat scripts are too. You still pay for a domain (about $10 a year) and hosting (from about $3 a month). Free subdomains and free hosting exist, but they are slow and usually ban real traffic.
Do I need to know coding to make a chat room?
No, if you use a ready-made PHP script or self-host Rocket.Chat. You upload files, create a database and run an installer. You only need coding if you build your own from scratch.
Can I use shared hosting, or do I need a VPS?
Shared hosting is fine for a PHP chat script, because it is just PHP and MySQL. Rocket.Chat, Mattermost and Openfire need a VPS, because they run as continuous services and shared hosting does not allow that.
Why is my chat showing a blank white page?
A PHP error with error display switched off. Open the error log in cPanel. The most common cause is the wrong PHP version — try switching between 7.4 and 8.x under Select PHP Version.
Why does the database connection keep failing?
Usually the cPanel prefix is missing. cPanel names the database youruser_chatroom, not chatroom, and the same applies to the username. Also check the user was added to the database with All Privileges.
Is a self-hosted chat room secure?
It can be, but only if you do the basics: delete the install folder after setup, force HTTPS, escape anything users type, rate-limit messages, and keep the script updated. Abandoned, unpatched chat scripts are a favourite target.
How many users can a chat room handle?
A PHP script on shared hosting is comfortable with 20 to 50 people chatting at once. Beyond that, the constant polling starts to slow the server. Rocket.Chat or Mattermost on a small VPS handles several hundred.
Can I add voice and video calls to a chat room website?
Yes, but the site must be on HTTPS — browsers block microphone and camera access on plain HTTP. Rocket.Chat includes calls. For a PHP script, check it supports WebRTC before you buy it.
Can I have both a chat website and a mobile app?
Yes, if you pick a back end that serves both. Openfire is the usual choice: it runs the web chat and also talks to an Android app built on XMPP, so one server and one user list covers both.
How do I make a chatting website in PHP?
The quick way is a ready-made PHP chat script: upload it, create a MySQL database and run its installer (Route 1). To code it yourself you need two tables, users and messages, a PHP file that saves each message, and a page that asks the server for new messages every two seconds (Route 3). Past a few dozen users, move to WebSockets, for example Ratchet for PHP.

Written by Habib Baloch

I build Android apps, websites and Ubuntu servers, and write down exactly how I did it.

Ask me about this guide →