Image

Knowledge base → Installing Laravel 8 on Ubuntu 20.04 (LAMP)

[Virtual servers] [Applications on VPS/VDS]
Date of publication: 09.09.2022

Consider installing Laravel Framework on Ubuntu 20.04 with LAMP preinstalled. Similarly, you can add multiple sites to one server. The guide will also be relevant for transferring sites, for example, from shared hosting to a VPS server.

We make all settings from the root user, if you are using a regular user, add before the command sudo.

1. Install the necessary php modules and download the latest version of Laravel

apt update && sudo apt upgrade
apt install php php-common libapache2-mod-php php-cli php-fpm php-mysql php-json php-opcache php-gmp php-curl php-intl php-mbstring php-xmlrpc php-gd php-xml php-zip
apt install curl
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
chmod +x /usr/local/bin/composer
cd /var/www/
composer create-project laravel/laravel laravelapp
cd laravelapp
php artisan

(Let's check the version, in our case Laravel Framework 8.83.19 i.e. installation is complete)


2. Let's create a database

mariadb -u root

CREATE DATABASE laravel_db; CREATE USER 'laravel_user'@'localhost' IDENTIFIED BY 'your_password'; GRANT ALL ON laravel_db.* TO 'laravel_user'@'localhost'; FLUSH PRIVILEGES; EXIT;


3. Web service setup

Assign rights and create a configuration file for our domain:

chown -R www-data:www-data /var/www/laravelapp
chmod -R 775 /var/www/laravelapp/storage

Let's create a new file:

nano /etc/apache2/sites-available/laravel.conf

ServerName domain.tld ServerAdmin admin@domain.tld DocumentRoot /var/www/laravelapp/public

AllowOverride All

ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined

apache2ctl configtest
a2ensite laravel.conf
systemctl reload apache2

Change domain.tld to your already configured in the DNS editor to the ip address of the VPS server. Thus, you can add several sites by analogy. Go to the browser on the configured domain http://domain.tld/.

Installation completed.





No Comments Yet