In this tutorial you will learn about the Laravel 8 Install in Ubuntu Example and its application with practical example.
In this article, we will learn how to install Laravel 8 on Ubuntu 16.04 and 18.04. If we want to install laravel framework then are required to have LAMP for our system. First we need to install LAMP in our system. We need to install apache server MySQL and PHP.
Step 1: Install Composer
Step 2: Install Laravel 8
Step 3: Configure Apache2
Step 4: Enable Laravel virtual host site and Apache2 Rewrite Module
Step 5: Restart Apache2 server
Install Composer
Use the following command to download the composer:
1 2 3 |
sudo apt-get update sudo apt-get install curl sudo curl -s https://getcomposer.org/installer | php |
Now we move the composer.phar file into the bin folder and set the permission for all users.
1 2 |
sudo mv composer.phar /usr/local/bin/composer chmod +x /usr/local/bin/composer |
Install Laravel 8
Now this step, I will move on root directory “/var/www/html” and .download and install fresh laravel.
1 2 |
cd /var/www/html composer create-project laravel/laravel blog --prefer-dist "8.*" |
After installing laravel 8, we need to set permission for the new directory.Use the following command to set permission:
1 2 |
sudo chown -R www-data:www-data /var/www/html/blog/ sudo chmod -R 755 /var/www/html/blog/ |
Configure Apache2
Now, we will configure the Apache2 site configuration file for Laravel. Run the below command to create a new configuration file for larvel configuration laravel.conf
1 |
sudo nano /etc/apache2/sites-available/laravel.conf |
After creating configuration file, put the below code in this file and save it.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<VirtualHost *:80> ServerAdmin admin@example.com DocumentRoot /var/www/html/blog/public ServerName example.com <Directory /var/www/html/blog/public> Options +FollowSymlinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> |
Enable Laravel virtual host site and Apache2 Rewrite Module
After configuring Apache2 server, we have to enable laravel virtual host site and Apache2 rewrite module. Use following command to enable it.
1 2 |
sudo a2ensite laravel.conf sudo a2enmod rewrite |
Restart Apache2 server
Now, we need to restart Apache2 server. Use the following command to restart Apache2 server.
1 |
sudo service apache2 restart |
Run Our Laravel Application
Now, open the following Url in the browser to test our example.
1 |
http://example.com |