X

Laravel Installation Guide For CentOS

How to install Laravel on CentOS

One of the most popular frameworks of PHP is Laravel. The use of this framework is increasing day by day. Website development becomes easier by using this framework. It is open-source software. So anyone can install and use this software without any cost. This framework supports most of the well-known operating system such as Windows, Linux etc. It also supports maximum popular relational database such as MySQL, SQL Server, PostgreSQL etc. This is a guide on how the framework can be downloaded and installed on CentOS step by step.

Requirements:

Before starting the steps of this tutorial you require Apache and PHP to be installed on your system. So, you must install these packages and check these are working properly. You must have root privileges also to complete this tutorial.

Laravel Installation:

You need to follow the following steps to start the installation process the installation on CentOS.
Update the system
You have to make the system update-to-date to install any software. Run the following command to update the system.
$ sudo yum -y update

Check the apache server is enable and working. Run the following commands to start apache server.
$ sudo systemctl start httpd

Run the following commands to allow HTTP and HTTPS ports:

$ sudo firewall-cmd --permanent –add-port=80/tcp
$ sudo firewall-cmd --permanent –add-port=443/tcp

Check PHP is installed and working. Run the following command to check the installed PHP version. Here, PHP version 7.3.2 used. You can use PHP 7+ any version to complete the installation.

$ php -v

Some PHP extensions are required to install Laravel. Run the following command to install necessary PHP extensions.

$ sudo yum install php-common php-gd php-phar php-xml php-cli php-mbstring php-openssl php-mcrypt php-pdo php-mysql

PHP dependency manager, Composer is a very useful tool for installing any PHP package. It is used to install Laravel. The composer will be downloaded in this step. Run the following command to download the Composer installer for PHP.

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

The composer will be installed in the required folder in this step. Run the following command to install Composer in the /usr/local/bin folder.
$ sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

Check the composer is installed properly by running the following command.

$ php /usr/local/bin/composer

If all the previous steps completed successfully then you can start the step for installing the latest version of Laravel. Run the command to download and install Laravel directly into apache document folder under laravel. It will require some time to complete the process.

$ php /usr/local/bin/composer create-project laravel/laravel /var/www/html/laravel

After completing the installation, if the following success information appears at the ending then Laravel is installed successfully in the system.

Run the following commands to set the required permissions for the necessary folders.
$ sudo chown -R apache:apache /var/www/html/laravel
$ sudo chmod -R 755 /var/www/html/laravel/storage

Restart the apache
$ sudo systemctl restart httpd

You can run your application directly from a web server but Laravel has own development server also. To start it, proceed to the project folder and start the application development server.

$ cd /var/www/html/laravel
Run the following command to start Laravel Development server. If the following message appears like the following image then Laravel development server is working.

$ cd /var/www/html/laravel
$ php artisan server

Open any browser and type the following URL to check the installation is working properly.
http://localhost:8000
If the following screen appears then you have succeeded in your installation

Conclusion

After downloading and installing Laravel, many types of deprecated errors may appear based on PHP and Laravel version. After solving these problems, you can use this framework for developing any web application. We hope the reader will be able to install Laravel on CentOS by following the steps of this tutorial. Once you have completed the installation you can learn all of the features in the framework by reading further the documentation and start using them!

LinuxAdmin.io
0 0 votes
Article Rating
LinuxAdmin.io:
Related Post