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.
Installation of CyberPanel
First, we have to install CyberPanel on our server. CyberPanel is ideal for Laravel development.
- We have to make sure we have a fresh installation of CentOS 7.x.
- 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:
- 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/
- Then, confirm PHP CLI installation:
php -v
- 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');"
- 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:
- Access CyberPanel via `[Server IP]:8090`.
- Login as admin using the default password (`1234567`).
- Head to ‘Create Website’ from the left menu.
- Enter domain details, selecting PHP 7.1 for compatibility.
- 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:
- Access the .htaccess file for our domain via CyberPanel.
- 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.
- 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.
0 Comments