How to Install Laravel on CentOS 8

Install Laravel on CentOS 8

In this article, we will have explained the necessary steps to install and configure Laravel on CentOS 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Laravel is a very popular open-source PHP framework with the expressive and elegant syntax used to design modern and beautiful web applications. Laravel aims to take the pain out of web development and make it an enjoyable and creative experience, turning web devs into web artisans.

Install Laravel on CentOS 8

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo dnf clean all
sudo dnf update

Step 2. Install LAMP stack on CentOS server.

It is assumed that you have already installed LAMP stack on CentOS 8. If not, please check out the following tutorial:

Step 3. Installing PHP Composer.

Composer is a dependency manager for PHP. Install composer by typing following command in terminal:

curl -sS | php
mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer

Confirm the installation of Composer by typing following command:


Step 4. Install Laravel on CentOS system.

Install Laravel by running the following command:

cd /var/www
composer create-project laravel/laravel my-Laravel-App

Next, set the 32 bit long random number encryption key, which used by the Illuminate encrypter service:

cd /var/www/myLaravelApp
php artisan key:generate

Step 5. Setup the Laravel Application.

Run the below command from your Laravel application. You can change the host to your LAN IP or localhost to restrict access:

php artisan serve --host --port=8000

Step 6. Configure Apache webserver.

Now we add a Virtual Host in your Apache configuration file to access Laravel framework:

sudo nano /etc/httpd/conf.d/laravel.conf
<VirtualHost *:80>
       DocumentRoot /var/www/myLaravelApp/public

       <Directory /var/www/myLaravelApp>
              AllowOverride All

Next, Restart the Apache service:

sudo systemctl restart httpd.service

Also, set the proper permission for the application files and directories:

chown -R apache.apache /var/www/myLaravelApp
chmod -R 755 /var/www/myLaravelApp
chmod -R 755 /var/www/myLaravelApp/storage

Step 7. Accessing Laravel.

Now visit replacing with your domain name. You should see output like the following:

Install Laravel on CentOS 8

Congratulation, you have learned how to install and configureĀ Laravel on CentOS 8. For further reading on Laravel, please refer to their official knowledge base. If you have any questions, please leave a comment below.