How to Deploy a PHP Project to a Live Server — Complete Beginner’s Guide 2026
Getting a live URL for your PHP project is the single biggest upgrade to your portfolio — and the step most students never take. This guide walks you through the complete process: choosing free hosting, uploading your files via FileZilla, migrating your database, and going live — step by step, with every common error solved.
Your project works perfectly on XAMPP. You can log in, navigate, add records, and export PDFs. But when a recruiter or interviewer asks “can I see it running?” — you have to say no, because it only exists on your laptop. A live URL changes everything.
“Live demo: https://hospital-demo.infinityfree.net” on a CV turns a description into evidence. A recruiter who can click and see your system running in 30 seconds is significantly more impressed than one reading “I built a hospital management system in PHP.” This guide gets you from XAMPP to live server in one afternoon.
Your goal by the end of this tutorial:
Step 1 — Choose Your Free Hosting
For student portfolio projects, you do not need paid hosting. These options are genuinely free with no credit card required and support PHP + MySQL — exactly what Codezips projects need:
| Host | URL Format | PHP | MySQL DBs | Storage | Best For |
|---|---|---|---|---|---|
| InfinityFree ⭐ Recommended | yourname.infinityfree.net | PHP 8.2 | Unlimited | 5GB | Management system projects, most Codezips downloads |
| WebHostMost | yourname.webhostmost.com | PHP 8.1 | Unlimited | 1GB | Simple PHP projects, fast setup |
| 000webhost | yourname.000webhostapp.com | PHP 7.4 | 1 DB | 300MB | Very small test projects only |
| Railway.app | yourname.up.railway.app | Any version | Included | 5GB | Slightly technical — better for developers comfortable with Git |
| Hostinger (paid) | yourdomain.com | PHP 8.3 | 100 DBs | 100GB | Professional portfolio — ~£2/month, worth it for job applications |
This tutorial uses InfinityFree — it is the most reliable free option for PHP/MySQL projects, has cPanel, and your site stays up 24/7. Sign up at infinityfree.com (no credit card required). After creating an account and a hosting account, you get access to a cPanel dashboard.
Step 2 — Prepare Your Project Files for Upload
Before uploading anything, do four things to your project files on your local machine:
2a — Remove your database credentials from the connection file
Your XAMPP config probably has username: root and password: (empty). The live server will have different credentials. You need to update the config file after you create the live database. For now, note where your credentials are stored.
Your typical XAMPP dbconnection.php — you will update these 4 values for live
<?php
// config/dbconnection.php
// XAMPP values (local): → Live server values (you will fill these in Step 5)
$host = 'localhost'; // stays 'localhost' on most hosts
$dbname = 'hospital_db'; // → your InfinityFree database name
$username = 'root'; // → your InfinityFree DB username
$password = ''; // → your InfinityFree DB password
$conn = mysqli_connect($host, $username, $password, $dbname);
if (!$conn) {
die('Connection failed: ' . mysqli_connect_error());
}
?>
dbconnection.php is in your .gitignore file. Pushing database credentials to a public GitHub repo is a serious security mistake. Add config/dbconnection.php to .gitignore and create a dbconnection.example.php with placeholder values instead.
2b — Export your database from phpMyAdmin
- Open XAMPP → click phpMyAdmin (or go to localhost/phpmyadmin)
- Click your project database in the left panel (e.g.
hospital_db) - Click the Export tab at the top
- Format: SQL — leave all other settings as default
- Click Export — this downloads a
.sqlfile to your computer. Save it asdatabase_export.sql
2c — Create a ZIP of your project files
Select your entire project folder (e.g. hospital_management/) and compress it to a .zip file. This makes uploading much faster than transferring files individually — especially useful for projects with many files.
Step 3 — Upload Your Files via FileZilla (FTP)
FileZilla is a free FTP client. Download it from filezilla-project.org. Your InfinityFree hosting account shows your FTP credentials in the cPanel dashboard under “FTP Accounts.”
- Open FileZilla. In the top bar: Host = your FTP hostname from InfinityFree (e.g.
ftpupload.net), Username and Password = from your hosting dashboard, Port = 21. Click Quickconnect. - In the right panel (remote server), navigate to the
htdocsorpublic_htmlfolder — this is where your website files must go. - In the left panel (your computer), navigate to your project folder.
- Select your project ZIP file on the left, drag it to
public_htmlon the right. Wait for the upload to complete (progress shows in the bottom panel). - After uploading, right-click the ZIP in the right panel and look for an Extract option — or use cPanel File Manager to extract it (login to cPanel → File Manager → navigate to public_html → right-click the zip → Extract).
Step 4 — Create and Migrate Your Database
This is the most important step. On InfinityFree you need to: (1) create a new database, (2) create a database user, (3) import your SQL file.
- In InfinityFree cPanel, click MySQL Databases
- Under “Create New Database,” enter a name (e.g.
hospital) — note that InfinityFree prefixes it with your account ID automatically, giving you something likeepiz_12345678_hospital - Under “Create New User,” enter a username and password — note these down carefully
- Under “Add User to Database,” add your new user to your new database with All Privileges
- Now open phpMyAdmin from the cPanel dashboard
- Select your new database in the left panel
- Click the Import tab
- Choose your
database_export.sqlfile and click Import - Wait — you should see a green success message when done
Write down your live database credentials — you need them in the next step:
Your live database details — fill these in after creating the database
Host: localhost (almost always localhost — confirm in your cPanel)
DB Name: epiz_12345678_hospital (the full prefixed name InfinityFree gave you)
Username: epiz_12345678_youruser (also prefixed)
Password: [the password you created in Step 4]
Step 5 — Update Your Config File on the Live Server
Now update the dbconnection.php on the live server with your live database credentials. Use FileZilla or cPanel File Manager to open and edit the file directly on the server.
Updated dbconnection.php — use your live database credentials here
<?php
// LIVE SERVER config — replace these with your InfinityFree database details
$host = 'localhost';
$dbname = 'epiz_12345678_hospital'; // ← your full DB name from cPanel
$username = 'epiz_12345678_youruser'; // ← your DB username
$password = 'YourSecurePassword123'; // ← your DB password
$conn = mysqli_connect($host, $username, $password, $dbname);
if (!$conn) {
die('Connection failed: ' . mysqli_connect_error());
}
?>
Also check your file paths
On XAMPP your paths might start with C:/xampp/htdocs/project/. On a live server, absolute paths use /home/username/public_html/project/. Always use __DIR__ or relative paths in your PHP includes to avoid path issues:
Use __DIR__ for reliable paths that work on both XAMPP and live servers
// Bad — hardcoded path that breaks on live server:
require_once 'C:/xampp/htdocs/hospital/config/dbconnection.php';
// Good — relative path from current file:
require_once '../config/dbconnection.php';
// Best — absolute path using __DIR__ (works everywhere):
require_once __DIR__ . '/../config/dbconnection.php';
Your Deployment Checklist
✅ Before You Share Your Live URL — Verify Everything
Error Troubleshooter — Fix the Most Common Deployment Errors
Fix: Open dbconnection.php on the live server via FileZilla or cPanel File Manager. Update all four values: host (usually localhost), database name (use the full prefixed name like epiz_12345678_hospital), username, and password. Save and refresh your site.
Fix: Update all include/require statements to use relative paths (../config/dbconnection.php) or __DIR__ paths (__DIR__ . ‘/../config/dbconnection.php’). These work correctly on both XAMPP and the live server regardless of where the project is installed.
Fix: Temporarily add these two lines at the very top of your index.php or the page showing the blank screen:
ini_set('display_errors', 1); error_reporting(E_ALL); — refresh to see the actual error. Once you have fixed the issue, remove these lines — you do not want to show raw PHP errors to visitors.Fix: Check your CSS and image links. Change absolute paths like
href="C:/xampp/htdocs/hospital/assets/style.css" to relative paths like href="assets/style.css" or root-relative like href="/assets/style.css". For images in PHP, use: src="= dirname($_SERVER['PHP_SELF']) ?>/assets/images/logo.png"Fix: Open phpMyAdmin on the live server, select your database, and verify the tables are there (you should see the same tables that exist on XAMPP). If the tables are missing, import your SQL file again. If tables exist but the database name in dbconnection.php does not match the actual database name (remember InfinityFree prefixes it), update dbconnection.php with the correct full name.
Frequently Asked Questions
Is free hosting reliable enough for a portfolio? Will my site go down?
InfinityFree has reasonable uptime for a free service — typically 99%+ in normal conditions. The main limitation is that if your site gets a sudden spike of traffic (very unlikely for a student portfolio), it may throttle or temporarily suspend your account. For job applications and portfolio purposes, this reliability is entirely sufficient. The bigger risk is that free hosting providers occasionally shut down or change their terms — keep a backup of your files and database locally at all times. If you are actively job hunting and want maximum reliability, a £2/month Hostinger plan eliminates all these concerns.
My university network blocks FTP connections. What do I do?
Use cPanel’s built-in File Manager instead — it works in any browser without needing FTP. Login to your InfinityFree cPanel, click File Manager, navigate to public_html, and use the Upload button to upload your files directly through the browser. For the database, phpMyAdmin also works through the browser with no FTP needed. If your project has many files, zip them first — File Manager lets you upload a single zip and then extract it on the server.
How do I update my live site when I make changes locally?
For individual file changes: open FileZilla, navigate to the changed file on the left (your computer), and drag it to the corresponding location on the right (server) — this overwrites the old version. For database changes: export just the changed table or run the specific ALTER/INSERT query in live phpMyAdmin rather than re-importing the entire database. For large updates, a Git-based workflow (push to GitHub, pull on server) is more professional — but FileZilla works perfectly for student projects.
Should I get a custom domain name for my portfolio?
For maximum portfolio impact, yes. A domain like yourname.dev or yourname.com looks significantly more professional than yourname.infinityfree.net — recruiters notice this. Namecheap offers .com domains for about £8/year and includes free WHOIS privacy. With a paid hosting plan (Hostinger at ~£2/month), you get free domain name included for the first year. This combined investment of under £20/year for a professional portfolio with a custom domain is genuinely worth it when you are actively applying for jobs.
Secure your project before making it public
Optimise your development environment first
Back up your project to GitHub before deploying
Get a project ready to deploy with this guide
Last updated April 2026. InfinityFree hosting details verified April 2026. FileZilla 3.67 used for screenshots. Database migration steps tested on InfinityFree + phpMyAdmin.


