Laravel is one of the most popular PHP frameworks for building modern web applications. This guide explains how to install Laravel on a Mybox hosting account using SSH and Composer.
Table of Contents
Prerequisites
Before installing Laravel, make sure that:
- SSH access is enabled for your hosting account.
- A website has been created in the Mybox control panel.
- PHP 8.2 or newer is selected for the website.
- You have basic familiarity with SSH commands.
Connecting via SSH
Enable SSH access for your hosting account if it is not already enabled.
Then connect to your account using:
- PuTTY on Windows
- Terminal on macOS
- Terminal on Linux
Installation
Step 1 – Create an Empty Website
In the Mybox control panel:
- Navigate to Websites.
- Click Add Website.
- Select Blank Website.
- Choose PHP 8.2 (or newer).
- Complete the website creation process.
Step 2 – Remove the Default Document Root
After connecting via SSH, enter your website directory:
cd yourdomain.com
Remove the default document root:
rm -rf public_html
Step 3 – Download Composer
Download the desired Composer version.
Example:
wget https://getcomposer.org/download/2.8.8/composer.phar
You can replace the version number with the latest stable release if desired.
Step 4 – Create a Laravel Project
Create a new Laravel application.
Example:
php82 composer.phar create-project --prefer-dist laravel/laravel project_name
Replace:
project_name
with your preferred application directory name.
Step 5 – Optimize the Laravel Installation
Run the following commands:
php82 -c /usr/local/php/php.ini project_name/artisan clear-compiled
php82 -c /usr/local/php/php.ini project_name/artisan optimize
php82 -c /usr/local/php/php.ini project_name/artisan key:generate
These commands:
- Clear cached compiled files
- Optimize the framework
- Generate the application encryption key
Step 6 – Create a Symbolic Link
Laravel stores publicly accessible files inside the public directory.
Since the web server expects website files inside public_html, create a symbolic link:
ln -s project_name/public public_html
Replace:
project_name
with your Laravel project directory name.
Verifying the Installation
Open your website in a web browser.
If the installation was successful, you should see Laravel’s default welcome page.
Updating Laravel Permissions (Optional)
If your application requires write access to storage and cache directories, make sure the following directories are writable:
storage
bootstrap/cache
Laravel uses these directories for:
- Cache files
- Sessions
- Logs
- Temporary application data
Useful Artisan Commands
Clear application cache:
php82 project_name/artisan cache:clear
Clear configuration cache:
php82 project_name/artisan config:clear
Clear route cache:
php82 project_name/artisan route:clear
Run database migrations:
php82 project_name/artisan migrate
Summary
To install Laravel on Mybox:
- Create a blank website with PHP 8.2 or newer.
- Connect via SSH.
- Remove the default
public_htmldirectory. - Download Composer.
- Create a new Laravel project.
- Run the Laravel optimization commands.
- Create a symbolic link from
public_htmlto Laravel’spublicdirectory.
After completing these steps, your Laravel application should be available under your domain and ready for development.