Logo
  • PHP
    • HipHop / HHVM
    • Modern PHP
    • PHPStorm
    • LAMP
    • Laravel
    • Composer
    • PDO
  • JavaScript
    • node.js
    • AngularJS
  • CSS
    • SASS
    • “CSS4” (CSS level 4)
  • HTML
  • Git
  • LAMP
  • Vagrant
  • UI / UX
  • Architecture of …
  • Off-Topic
With ♥ from Berlin
November 12, 2013
Chris
Laravel, Local Development, PHP, Ubuntu
Comments Off on Install Laravel 4 on Ubuntu 12.04 LTS (a how-to tutorial)

Install Laravel 4 on Ubuntu 12.04 LTS (a how-to tutorial)

PreviousNext

Laravel 4 is the big thing. Every blog talks about it, nearly every developer-twitter-account mentions it. Hmm, looks like everybody should try it out ! But – to my surprise – the official installation tutorial is quite confusing and also incomplete. If you install Laravel exactly like described on http://laravel.com/docs/quick#installation, well, then you’ll be stuck right after the first seconds. There’s another, more detailed installation tutorial, right in http://laravel.com/docs/installation, but this will also not clearly help you with the installation process as it simply leaves out essential steps in the setup, and you’ll have to do a lot of additional stuff to get this thing running. That’s probably why you are reading this, right ? ;) So here’s “my” full step-by-step guideline on how to install laravel 4.0 and 4.1 on a naked Ubuntu 12.04 LTS.

 

Preparing the server / environment

Log in into your naked Ubuntu 12.04 LTS and do an update and upgrade:

sudo apt-get update
sudo apt-get upgrade

Choosing the right PHP version: Laravel 4 uses Composer to install. And currently there’s a bug in composer which makes installation of dependencies extremely slow, like 60 minutes for something that usually takes 10 seconds. This bug only happens on PHP 5.3 systems, so installing PHP 5.4 might be a good choice when Composer runs very very slow. Upgrading to PHP 5.5 is (currently, November 2013) not a good choice as this will also install Apache 2.4 which has different config files, and I also don’t know how to rewrite the Apache 2.2 stuff to 2.4.

OPTIONAL: Preparation of installing PHP 5.4: This can be skipped if you are fine with 5.3.

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:ondrej/php5-oldstable
sudo apt-get update
sudo apt-cache policy php5

The last command shows the to-be-installed version of PHP (on the top) . Should be 5.4.x! This process replaces the default PHP version by the chosen one, in this case the “old-stable”, 5.4.

 

Installing Apache, PHP and MySQL

sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install mysql-server
sudo apt-get install php5-mysql

The installation process is self-explaining. You can prove the installed versions of PHP and Apache with:

php -v

and

apache2 -v

 

Installing necessary PHP extensions

sudo apt-get install unzip
sudo apt-get install curl
sudo apt-get install openssl
sudo apt-get install php5-mcrypt

Usually these 4 are not installed by default, but they are necessary to 1.) unzip the .zip’ped Laravel 4 download, 2.) use Composer (which needs CURL), 3.) use Composer (which downloads via HTTPS, useable only with installed OpenSSL) 4.) use Laravel 4 (which needs mcrypt).

 

Install Composer (systemwide)

In case you wonder: The download of Composer into each project “by hand” is not recommended anymore. We use the “real” installation of Composer here:

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

 

Activate mod_rewrite

Install the mod_rewrite module (or extension or whatever it is) and restart the Apache:

sudo a2enmod rewrite
sudo service apache2 restart

Open the default vhost config file:

sudo nano /etc/apache2/sites-available/default

Now search for “AllowOverride None” (which should be there TWO times) and change both to “AllowOverride All“. Search for these two lines

DocumentRoot /var/www
<Directory /var/www>

and change them to

DocumentRoot /var/www/public
<Directory /var/www/public>

This will route a user who enters your server directly to /var/www/public (the base folder of Laravel 4) instead of /var/www. Exit and save with CTRL+X, Y, ENTER.

 

Install Laravel 4

These commands will move you into the web root (/var/www), download Laravel from GitHub, extract the files into a folder called “laravel-master”, move it’s content into /var/www and delete the download and the empty folder:

cd /var/www
wget https://github.com/laravel/laravel/archive/master.zip
unzip master.zip && cd laravel-master/ && mv * ../ && cd ..
rm -r laravel-master && rm master.zip

Run the installation with Composer by

composer install

Note from comments: Eventually you’ll have to do a sudo composer install.

Make the storage folder writeable (777 is too much for production servers, but it’s okay for this tutorial. Would be cool if more experienced linux guys could comment here: What’s the best overall-working way to give PHP write-rights to this folder ?)

sudo chmod -R 777 app/storage

and restart the server:

sudo service apache2 restart

 

First run of Laravel 4

When you navigate to your server’s IP (or domain), you should see the Laravel startscreen:

