DEV Community

Chimaobi Prince
Chimaobi Prince

Posted on

How to deploy a PHP application in InfinityFree

Step 1: Account Setup
Sign up and verify: Create an account on the InfinityFree website and verify your email address.
Create a Hosting Account: Once signed in, navigate to the client area and click "Create Account".
Choose a Domain: Select a free subdomain or use a custom domain, then click "Create Account".
Finish Setup: After the account is created, click "Finish". Note down your account details, including the username, password, and MySQL details, as you will need them later.

Step 2: Upload Project Files
Access Control Panel: From your client area, click "Control Panel" (cPanel). You may need to click "I Approve" to proceed.

Open File Manager: In the cPanel, find and click "Open File Manager".
Navigate to htdocs: Inside the file manager, open the htdocs folder. This is the root directory for your website's public files.
Upload Files:
Delete any default files present in the htdocs folder.
Click the "Upload" button. You can upload individual files or a ZIP archive of your entire project. Uploading a ZIP file and extracting it on the server is often easier for large projects.

*Step 3: Set up the Database *
If your project uses a MySQL database, follow these steps:
Go to cPanel: Return to the cPanel and find the "Databases" section.
Create Database: Click on "MySQL Databases". Give your new database a name (e.g., demo) and click "Create Database".
Access phpMyAdmin: Click the "Admin" button next to your new database. This opens phpMyAdmin.

Import Database: In phpMyAdmin, go to the "Import" tab. Click "Choose File", select your local .sql database file, and click "Go" to upload it.

Step 4: Configure Your PHP Project
Edit Configuration File: In the File Manager, locate your database configuration file (e.g., config.php, db.php, or similar). Open it for editing.
Update Credentials: Change the localhost database credentials to the new InfinityFree credentials. You can find the required details (DB Hostname, DB Name, DB Username, DB Password) in your client area under "MySQL Details":
DB Server (Hostname): This will be a specific hostname, not localhost.
DB Username: A unique username generated by InfinityFree.
DB Password: The password you set for the hosting account (or database password if you set one separately).
DB Name: The name you provided when creating the database in cPanel.
Save Changes: Save and close the configuration file.
Your PHP project should now be deployed and accessible via the domain name you selected in Step 1. You may need to clear your browser cache to see the changes.

Top comments (2)

Collapse
 
hdanishnaseer profile image
Danish

This is a helpful breakdown for anyone deploying PHP apps on free hosting, especially since database setup can get confusing for beginners. Once projects grow, shifting to a managed host like Cloudways makes things a lot easier because the server setup and deployment steps are much smoother.

Collapse
 
royadeveloper01 profile image
Chimaobi Prince

I called it "Free Hosting Made Easy", haha.