Introduction
So, you've built your first PHP application—a portfolio site, a small blog, or a project tracker. Now, you want to share it with the world! While paid hosting offers power and flexibility, you can get started absolutely free. This tutorial will guide you through hosting your PHP app on InfinityFree, one of the most popular and reliable free hosting providers, which supports modern PHP versions, MySQL databases, and more.
⚠️ A Word of Caution: Free hosting is perfect for learning, testing, and small personal projects. However, expect limitations like:
* Limited resources: Can lead to slower performance.
* Advertisements: The host may place ads on your site.
* No custom domain: You'll likely get a subdomain (e.g., `yoursite.epizy.com`).
* Strict fair-use policies: High traffic or resource usage can get your site suspended.
For a serious business or production app, consider affordable paid hosting later.
What You'll Need
1. The files for your PHP application (e.g., your `index.php`, folders, etc.).
2. A database export file (`.sql` file) if your app uses MySQL.
3. About 15 minutes of your time.
Step 1: Prepare Your Application for Deployment
Before you upload anything, you need to get your app ready.
* Test Locally: Ensure everything works perfectly on your local machine (using XAMPP, MAMP, or Laragon).
* Handle Configuration: If your app connects to a database, you'll need to update its configuration. Use environment-specific configuration. Often, this means you'll create a `config.php` file that you will update on the server with the new database details you'll get in the next step.
* Local config might connect to `localhost`.
* Server config will connect to the host's database server (e.g., `sqlXXX.epizy.com`).
* Export Your Database: Use phpMyAdmin (or your preferred tool) to export your database as an `.sql` file. Keep this file handy.
Step 2: Sign Up for a Free Hosting Account
1. Go to the [InfinityFree website](httpss://www.infinityfree.com/).
2. Click "Sign Up" or "Create Account".
3. Fill in the required details. You will need to verify your email address.
Step 3: Create Your First Website & Database
1. Log in to your InfinityFree control panel.
2. Create a New Website:
* Look for a button like "Create New Account" or "Add Site".
* Choose a subdomain for your site (e.g., `myawesomeapp.rf.gd`).
* Complete the setup process. Your website space will be created.
3. Set Up Your MySQL Database:
* Back in the control panel, find the "MySQL Databases" section.
* Create a new database. Note down the Database Name.
* Create a user and assign it to the database. Note down the **Username** and **Password**.
* Note the Database Server hostname (it is not `localhost`; it will be something like `sqlXXX.epizy.com`).
Step 4: Upload Your Files and Import Your Database
1. Upload PHP Files via FTP:
* In your control panel, find your FTP login details (server, username, password).
* Use a free FTP client like [FileZilla](httpss://filezilla-project.org/).
* Connect to the server using your credentials.
* Navigate to the `htdocs` or `public_html` folder. This is your website's root directory.
* Upload all your PHP files and folders from your local computer into this directory.
2. Import Your Database:
* Go back to the "MySQL Databases" section in your control panel and click to open phpMyAdmin.
* Log in with the database user you created.
* Select your database from the left sidebar.
* Click the "Import" tab.
* Choose your `.sql` file and click "Go" to import your database structure and data.
Step 5: Update Configuration and Go Live!
This is the most critical step.
1. Find the configuration file you prepared in Step 1 (e.g., `config.php`).
2. Using FileZilla, **edit this file directly on the server (right-click -> "View/Edit"). It will open in your local text editor.
3. Update the database connection variables with the details you noted down in Step 3:
<?php
$servername = "sqlXXX.epizy.com"; // Your database host
$username = "epiz_12345678"; // Your database username
$password = "yourPassword123"; // Your database password
$dbname = "epiz_12345678_db"; // Your database name
?>
4. Save the file. FileZilla will ask if you want to upload the changed file. Confirm "Yes".
5. You're done! Open your web browser and navigate to your free subdomain (e.g., `httpss://myawesomeapp.rf.gd`). Your PHP app should be live!
Troubleshooting Common Issues
* White Screen of Death: Usually a PHP error. Check your error logs in the control panel and ensure your `config.php` paths and credentials are correct.
* "Error Establishing a Database Connection": Double-check your database credentials and hostname in your configuration file.
* Page Not Found (404): Ensure you uploaded your files to the correct `htdocs` folder and that your main file is named `index.php`.
Conclusion & Next Steps
Congratulations! You've successfully hosted your PHP application for free. Use this as your playground.
When you're ready to take the next step, consider migrating to a paid hosting provider or a Platform-as-a-Service (PaaS) like Heroku, DigitalOcean App Platform, or Laravel Forge for a server. They offer better performance, no ads, custom domains (e.g., `yourname.com`), and more reliability for your serious projects.
Now go show off your work to the world