how to install laravel 4 on ubuntu 12.04 LTS

Now edit app/routes.php and add a new route:

Route::get('/mytest', function()
{
    return "Oh yeah, this really works !";
});

When you navigate to your server’s IP/adress and add “/mytest” to the URL, you should see “Oh yeah, this really works !” in the browser.

http://your-domain-or-ip/mytest

This is basically how laravel works. To get an idea what’s possible with routes, have a look on http://laravel.com/docs/quick ! Feel free to comment, share and rate this tutorial.

 

Related articles across the web

  • Real-time Apps with Laravel 5.1 and Event Broadcasting
  • Laravel 5.1 with LTS is released
  • Reddit.com: Why experienced developers consider Laravel as a poorly designed framework?
  • Running Laravel and angularjs on Docker
  • Use Gulp to Start a Laravel PHP Server
laravellaravel 4mod_rewriteMySQLPHPUbuntu
Share this
php

Redesigning the PHP logo – who wants ?

The current PHP logo is a really lovely one, it is highly accepted and has its own charme, transports a

hack-php

Wow! Facebook devs have rewritten and fixed PHP, releasing it as new language called “Hack” today

Exciting stuff is happening: Some years ago Facebook has released an early preview of HipHop, a virtual machine that precompiles

PHPMyAdmin not found after installation ? Here’s a fix (Ubuntu 12.04) !

You just installed PHPMyAdmin but http://www.yourdomain.com/phpmyadmin just says “phpmyadmin not found” ? Try to create a link in /var/www like

The architecture of StackOverflow

One of the most interesting talks these weeks, and a rare insight into one of the most active pages on

8 awesome pure CSS spinner / loader

Excllent spinner / loader in pure CSS, made with just one element (even if the demo shows this in a

Ghost

[FREE SERVER PROMO] Install GHOST for free on a free SSD server with this coupon

A little off-topic, but highly interesting: In April 2013 the former User Interface Head of WordPress (and WordPress expert) John

set up a local virtual machine for development with vagrant and puphpet / puppet (and ubuntu, linux, php, apache, mysql)

A super-simple pre-configured Vagrant box with HipHop, Hack and Hack code examples

Another game-changing project: Victor Berchet‘s HHVM Vagrant box is a simple Ubuntu 12.04 LTS Vagrant-box that comes with preinstalled HHVM/HipHop

shadow dom

Crossbrowser-safe HTML5 video (IE6+) with a few lines of code and just one .mp4 video file

No time to read the full article ? Get the code directly here on GitHub: panique/html5-video. Publishing a video on

phpstorm 7.0 php

A perfect video tutorial to get started with xdebug in PHPStorm

Laracast just published an excellent short tutorial on how to get install xdebug in a local environment and how to

php

PHP 5.7 gets refactored core, is 10%-30% faster than PHP 5.5! Wow!

What an announcement! The awesome PHP core guys have refactored the Zend Engine (which drives PHP) and could successfully speed

1/4

Categories

Search

The New Era of JavaScript (28min conference talk, Jack Franklin, 2013)
css3-chrome-font
[Link] Retinafy your Site / Device by Nijiko Yonskai
pdo-debug
Debug PDO with this one-line function. Yeah!
hack-php
The first micro framework written in Hack is there: hack-mvc !
Frontend Ops Conf 2014 – Paul Irish: Delivering The Goods In Under 1000ms (40min video)
photoshop-cc-deal
Adobe offers Photoshop for $9.99 per month (limited deal)
js javascript
JavaScript Testing Tactics (21min video by Justin Searls)
Adobe releases Firebug-like developer tools to edit and extract PSDs
set up a local virtual machine for development with vagrant and puphpet / puppet (and ubuntu, linux, php, apache, mysql)
A super-simple pre-configured Vagrant box with HipHop, Hack and Hack code examples
phpstorm 7.0 php
How to setup and use XDEBUG with PHPStorm 6/7 (locally in Windows 7/8 and Mac OS X)
shadow dom
Crossbrowser-safe HTML5 video (IE6+) with a few lines of code and just one .mp4 video file
php
12 tools for better PHP quality
harper reed about big data
Harper Reed – The magic and mystery of Big Data (30min video from Webstock’15)
the-php-login-project
How to install php-login-one-file on Ubuntu 12.04 LTS
php uk conference
Slides & talks from PHP UK Conference 2014

Tags

apache bash centos composer conference coupon CSS debian fonts framework git GitHub hack HHVM HipHop HTML HTML5 IDE JavaScript JS LAMP laravel linux mod_rewrite MVC MySQL Nginx optimization PHP PHP 5.5 PHP 5.6 phpmyadmin PHPStorm security server SSD Ubuntu UI UX vagrant video virtual machine voucher VPS wordpress
Side-Project: Wordle-Solver:
www.wordle-helper.info

Pages

  • Privacy Policy