How to Install Laravel on CentOS 8?

Laravel is one of the best PHP frameworks available today. Used by thousands of developers worldwide, it has everything you need to create wonderful web applications. So learning how to install Laravel on CentOS 8 is something you should always have on hand since this system is popular among developers.

Laravel is an open-source PHP framework that tries to take advantage of other frameworks and develop with the latest versions of PHP. Its philosophy is to develop PHP code elegantly and simply based on an MVC (Model-View-Controller) model.

With Laravel, we find a framework in constant maintenance and expansion by its developers which ensures the continuity and security of the framework with regular updates.

Also, thanks to extensive and organized documentation will make us much easier and effective work.

Install Laravel on CentOS 8

We are going to install Laravel in developer mode, so for now we don’t care if it’s Apache or Nginx. What we care about is that we have to install PHP and some other modules.

To do this, in a terminal run:

sudo dnf install php php-curl php-bcmath php-dom php-xml php-mbstring php-json php-zip curl zip unzip

Note that in the packages to install, there are also included others necessary to complete the post as curl. Also, I do not include the drivers for MariaDB or PostgreSQL because this will depend on each project and developer.

Now you have to install Composer. Composer is a PHP dependency manager. Thanks to it we will be able to install Laravel and make sure that all its dependencies are fulfilled.

To do this, download it and install it running:

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer

In summary, you download it, generate the program, move it to a location so that it is available as a command and finally assign it execution permissions.

Now with the help of Composer, you perform the installation by running

composer create-project --prefer-dist laravel/laravel [project-name]

Replace [project-name] with the name of your project, for example

composer create-project --prefer-dist laravel/laravel project
Install Laravel on CentOS 8
Install Laravel on CentOS 8

This will create a folder called project that you will have to access to explore it.

cd project/

And to secure the installation you have to generate the key.

php artisan key:generate
Application key set successfully

And to serve the project, you can run

php artisan serve --host=0.0.0.0.0 --port=8000

Finally, open your web browser and go to http:localhost:8000 and you will see this.

Laravel working on CentOS 8
Laravel working on CentOS 8

This indicates that Laravel is installed correctly.

Conclusion

In short, Installing Laravel on CentOS 8 is a simple process that allows a developer to start working smoothly to create PHP web applications on this framework. Thanks to Composer, installing Laravel is easy.

Scroll to Top