DEV Community

pcreem
pcreem

Posted on • Updated on

Install Laravel on Ubuntu

install php

$sudo apt install zip unzip software-properties-common
$sudo add-apt-repository ppa:ondrej/php
$sudo apt install -y php8.0 php8.0-gd php8.0-mbstring php8.0-xml php-zip
Enter fullscreen mode Exit fullscreen mode

Apache2

$sudo apt install apache2 libapache2-mod-php8.0
Enter fullscreen mode Exit fullscreen mode

MySQL

$sudo apt install mysql-server php8.0-mysql
Enter fullscreen mode Exit fullscreen mode

(optional) Upgrade composer 2.0

$sudo apt install curl
$curl -sS https://getcomposer.org/installer -o composer-setup.php
$sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Enter fullscreen mode Exit fullscreen mode

Laravel installer

$composer global require laravel/installer
Enter fullscreen mode Exit fullscreen mode

Edit Laravel path

$cd~
$nano .bashrc
Enter fullscreen mode Exit fullscreen mode

add export PATH=$PATH:$HOME/.config/composer/vendor/bin to last line

$source ~/.bashrc
Enter fullscreen mode Exit fullscreen mode

create & run project

$laravel new {project name}
$php artisan serve
Enter fullscreen mode Exit fullscreen mode

open http://127.0.0.1:8000 on browser

(optional) VScode

$sudo snap install --classic code
Enter fullscreen mode Exit fullscreen mode

Top comments (0)