Deploy Yii Framework Application to InfinityFree Using GitHub Actions and FTP

Oct 16, 2026
By Admin
4 min read
48 views
Deploy Yii Framework Application to InfinityFree Using GitHub Actions and FTP

Deploy Yii Framework Application to InfinityFree Using GitHub Actions and FTP

This guide walks you through deploying a Yii2 Framework app to InfinityFree using GitHub Actions and FTP. You'll prepare the project locally, configure GitHub secrets, and deploy automatically through push or manual trigger.


Prerequisites

  • Yii2 Basic Template (or Advanced) installed locally
  • PHP, Composer, Git
  • A GitHub account and repository
  • An InfinityFree account
  • FTP login credentials
  • Optional: a MySQL database if your app uses one

1. Install Yii2 Locally

Install the Yii2 basic app:

composer create-project yiisoft/yii2-app-basic yii2-app
cd yii2-app
php yii serve

Visit http://localhost:8080 to verify the app runs.


2. Configure the .env File or db.php

If no database is needed:

  • You can comment or remove the 'db' component in config/web.php
  • Or make config/db.php return an empty array:
return [];

If using a MySQL database:

  1. In InfinityFree, go to MySQL Databases
  2. Create a new database
  3. Take note of:
  1. Update config/db.php:
return [
    'class' => 'yii\db\Connection',
    'dsn' => 'mysql:host=sqlXXX.epizy.com;dbname=epiz_12345678_dbname',
    'username' => 'epiz_12345678',
    'password' => 'your_db_password',
    'charset' => 'utf8',
];
  1. Export your local DB and import it using phpMyAdmin > Import in InfinityFree.

3. Add a Root .htaccess Redirect

Since Yii2 places its frontend in the web/ directory, add this .htaccess in the project root (not inside web/):

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ web/$1 [L]
</IfModule>

4. Comment All .gitignore Rules

By default, vendor/, runtime/, .env, and other essential folders are ignored. Since InfinityFree doesn’t support Composer or CLI, you must upload everything.

Instructions:

  1. Locate all .gitignore files in your project
  2. Comment out all rules by adding # before each line:
# /vendor
# /runtime
# /.env
# /web/assets
  1. Save the files

This ensures the entire Yii2 project is included in the deployment.


5. Add Your Domain on InfinityFree

InfinityFree allows 3 main accounts and unlimited custom domains. Here's how the structure works:

  • The default domain (created when opening the account) uses the main /htdocs/ directory
  • Any addon domain gets its own directory named after the domain — with its own htdocs/ inside (e.g., /yourdomain.com/htdocs/)

Example:

Recommendation:

Before setting up deployment, add the domain in InfinityFree to ensure the path exists.


6. Add GitHub Secrets (Before Pushing)

In your GitHub repo:

  1. Go to Settings > Secrets and Variables > Actions
  2. Add these two repository secrets:
FTP_USERNAME = epiz_12345678
FTP_PASSWORD = your_ftp_password

These will be used by the workflow for authentication.


7. Create the GitHub Actions Workflow

Before pushing the code, create a workflow file at:

mkdir -p .github/workflows
nano .github/workflows/infinityfree-deploy.yml

Paste this:

name: Deploy to InfinityFree

on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  deploy:
    name: Deploy Yii2 App
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Repository
        uses: actions/checkout@v4

      - name: Upload via FTP
        uses: SamKirkland/[email protected]
        with:
          server: ftpupload.net
          username: ${{ secrets.FTP_USERNAME }}
          password: ${{ secrets.FTP_PASSWORD }}
          server-dir: /yourdomain.com/htdocs/  # Use /htdocs/ for default domain
          timeout: 86400000
          log-level: standard

⚠️ Replace /yourdomain.com/htdocs/ with /htdocs/ if deploying to the main/default domain.


8. Initialize Git and Commit the Project

Set up Git and prepare your first commit:

git init
git add .
git commit -m "Initial Yii2 project with InfinityFree deployment"

9. Push to GitHub

Add your remote and push:

git remote add origin https://github.com/your-username/your-repo.git
git branch -M main
git push -u origin main

If everything is set, the deployment will start automatically based on the push event.


10. Trigger the Deployment (Optional)

If you configured workflow_dispatch, you can also deploy manually:

  1. Go to the Actions tab in your GitHub repo
  2. Select the deployment workflow
  3. Click Run workflow

This is useful for re-deploying without making a new commit.


Deployment Notes

  • Max file size is ~1MB — avoid uploading large libraries or assets
  • Make sure vendor/, runtime/, web/assets/, and configs are included
  • Upload may take a few minutes to hours depending on project size
  • If no database is used, make sure session is configured to use file:
'session' => [
    'class' => 'yii\web\Session',
],

Summary

Step Action
Yii2 app installed locally ✅
DB configuration or disabling done ✅
Root .htaccess added ✅
All .gitignore rules commented out ✅
Domain added and structure verified ✅
GitHub secrets set before push ✅
Workflow created pre-push ✅
Project committed and pushed ✅
Deployment triggered (automatically or manually) ✅
Share this article:
Back to Blog

More Engineering Articles

View All

Ready to Engineer Scalable Systems for Your Enterprise?

Our engineering team builds custom ERPs, ISP billing platforms, fintech automation, and cloud architectures tailored to your business.

Get in Touch