Ubuntu Install Laravel

To install Laravel in Ubuntu 20.04, you’ll first need to install composer. To install composer, execute the commands below.

sudo apt update
sudo apt upgrade -y
sudo apt install composer php-zip php-xml -y
Image for post
Image for post

I assume you had read through my previous stories on how to install Apache and how to install PHP, directory permission should have been configured correctly.

cd /var/www
laravel new blog
sudo chown -R www-data: blog

If you are unable to execute the command “laravel”. Verify if “$HOME/.config/composer/vendor/bin” is in your PATH. To check your PATH, use the command below

echo $PATH

If not found, you can add it in with the command below. After adding it you will need to logout and login again for the PATH to take effect.

echo 'PATH="$HOME/.config/composer/vendor/bin:$PATH"'|tee -a ~/.profile

I’m assuming you do not own a domain yet. We will be editing the default Apache sites enabled config file. Change the DocumentRoot path like the screenshot below

cd /etc/apache2/sites-available
sudo cp 000-default.conf 000-default.conf.bak
sudo vim 000-default.conf
Image for post
Image for post

Reboot Apache after saving the configuration. With your web browser, you should see something similar to the screenshot below.

sudo systemctl restart apache2
Image for post
Image for post

< Back to all the stories I had written

Written by

A software engineer, a rock climbing, diving & rollerblading enthusiast, a husband, a father.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store