How to Install Laravel With Nginx on CentOS 8

Install Laravel With Nginx on CentOS 8

In this tutorial we will show you how to install Laravel with nginx on CentOS 8.  For those of you who didn’t know, Laravel is a free, open-source PHP web application framework, created by Taylor Otwell and intended for the development of web applications following the model view controller (MVC) architectural pattern. It is a pretty new framework, but with a big potential to become one of the most popular PHP frameworks.

This article assumes you have at least basic knowledge of linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Laravel PHP Framework with nginx on a CentOS 8 server.

Install Laravel With Nginx on CentOS 8

Step 1. First let’s start by ensuring your system is up-to-date.

Step 2. Install LEMP stack server.

A CentOS 8 LEMP stack server is required. If you do not have LEMP installed, you can follow our guide here.

Step 3. Installing Composer.

The composer is required for installing Laravel dependencies. So use below commands to download and use as a command in our system:

Confirm the installation of Composer using following command:

Step 3. Installing Laravel on CentOS 8.

Install Laravel using following command:

We will need to change some folders permissions:

Step 4. Configuring MariaDB for Laravel.

By default, MariaDB is not hardened. You can secure MariaDB using the mysql_secure_installation script. You should read and below each steps carefully which will set root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB.

Configure it like this:

Next we will need to log in to the MariaDB console and create a database for the Laravel. Run the following command:

This will prompt you for a password, so enter your MariaDB root password and hit Enter. Once you are logged in to your database server you need to create a database for Laravel installation:

Now open .env file and make changes as given below:

Step 5. Configure Nginx For Laravel.

First, create a root directory for your Laravel project by typing following command:

Now go to Nginx configuration directory and create a file for your project configuration:

Add the following lines:

Save and close the file. Restart the Nginx service for the changes to take effects:

Step 6. Configuring Firewall for Laravel.

Create a firewall rule to allow access from external machines to the Laravel:

Step 7. Accessing Laravel.

Laravel PHP Framework will be available on HTTP port 80 by default. Open your favorite browser and navigate to or http://server-ip-addressand complete the required the steps to finish the installation.

Install Laravel With Nginx on CentOS 8

Congratulation’s! You have successfully installed Laravel. Thanks for using this tutorial for installing Laravel PHP Framework on your CentOS 8 system. For additional help or useful information, we recommend you to check the official Laravel website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get a best deal!