How to Install Laravel on aaPanel for Developers

How to Install Laravel on aaPanel for Developers

Bitnesia Development Mar 28, 2026 333 ID

For developers, managing a VPS can be challenging when every small task requires manual configuration via the command line (CLI). This is where aaPanel comes in as a solution. aaPanel is a lightweight, user-friendly, and free control panel for managing Linux servers. When combined with Laravel, the most popular PHP framework today, developers gain a productive, secure, and easy-to-manage development environment.

Here is a step-by-step tutorial on how to install and configure Laravel on aaPanel.

Prerequisites

Before getting started, ensure you have prepared the following:

  • VPS (Virtual Private Server):
    • Minimum recommended: 1 CPU and 2 GB RAM.
    • Operating System: Ubuntu 22.04 LTS (recommended).
  • aaPanel Installed: The panel is already installed and accessible on your server.
  • Domain: A domain with an A Record pointing to your VPS IP address.
  • SSH Access: Root access to the server for command execution.

Installing aaPanel

If aaPanel is not yet installed, run the following command via SSH to begin installation:

URL=https://www.aapanel.com/script/install_panel_en.sh && if [ -f /usr/bin/curl ];then curl -ksSO $URL ;else wget --no-check-certificate -O install_panel_en.sh $URL;fi;bash install_panel_en.sh ipssl

1. Installing the LEMP Stack

The first step is to set up the LEMP Stack (Nginx, MariaDB/MySQL, PHP) via aaPanel:

  1. Log in to your aaPanel dashboard.
  2. Navigate to the AppStore menu in the left sidebar.
  3. Search for and install the following packages (select versions as needed):
    • Nginx: Recommended for optimal performance.
    • PHP: Choose a version compatible with Laravel (PHP 8.3 recommended).
    • After installation, click Settings for PHP and ensure the following extensions are enabled: fileinfo, intl, mbstring, openssl, pdo, zip.
    • Still in the PHP menu, go to the Disable functions tab and remove putenv and proc_open from the list to enable these functions.
    • Database: Choose MySQL 8.4 or MariaDB 10.11.
    • phpMyAdmin: For visual database management.
  4. Ensure all services show a status of Running after installation completes.

2. Creating a Website & Database

aaPanel simplifies website and database creation in a single integrated step:

  1. Go to the Website menu.
  2. Click the Add Site button.
  3. Fill in the following form:
    • Domain: Enter your domain name (e.g., example.com).
    • SSL: Check Apply for SSL to automatically enable HTTPS.
    • Database: Select MySQL, then specify the database name, username, and password. Save these credentials!
    • PHP Version: Select PHP 8.3 that was installed earlier.
    • Site Directory: Leave as default (typically /www/wwwroot/example.com).
  4. Click Submit to complete site creation.

3. Installing Laravel via SSH

First, install Composer if it is not already available on your server:

wget https://getcomposer.org/download/latest-stable/composer.phar -O /usr/local/bin/composer
chmod +x /usr/local/bin/composer

Next, download the Laravel source code into the website directory you just created:

Navigate to the wwwroot directory:

cd /www/wwwroot

Remove the default website directory (if it exists), as Composer will create the Laravel structure from scratch:

rm -rf example.com

Install Laravel using Composer:

composer create-project laravel/laravel example.com
chown -R www:www example.com

Configuring Document Root

  1. Go to Website menu > click Conf for your domain.
  2. Select the Directory tab.
  3. Under Running directory, select /public.
  4. Click Save to apply the changes.

Configuring URL Rewrite

Click the URL Rewrite menu, then add the following configuration to support Laravel routing:

location / {
  try_files $uri $uri/ /index.php?$query_string;
}

4. Environment & Database Configuration

Navigate to your Laravel project directory:

cd /www/wwwroot/example.com

Duplicate the environment template file:

cp .env.example .env

Generate the application key:

php artisan key:generate

Open the .env file for configuration:

nano .env

Locate the DB_CONNECTION section and update it with the database credentials created earlier:

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_database_name
DB_USERNAME=your_database_username
DB_PASSWORD=your_database_password

Run database migrations to verify the connection works:

php artisan migrate

5. Verifying the Installation

Open your browser and visit your domain via HTTPS: https://example.com. If you see the Laravel welcome page, congratulations! The installation was successful.

If you encounter a 500 Internal Server Error, check the following logs for troubleshooting:

  • aaPanel: Menu Website > Settings > Error Log.
  • Laravel: Log file at storage/logs/laravel.log.

Conclusion

Installing Laravel on aaPanel combines the power of a modern framework with the convenience of GUI-based server management. Developers no longer need to wrestle with manual Nginx or PHP-FPM configurations, allowing them to focus more on building application features. After following this guide, you will have a secure, well-structured production environment ready for further development.

Happy coding, and may your project be a success!

I love keeping these tutorials free for everyone. If you've saved time or learned something new today, consider making a small donation to keep this site ad-free.

Support Free Content

Related Posts