We recently talked about CakePHP on CentOS 8. It is a pretty good PHP framework and fast in terms of generating the application as such. However, it is not the only one that exists. We also have Laravel which is another framework more powerful but just as fast to generate functional applications. Well, today you will learn with this post step by step how to install Laravel on CentOS 8. With this combination, you will be able to develop web applications in a comfortable and stable environment.
The team responsible for the development and maintenance of Laravel defines it as the PHP framework for artisans. This is because Laravel respects the clear and legible syntax of the code. In addition to this, it has a huge user community that is constantly checking the source code for errors.
Laravel has grown so much that there is a whole ecosystem of applications and tools to continue taking advantage of the framework. So we are talking about a community PHP framework that behaves professionally.
In the same way, some distinctive elements of Laravel are Blade for creating the templates, Eloquent for integrating the database correctly and Artisan as a command interpreter.
Now let us install Laravel on CentOS 8.
Install Laravel on CentOS 8
While it is true that to start developing in Laravel is not necessary to have a web server running, it is advisable to have it. Because once we have the application ready, we can deploy it locally and know how it really works. Also, if we are going to work with a PHP framework is because we will use database and of course the language as such. So, I recommend you to install LAMP on CentOS 8 first.
Just, install the following PHP extensions:
- BCMath PHP Extension
- Ctype PHP Extension
- JSON PHP Extension
- Mbstring PHP Extension
- OpenSSL PHP Extension
- PDO PHP Extension
- Tokenizer PHP Extension
- XML PHP Extension
Then, you have to continue with the rest of the steps.
Install composer on Linux
Similar to CakePHP, the fastest and most direct way to install Laravel is through Composer. Then, you have to install Composer. For this, we have a very detailed tutorial where we explain the process.
With composer running, it is time to install Composer on CentOS 8.
Install Laravel on CentOS 8
Now we can install Laravel, for that, we will use
:~$ composer create-project --prefer-dist laravel/laravel example
You can change example by the name of your project.
To check the progress of your project you can use it. To do this, use the following command:
:~$ cd example :~$ php artisan serve
This will make your project available at
http://localhost:8000 but you can modify the command to specify the host and port. Remember that the port must be open in the firewall. Suppose we continue with port 8000 but with another host.
:~# firewall-cmd --add-port=8000/tcp --permanent --zone=public success :~# firewall-cmd --reload success
Again, serve the project.
:~$ php artisan serve --host=192.168.250.13 --port=8000
Next, open your web browser and go to your host. You will see the following:
And that is it.
With Laravel you can make web applications in an elegant way with a clean and legible source code. In this sense, the ecosystem surrounding Laravel is something more complex and robust than other frameworks such as CakePHP. And as you’ve learned today, installing it on CentOS 8 is not something that should scare us.
Please share this post with your friends and join our Telegram channel.