How to Install Laravel in cPanel
In this blog, we will show you How to Install Laravel in cPanel. Not only that we will try to solve all your confusion about laravel. Just make sure if you like this blog please share it with others also.
LARAVEL is one such web application framework. It has made it so easy for all the web developers to develop different web applications. Before you proceed you should know what is a framework so check that out below.
What is the framework?
In simple words, web frameworks are a set of components designed to simplify your web development process. It allows you to focus on the more essential details and the project’s goals instead of creating things that you can easily pull out of the framework.
What is LARAVEL?
TAYLOR OTWELL created a web application framework with expressive and elegant syntax, which later came to be known as LAVAREL.
Lavarel is a free, open-source PHP web framework that was intended for the development of web applications following the model-view-controller (MVC) architectural pattern and based on Symfony.
Lavarel takes the pain out of development by easing routine tasks used in many web applications, such as Simple and fast routing engine, powerful dependency injection container, real-time event broadcasting, intuitive database ORM, and many more.
Laravel is powerful and provides tools required for large and robust applications. It is popular amongst all web developers.
Now, there arises a question as to how to download the most popular web-application framework in cPanel. Don’t worry. In this post, I will be showing you the exact steps to do so.
Steps to Install Laravel in cPanel
Before starting to install Laravel, you need to make sure that your server meets some pre-requisites mentioned by Laravel. They are listed below:
- PHP >= 5.6.4
- OpenSSL PHP Extension
- PDO PHP Extension
- Mbstring PHP Extension
- Tokenizer PHP Extension
- XML PHP Extension
- Ctype PHP extension
- JSON PHP extension
- Phar PHP extension
- Mcrypt PHP extension
Now, let’s move on to the installation steps in detail.
1. Log in to Your VPS via SSH
ssh root@my_server
2. Update the System and Install Necessary Packages
yum update
yum install git curl
3. Install the Composer
To install packages, you will need a dependency manager. Composer is a dependency manager that will pull in all the required libraries and dependencies you will need for your project.
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
4. Install Laravel
Here we are installing Laravel by using the composer create-project command.
Switch to the domain root directory:
cd /home/USERNAME/public_html/
and install Laravel using the composer create-project command. (Be sure to use the dot (.) at the end of the command):
composer create-project –prefer-dist laravel/laravel
You will need to set the correct ownership and permissions if you are logged in as a root or another sudo user:
chown -R USERNAME:USERNAME /home/USERNAME/public_html/
Do Not to forget to change the ‘USERNAME’ with the actual name.
5. Configure cPanel
The default web server document root needs to be changed from public_html to public as required by Laravel.
6. Change Document Root for an Add-on domain
Login to your cPanel at: https://YOUR_SERER_IP:2083 and in the ‘Domains’ section click on the ‘Add-on Domains’. In the new window, you will see a list of all your add-on domains, click on the edit icon next to the domain’s document root path and enter the new path, for example, /public_html/laravel-addon-domain.com/public.
7. Change Document Root for a Primary Domain
You need to have SSH root access to your server to change the document root for the main/primary domain.
Open the following file:
nano /var/cpanel/userdata/USERNAME/MY_LARAVEL_DOMAIN.COM
Now change the main root (documentroot) value, you have to add public in the and of the path,
Example: documentroot: /home/USERNAME/public_html/public
You also need to edit the documentroot value, if you have an SSL certificate for your domain, in the following file:
/var/cpanel/userdata/USERNAME/MY_LARAVEL_DOMAIN.COM_SSL
Do not forget to change ‘USERNAME’ with the actual username and MY_LARAVEL_DOMAIN.COM with the actual domain.
Now here you have to save the file and next just rebuild the apache configuration:
/scripts/rebuildhttpdconf && service httpd restart
Boom, You are done, You have successfully installed and configured Laracel on your cPanel. Now if you are seeking for more information about laravel feel free to check out the official Laravel documentation.
Features of Laravel
- Laravel provides a flexible approach to the user to define routes in the web application.
- Laravel provides many built-in libraries that will help you to enhance your web application.
- There are more than 20 libraries and modules available for use.
- A web application designed in Laravel will be running on different environments, which means that there will be a constant change in its configuration.
- With Laravel, you can easily send and receive emails. Also, you can send rich content with the use of its mail class.
Frequently Asked Questions
What is a web framework?
The web application framework is a software framework that is designed to support the development of web applications including web services, web resources, and web APIs.
What is Laravel?
Lavarel is a free, open-source PHP web framework that was intended for the development of web applications following the model-view-controller (MVC) architectural pattern and based on Symfony.
There are more web framework which works faster and efficient for web development
Conclusion
Thus, Laravel proves to be a useful web application framework that a web developer can opt for. It’s amazing features and ease of use attracts many web developers.
All the steps to install Laravel in cPanel are mentioned above. If you have any queries related to the steps comment down below and let me know.