Installing Laravel and Composer on the cPanel server

Installing Laravel and Composer on the cPanel server

Laravel is a free and open source PHP framework for developing web applications. Some of the features of Laravel are a modular packaging system with a dedicated dependency manager, different methods for accessing relational databases. Laravel, along with Symfony2, Nette, CodeIgniter, Yii2, etc., is known as one of the most popular PHP frameworks. Laravel tries to make things easier by reducing common tasks used in most web projects, such as authentication, routing, sessions, queuing and caching. Laravel provides the powerful tools needed for large and robust applications. It supports multiple platforms and allows users to develop MVC web applications.

Server requirements

The Laravel framework has several system items. You need to make sure that your server meets the following conditions:

1
2
3
4
5
6
7
8
9
PHP >= 5.6.4
OpenSSL PHP Extension
PDO PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
XML PHP Extension
Automatic installation of Laravel via Softaculous installation script

Laravel can be installed automatically on cPanel server using Softaculous script installer software. Log in to cPanel and find the Softaculous menu under Software and Services. Once done, you will be redirected to the Softaculous home page. Type Laravel in the search bar and click on the result. Go to the Install tab, where you will be asked to select the folder where Laravel will be installed. Feel free to choose the directory you need (note that this directory will be created by Softaculous). This is the easiest way to install Laravel.

Manual installation of Laravel

Laravel uses Composer to manage its dependencies. Before using Laravel, make sure you have Composer installed on your machine. It is a tool for dependency management in PHP. It allows you to install the libraries your project depends on and manages them for you. Run the following commands to install Composer and SSH on the server.

1
2
cd / bin
wget https://getcomposer.org/installer

Before installing, let’s check your compatibility using the command below.

1
2
php installer –check
All settings correct for using Composer

If everything looks good, let’s install Composer.

1
2
3
4
php installer
Downloading…
Composer successfully installed to: /bin/composer.phar
Use it: php composer.phar

Now that Composer is installed, we can uninstall the installer.

1
rm -f installer

Now we can use this Composer to install Laravel. Run the following command to install Laravel.

1
php /bin/composer.phar create-project laravel/laravel –prefer-dist

After installing Laravel,

Connect Laravel’s public directory to the public_html folder as a symbolic link like the code below:

1
2
3
rm -rf public_html
ln -s laravel/public/ public_html

After all the installation steps, open the browser and go to the relevant domain. Installation is complete and some configuration settings are required.

Laravel configuration settings

Public Directory

After installing Laravel, you need to configure the document/web root of your web server as a public directory. index.php in this directory is the front controller for all incoming HTTP requests to your application.

Configuration files

All Laravel framework configuration files are stored in the config directory. Each option is documented, so feel free to browse through the files and familiarize yourself with the options available to you.
Directory permissions

After installing Laravel, you may need to configure some permissions. The directories in the cache directory and bootstrap/cache folders must be writable by your web server, otherwise Laravel will not run. If you are using a Homestead virtual machine, these permissions must already be set.

support hosting100