XAMPP · PHP · MySQL

Localhost to online: how to make your XAMPP website live

Your PHP project works at http://localhost on your laptop. This tutorial moves it, database and all, to cPanel hosting so anyone can open it, and fixes the errors that usually appear on the way.

In short

To take a localhost website online, export your MySQL database from phpMyAdmin as an .sql file, upload your project files to public_html with cPanel File Manager, create a new database and user in cPanel, import the .sql file through cPanel's phpMyAdmin, then update your config file with the new database name, user and password. On shared hosting the database host is usually still localhost.

XAMPP and WAMP make it easy to build a PHP and MySQL project on your own laptop, which is why so many college projects start there. Taking it online is a different job: you are copying two things, the files and the database, to a server that is set up a little differently from your laptop. This guide uses cPanel, which most shared hosting in India uses, including ours.

Key takeaways

  • Moving from localhost means moving files and a database, then pointing the code at the new database.
  • On cPanel hosting, database and user names get your account name added in front, such as myacct_shop.
  • The database host on shared hosting is usually still localhost.
  • Most errors after going live come from hard-coded localhost URLs, Windows file paths, or capital letters in file and table names.

What changes between XAMPP and hosting

The PHP code is the same; the surroundings change. Knowing these differences in advance explains nearly every error you might see.

ItemXAMPP on your laptopcPanel hosting
Website folderC:\xampp\htdocs\projectpublic_html (or a folder inside it)
Addresshttp://localhost/projecthttps://yourdomain.in
Database userroot, often with no passwordA user you create, with a strong password
Database nameshopmyacct_shop (account prefix added)
Database hostlocalhostUsually localhost as well
File namesWindows ignores capital lettersLinux treats Logo.png and logo.png as different files

Step 1: Export your database from phpMyAdmin

Export the database on your laptop into a single .sql file. This file holds your tables and all their data.

  1. Start Apache and MySQL in the XAMPP Control Panel, then open http://localhost/phpmyadmin.
  2. Click your project's database in the left-hand list.
  3. Open the Export tab, keep the Quick method and SQL format, and click Export (or Go).
  4. Save the .sql file somewhere you can find it.

Step 2: Upload your files with cPanel File Manager

Zip the project, upload the ZIP once, and extract it on the server. Uploading hundreds of small files one at a time is slow and easy to get wrong.

  1. On your laptop, open the project folder inside htdocs, select everything inside it and compress it into a ZIP.
  2. Log in to cPanel and open File Manager, then go into public_html.
  3. Click Upload, choose the ZIP and wait for it to finish.
  4. Back in File Manager, right-click the ZIP and choose Extract. Delete the ZIP afterwards.

Your index.php should sit directly inside public_html if the project is the main site. If it ends up in public_html/project, the site will open at yourdomain.in/project instead.

Step 3: Create the database and import your data

cPanel needs an empty database, a user allowed to use it, and then your exported data loaded into it. It takes two short tasks.

Create the database and user

The MySQL Database Wizard creates the database, creates the user and links them in one go.

  1. In cPanel, open MySQL Database Wizard.
  2. Enter a database name, for example shop. cPanel shows the full name with your prefix, such as myacct_shop. Note it down.
  3. Create a user, use the password generator, and save the full username and password.
  4. Tick All Privileges and finish.

Import the .sql file

Load your exported file into the new, empty database using the phpMyAdmin inside cPanel.

  1. In cPanel, open phpMyAdmin and click your new database in the left-hand list.
  2. Open the Import tab, choose your .sql file and click Import (or Go).
  3. Check that your tables now appear in the list.

If the import complains about creating a database or about access being denied, your export probably includes a CREATE DATABASE line. Open the .sql file in a text editor, delete that line and any USE line, and import again. If the file is too large to upload, compress it as a ZIP first or ask your host's support to import it for you.

Step 4: Update your config file

Find the file where your project connects to MySQL, often called config.php, db.php or connection.php, and change the four connection values. Edit it in File Manager with the Edit option.

  • Host: keep localhost unless your host tells you otherwise.
  • Database: the full prefixed name, such as myacct_shop.
  • User: the full prefixed username, such as myacct_shopuser.
  • Password: the password you generated in Step 3.

For a project using mysqli, the line ends up looking like mysqli_connect('localhost', 'myacct_shopuser', 'your-password', 'myacct_shop').

Step 5: Fix paths, links and http/https

Search your code for anything that only made sense on your laptop. A text editor's "find in files" makes this quick.

  • Replace http://localhost/project in links, form actions and image paths with relative paths or your real domain.
  • Replace Windows paths such as C:\xampp\htdocs\project\uploads with paths built from __DIR__.
  • Make every file name in your code match the real file's capital letters exactly. Table names in SQL queries can be case-sensitive on Linux too.
  • Once free SSL is active, change any remaining http:// links to https://, or browsers will warn about insecure content.
  • For WordPress, the siteurl and home values in the wp_options table still say localhost; update them, or use a migration plugin that rewrites URLs for you.

If the project needs a particular PHP version or extension, check the PHP settings in cPanel or ask support before assuming the code is broken.

Common errors after going live

A blank page or an error message almost always points to one of the steps above. cPanel's Errors page and the error_log file in your folder show the exact message.

  • "Access denied for user": the username or password in your config is wrong, or the user was not added to the database.
  • "Table doesn't exist": the import did not finish, or a table name's capital letters differ from your query.
  • Images or CSS missing: a path still points at localhost, or a file name's case does not match.
  • The site redirects to localhost: a hard-coded URL, or the WordPress siteurl setting.

Which hosting plan suits a student project

Our cPanel hosting runs PHP and MySQL, with phpMyAdmin, File Manager and free SSL included. A small PHP project fits the 500 MB plan at ₹1,800 a year; a larger one with uploads, the 2 GB plan at ₹6,000 a year, both plus GST. Our pages on hosting a PHP website and hosting for students have more detail, and if you get stuck, contact us by phone or WhatsApp.

Frequently asked questions

How do I make my localhost website live?

Export the database from phpMyAdmin, upload your project files to public_html in cPanel, create a database and user in cPanel, import the .sql file, and update your config file with the new database details. Then fix any links that still point to localhost, and connect your domain.

What should the database host be on shared hosting?

On cPanel shared hosting it is usually localhost, the same as XAMPP, because the database runs on the same server as your website. What changes is the database name, username and password, which get your cPanel account name added in front. Your host will tell you if theirs is different.

Why do I get "Access denied for user" after uploading?

The config file has the wrong username or password, the name is missing the cPanel prefix, or the user was not added to the database with privileges. Check all three in cPanel's MySQL Databases page, then copy the exact names into your config file.

Can I upload my XAMPP project with FTP instead of File Manager?

Yes. An FTP program such as FileZilla works with the FTP details from your cPanel. File Manager is easier for a first upload because you can upload one ZIP and extract it on the server, which is much faster than sending hundreds of small files.

Will my project work the same online as on XAMPP?

Usually, once the database details and paths are fixed. The common differences are capital letters in file and table names, which Linux servers treat as different, hard-coded localhost URLs, Windows file paths, and PHP settings or extensions that differ from your laptop.

WhatsApp