Install the Laravel PHP Framework on Ubuntu 16.04

PHP frameworks make web application development easier by providing an extensive collection of libraries and components. The ability to easily use this pre-existing architecture prevents developers from "reinventing the wheel," and increases work efficiency. Learn how to install and use the Laravel PHP framework, which is one of the most popular and widely-used frameworks available.

Requirements

  • A Cloud Server with Ubuntu 16.04.
  • PHP installed and running, version 7.0 or later.
  • PHP Composer package management system installed. See our article "Install and use PHP Composer on Ubuntu 16.04" for step-by-step instructions to install Composer.

Free Cloud Server Trial from IONOS

Try out a Cloud Server for free now - test your IONOS Cloud Server for 30 days!

REST API
Unlimited traffic
VMware virtualization

Use the command php -v to check your PHP version:

user@localhost:~# php -v
PHP 7.0.22-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
with Zend OPcache v7.0.22-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies

In this example, the server is running PHP version 7.0.22.

Note
  • PHP is installed and running on a Standard Linux installation by default. If your server was created with a Minimal installation, you will need to install and configure PHP before you proceed.

  • Laravel requires PHP version 7.0 or better.

Install Laravel

Install Laravel's PHP dependencies with the command:

sudo apt-get install php7.0-zip php-mbstring php-xml

Enable the Apache module mod_rewrite:

sudo a2enmod rewrite

Restart Apache:

sudo service apache2 restart

Use Composer to download the Laravel installer:

composer global require "laravel/installer"
Note

Because Composer is never run as root, it is not necessary to use sudo for Composer commands.

Update Your PATH

You will want to update the PATH for your Composer user so that you can use the laravel command. To do this, go to your user's home directory:

cd ~/

Open the .profile file for editing:

nano .profile

Find the following lines:

# set PATH so it includes user's private bin directories
PATH="$HOME/bin:$HOME/.local/bin:$PATH"

Add $HOME/.composer/vendor/bin: to the second line so that it reads:

# set PATH so it includes user's private bin directories
PATH="$HOME/.composer/vendor/bin:$HOME/bin:$HOME/.local/bin:$PATH"

Save and exit the file. Then use source to update the PATH information:

source .profile

You can now use the laravel command to create a new project:

laravel new my-project

SSL certificates from IONOS

Protect your domain and gain visitors' trust with an SSL-encrypted website!

Easy activation
Proven safety
24/7 assistance
Free SSL check