Install the Laravel PHP Framework on Ubuntu 16.04
Table of Contents
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.
- A 1&1 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.
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.
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. To use Laravel on a CentOS 7 server, follow the steps in our article to Upgrade PHP From 5.4 to 7.0 on a CentOS 7 1&1 Cloud Server.
Install Laravel's PHP dependencies with the command:
sudo apt-get install php7.0-zip php-mbstring php-xml
Enable the Apache module
sudo a2enmod rewrite
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:
.profile file for editing:
Find the following lines:
# set PATH so it includes user's private bin directories PATH="$HOME/bin:$HOME/.local/bin:$PATH"
$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:
You can now use the
laravel command to create a new project:
laravel new my-project
Tags: Laravel / PHP