Laravel is a free, open-source PHP web application framework. It provides an expressive, elegant syntax and is used for the development of web applications following the model–view–controller (MVC) architectural pattern. Developers believe development must be an enjoyable, creative experience to be truly fulfilling. Laravel attempts to take the pain out of development by easing common tasks used in the majority of web projects, such as authentication, routing, sessions, queueing, and caching. Laravel is accessible, yet powerful, providing powerful tools needed for large, robust applications.
As of March 2015, Laravel is regarded as one of the most popular PHP frameworks, together with Symfony2, Nette, CodeIgniter, Yii2 and other frameworks. Documentation for the framework can be found on the Laravel website. You are able to choose two different variants of Laravel installation – automatic via the Softaculous installer and manual.
Laravel automatic installation via the Softaculous script installer
First of all, you need to log into your cPanel account and find Softaculous menu in Software and Services section:
Once done, you will be redirected to Softaculous main page. Type Laravel in the search bar and click on the result:
Move to Install tab, there you will be prompted to choose the folder where Laravel will be installed. Feel free to choose the one you need (note that this directory will be created by Softaculous):
Laravel manual installation
Other software which should be installed in order to set up Laravel is Composer. It is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on, and it will manage (install/update) them for you. Composer is not a package manager in the same sense as Yum or Apt are. Yes, it deals with 'packages' or libraries, but it manages them on a per-project basis, installing them in a directory (e.g., vendor) inside your project. By default, it will never install anything globally. Thus, it is a dependency manager.
1) Please make sure you have SSH access on your hosting package. If you do not have access to SSH, kindly open a support ticket in order for us to enable for you. (Please note that not all shared hosting package has SSH access).
2) Laravel and Composer requirePHP 5.5 version, so we need to check whether the needed version is set up. Type the php -v command in PuTTY (or in Terminal) and you will get the following output:
3) If it is not PHP5.5 and above, please use this tutorial to change your PHP version: http://secure.web-hosting.net.my/clients/knowledgebase/201/how-to-modify-php-value-in-cpanel.html
4) Now you need to decide where you wish to put your Laravel For example, we will createlaravel_folder in public_html using the following command:
cd public_html && mkdir laravel_folder && cd laravel_folder
This line can be divided into three separate commands:
cd public_html: navigation to the public_html folder, since after logging in you will be located in the /home/username/ folder by default
mkdir laravel_folder: mkdir command will create of a new folder named laravel_folder, you can replace laravel_folder with any desired name
cd laravel_folder: navigation to the newly created laravel_folder
&&: used for combination of several different commands.
5) Then you need to copyini file from the default location on the server to your laravel_folder using this command:
cp /opt/alt/php56/etc/php.ini /home/username/public_html/laravel_folder
cp: this command is used to copy the php.ini file to the folder you wish to use with Laravel.
NOTE 1: make sure that you replace username with your actual cPanel username
NOTE 2: in case you need php.ini for any other PHP version, just change php56 to php55 or to any other value corresponding to the current version.
6) Now you will need to find php.ini file in current location. Log intocPanel and navigate File Manager menu:
Move to the folder you have chosen for Laravel and open php.ini with Editor:
Then add the following block to the end of the file and hit Save button:
max_execution_time = 300
max_input_time = 300
memory_limit = 512M
executor.include.whitelist = phar
detect_unicode = Off
7) When all the preparations are done, you are ready to install Composer and then Laravel. Open PuTTY window where you have logged into your cPanel account and fill in the following command:
php -r "readfile('https://getcomposer.org/installer');" | php -c php.ini
This will execute the Composer installation:
In case you get a notification Some settings on your machine make Composer unable to work properly, make sure that the PHP version is 5.5 or higher and all the changes in the php.ini file are saved.
8) Now you are ready to install Laravel. Execute the command provided below:
php -c php.ini /home/username/public_html/directory/composer.phar create-project laravel/laravel --prefer-dist
NOTE: make sure that you replace the default details with the actual ones – username should be replaced with your cPanel username, directory should be replaced with the name of the folder you installed Composer to.
You will see the output like it is shown in the screenshot which means that some dependencies are installing:
Once the installation is successfully completed, you will get this output:
By default, Laravel installation will be installed in laravel folder in the same directory chosen for Composer installation.