Bobcares

Cyberpanel Laravel | How-to Guide

by | Mar 2, 2024

Learn how to set up Laravel in Cyberpanel. Our Cyberpanel Support team is here to help you with your questions and concerns.

Cyberpanel Laravel

Laravel is a powerful web application framework like Symfony. It offers expressive syntax and follows the model–view–controller (MVC) architectural pattern.

Cyberpanel Laravel

Installation of CyberPanel

First, we have to install CyberPanel on our server. CyberPanel is ideal for Laravel development.

  1. We have to make sure we have a fresh installation of CentOS 7.x.
  2. Then, get the CyberPanel installation package as seen here:

    wget http://cyberpanel.net/install.tar.gz
    tar zxf install.tar.gz
    cd install
    chmod +x install.py
    python install.py [IP Address]

Composer Installation

Composer is a dependency manager for PHP. We can install it as seen here:

  1. Our experts recommend using 7.1, as Symfony 4 needs PHP 7.1 and above. Copy PHP 7.1 binary for global accessibility:

    cp /usr/local/lsws/lsphp71/bin/php /usr/bin/

  2. Then, confirm PHP CLI installation:

    php -v

  3. Next, download and install Composer:

    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
    php composer-setup.php
    php -r "unlink('composer-setup.php');"

  4. Now, move the Composer binary to a global location:

    cp composer.phar /usr/bin/composer

Website Creation in CyberPanel

In CyberPanel, create a website to host our Laravel application:

  1. Access CyberPanel via `[Server IP]:8090`.
  2. Login as admin using the default password (`1234567`).
  3. Head to ‘Create Website’ from the left menu.
  4. Enter domain details, selecting PHP 7.1 for compatibility.
  5. Once the website is created, proceed to the Laravel application setup.

Laravel Project Initialization

Now, head to the website directory and start the Laravel project:

cd /home/example.com/public_html
composer global require "laravel/installer"
composer create-project --prefer-dist laravel/laravel cyber

Here, ‘cyber’ denotes the project name, which can be changed as per our project name.

Laravel Application Key Generation

At this point, generate a unique application key for the Laravel project:

cd public
php artisan key:generate

Directory Permissions Setup

We have to make sure directories are writable for proper functioning:

chmod -R 777 storage
chmod -R 777 bootstrap/cache

Rewrite Rules Configuration

Now, modify the rewrite rules for friendlier URLs:

  1. Access the .htaccess file for our domain via CyberPanel.
  2. Add the following rewrite rules:

    apache
    RewriteEngine On
    RewriteRule . /cyber/public/index.php [L]
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f

    Replace ‘cyber’ with our project name.

  3. Save the changes.

After the above steps, our Laravel application is now operational within CyberPanel. Let us know in the comments if you need further help with the process.

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

In brief, our Support Experts demonstrated how to set up Laravel in Cyberpanel.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.