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

The architecture of StackOverflow

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

phpstorm-8

Ignore .idea folder from git in PHPStorm

By default (?) PHPStorm will create a hidden folder named .idea directly within your project, containing user-specific stuff like chosen

js javascript

JavaScript Testing Tactics (21min video by Justin Searls)

Awesome next-gen PS4 graphics in “The Order: 1886”

We are entering a very interesting time: The differences between cinematic movies and video games are getting lesser and lesser.

october cms

[Link] How To Install October CMS on a VPS running Ubuntu 14.04

Quick tutorial on how to install October CMS on Ubuntu 14.04 by DigitalOcean. Worth a bookmark, does the job. I

Test GZIP compression of your server easily

If you are running servers (which you hopefully do), then Gzip compression should be a topic, as this simple thing

Migrating Wikipedia to HHVM (@Scale Conference 2014)

Awesome topic, superfresh, directly from Scale Conference 2014. The title says everthing. Full quote from video’s description: As a top

mod-rewrite-ubuntu-14-04-lts

Which server OS version to choose ? Some EOL lists of Debian, Ubuntu and CentOS

Moving running projects (especially smaller ones that you’ve made for clients years ago) from an outdated and not-supported linux version

Frontend Ops Conf 2014 – Keynote by Alex Sexton: “Front End Operations”

https://www.youtube.com/watch?v=7HGe8zZ1G6k

ubuntu-14.04-lts

First view: Ubuntu 14.04 LTS brings PHP 5.5 and Apache 2.4

Short first view on Ubuntu 14.04 LTS (= long term service): I just tried out the alpha1 version of the

1/4

Categories

Search

All new features of WordPress 3.9 in this 2 minute video
phpstorm-8
When PHPStorm’s cache eats up your harddisk space
Stressed and unrelaxed while coding ? Try some ultra-deeply-relaxing ASMR audio clips. It will change your life. Seriously.
Berlin, prepare for TOA conference (15th – 17th of July)
photoshop-cc-deal
Adobe offers Photoshop for $9.99 per month (limited deal)
php
Postmodern PHP: appserver.io, a multithreaded application server for PHP, written in PHP
[Link] Redesigning SoundCloud by Evan Simoni
Frontend Ops Conf 2014 – Keynote by Alex Sexton: “Front End Operations”
phpstorm 7.0 php
How to install GitHub’s, NetBeans’s and Sublime2’s syntax highlighting code colours theme in PHPStorm 6/7
PHPMyAdmin not found after installation ? Here’s a fix (Ubuntu 12.04) !
ilovepreloaders – A tumblr collection of preloader animations
Joshua Davis – my hero of Flash – in two excellent interviews (audio, video)
composer
[Link] How to require versions of PHP, HHVM / HipHop, GD, curl, openssl etc. with Composer
modern-php
Creator of Slim framework and “PHP – The right way” writes book: “Modern PHP”, available 2015
hearthbleed-ssl-bug
A quick guideline on how to fix the Hearthbleed bug (and update OpenSSL) on Ubuntu

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