Install Laravel with Nginx and PHP-FPM

Install Laravel

Nginx with PHP-FPM is currently the preferred way to run PHP applications on your server. In this post, I will show you how to install Laravel on your server and run it on top of Nginx serving PHP files using PHP-FPM. We will also make use of composer as the preferred way to install Laravel.

Install Laravel using Composer

Make sure you have composer installed on your system. If not you can get it here. I would suggest you install composer globally. Once composer is installed and verified, you should setup the laravel installer using:

This will create a new laravel folder and pull in all the files required for laravel development.

Install Nginx and PHP-FPM

This should be straightforward. In Linux based systems, you can use your package manager to install nginx and php-fpm. I use Arch Linux, so on my system the following command is all that is needed:

On Windows based systems, I recommend you use something like wnmp in order to make the installation process painless. You can download it from here.

Next, you have to edit your nginx.conf file in order to configure Nginx to use PHP-FPM.

The root, access_log and error_log must be set to the relevant project folders. The main section from above that configures Nginx to pass PHP files to PHP-FPM for processing is:

This assumes that the PHP-FPM service is running on port 9000. After this, you can add the following line to your hosts file.

Then you should be able to access your new laravel installation via browser by pointing it to:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.