In this 7-step guide, we will show you how to install Laravel on Debian 9. We’ll install Laravel together with PHP-FPM and Nginx. Laravel is a next generation of PHP framework, and it’s the most popular open-source PHP framework lately. It is intended for the modern, rapid development of web applications, following the MVC model. Installing Laravel (The PHP Framework For Web Artisans, its how they called it) on Debian 9 is an easy task and it should take few minutes to finish it. This guide should work on other Linux operating systems, but was written and tested for Debian 9. Let’s get started!
Table of Contents
1. Update the system and install necessary packages
2. Install PHP and required PHP modules
To install the latest stable version of PHP version 7.0 and all necessary modules, run:
3. Install Composer
Composer is a dependency manager for PHP and of course Laravel, which you can install packages with. Composer will pull all the required libraries you need for your project.
4. Install Laravel
Install the latest version of Laravel, using the composer create-project command:
If the installation is successful, you will see the following lines:
5. Server your application with Artisan serve command
Once the installation is completed you can use the artisan serve command to serve your application:
The output should be something like this:
You can now open your browser and access your new Laravel installation at: http://127.0.0.1:8000
6. Install and configure Nginx and PHP FPM
PHP’s built-in server is good for development but for production sites you will need to use a real web server such as Nginx or Apache. In this part of the tutorial, we will show you how to install and configure both, Nginx and PHP FPM to serve your Laravel application.
Run the following command to install both Nginx and PHP-FPM from the official Debian repositories:
Change the ownership of the Laravel directory to the web server user:
Create a new Nginx server block with the following content:
Activate the server block by creating a symbolic link :
7. Test Nginx configuration
Test the Nginx configuration and restart the Nginx service with the following commands:
This was the last step, you have successfully installed Laravel on your Debian 9 VPS. For more information about how to manage your Laravel installation, please refer to the Laravel website.
If you are one of our web hosting customers, and use our optimized Laravel Hosting, you don’t have to install Laravel on Debian 9, our expert Linux admins will setup and optimize your Laravel VPS, for you. They are available 24×7 and will take care of your request immediately. As a Laravel developer, you should be focusing on Laravel development and improving your code and leave the server work to us.
PS. If you liked this post, on how to install Laravel on Debian 9, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.
Thanks for sharing these tips! I am sure your tips really helpful!