Knowledgebase

How to Move a Laravel / PHP Application to Nairahost Print

  • php app hosting, laravel migration, beginner, composer, environment variables, deployment
  • 0

How to Move a Laravel / PHP Application to Nairahost

A simplified but complete deployment guide for non-DevOps users

Tags: laravel, php app, migration, composer, environment variables, deployment

Introduction

Laravel and modern PHP apps are built differently from basic WordPress sites. They have environment variables, storage directories, routing files, and dependencies. Deploying these apps requires attention to folder structure and configuration.

???? This guide explains the simplest possible way to deploy a Laravel or PHP application on Nairahost shared or reseller hosting — no SSH required.

Requirements

  • Your full Laravel project or PHP application folder
  • Nairahost hosting with PHP 8.x support
  • Database credentials
  • .env file

Step 1: Arrange File Structure for Shared Hosting

Laravel’s default structure assumes you have access to the root filesystem. Shared hosting works differently.

The public folder must become your document root.

Correct Deployment Structure:


/home/username/
    laravel_app/
    public_html/  <-- contents of public folder go here
    

Meaning:

  • Upload ALL Laravel files OUTSIDE public_html
  • Only upload the contents of public/ into public_html
⚠️ Never put your entire Laravel framework inside public_html — you will expose sensitive files!

Step 2: Upload Files

Using File Manager in cPanel:

  1. Create folder laravel in home directory
  2. Upload ZIP containing app & extract
  3. Move public/* into public_html/

Step 3: Configure .env Values

Edit /laravel/.env


APP_URL=https://yourdomain.com
APP_ENV=production
APP_DEBUG=false

DB_HOST=localhost
DB_DATABASE=mydb
DB_USERNAME=myuser
DB_PASSWORD=mypass
    

Update mail settings if using SMTP.

Step 4: Create & Import Database

  1. Open MySQL Databases in cPanel
  2. Create DB + user + password
  3. Import SQL via phpMyAdmin

Step 5: Fix Storage Directory Permissions

If your app stores uploads, run:

chmod -R 775 storage bootstrap/cache

If no SSH access, use File Manager → "Change Permissions"

Step 6: Set Correct Document Root

Check that public_html/index.php contains the right path:


require __DIR__.'/../laravel/vendor/autoload.php';
$app = require_once __DIR__.'/../laravel/bootstrap/app.php';
    

Step 7: Run Composer (Optional)

If your app needs vendor packages:

  • Upload /vendor from dev environment
  • OR request support to run composer for you

Common Laravel Hosting Issues

  • 500 error → wrong public folder location
  • Class not found → vendor missing
  • Database error → wrong DB credentials in .env
  • Storage not writing → permissions wrong

Laravel is more advanced than basic PHP or WordPress, but once you understand the correct directory structure and deployment steps, you can run full Laravel apps on Nairahost easily — even on shared hosting.


Was this answer helpful?
« Back
Loading indicator for Nairahost web hosting services
WhatsApp chat support for Nairahost web hosting Nigeria Chat with us