Laravel 101 Installing Laravel On Ubuntu

Laravel 101 Installing Laravel On Ubuntu

  1. Installing Laravel on Ubuntu>
  2. Setting Up Common Header And Footer Template With Laravel.php
  3. Fetching Database Results And Displaying

This simple tutorial covers the installation of Laravel 5 on Ubuntu 14.04. The commands are quite self explatory and show how to get a the basic installation up to the point of displaying the default web page.

# Install composer
curl -sS | php
sudo mv composer.phar /usr/local/bin/composer

# Add `laravel` command via composer
composer global require "laravel/installer=~1.1"
vim /etc/environment
Then add ~/.composer/vendor/bin to the path

At this point there are two options. As the environment file is loaded when X starts, you can either restart X or you can access the laravel command by giving the full path. ~/.composer/vendor/bin/laravel

# Add new Laravel Project via `laravel` command
sudo mkdir /data; sudo chown ubuntu /data; cd /data
laravel new <project-name>

#symlink to /var/www/html
sudo ln -s /data/ /var/www/html/

# fix permissions
sudo chmod -R 777 /var/www/html//storage
sudo chmod -R 777 /var/www/html//vendor

# Point Apache to new project
# Apache config: add a new site or make document root point to `/var/www/html//public`
sudo a2enmod rewrite

# Install Mcrypt
sudo apt-get install -y mcrypt php5-mcrypt
sudo php5enmod mcrypt
sudo service apache2 restart

After installation, the files for the website are located in the /public directory. Here you will find an initial index.php file which can be edited as any index.php file can be.

However, most people will not be sticking with a single index.php file. Many systems will have a page with a header, footer content and other components. Have a look at the next tutorial to see how to accomplish this.