Tuesday, January 15, 2013

Setting up Laravel-4 on Webfaction

Setting up laravel 4 on [**Webfaction**](http://webfaction.com?affiliate=jeff01)

Setting up laravel 4 on Webfaction

  1. Create your domain or subdomain. E.g laraveltest.hostname.com

    Check here on how to create add domains or subdomains on webfaction.

  2. Create your application. Make sure you select Static/CGI/PHP and PHP 5.4 runtime

    Check here on how to create add applications on webfaction

  3. Create your website and add domain and application you've created. E.g laraveltest

    Check webfaction on how to create website on webfaction

Test in browser

http://laraveltest.hostname.com

and see you have Hello World displayed.

Setting up laravel 4

Installing composer

To install composer to your home directory

$cd ~

Run this using php54 runtime

$php54 -r "eval('?>'.file_get_contents('https://getcomposer.org/installer'));"

This will install composer to your home directory so you can run it like composer.phar

Installing latest laravel-4 version

As of this writing laravel 4 is still in better. To get the lastes go to http://four.laravel.com and get the latest version.

I got my version from https://github.com/laravel/laravel/archive/develop.zip

$ cd ~

$ wget https://github.com/laravel/laravel/archive/develop.zip

$ unzip develop

This will unzip the content of develop to laravel-develop directory in the home directory

Ready to install laravel dependencies

$ cd ~

$ cd laravel-develop

$ php54 ~/composer.phar install

This will install all laravel dependencies into the vendor directory in the laravel-develop directory

Create a directory in your home folder that will take all laravel apps

$ cd ~

$ mkdir laravelapps

$ cd laravelapps

$ mkdir laraveltest

Now copy the content of ~/laravel-develop/public directory into ~/webapps/laraveltest.

You should have these files inside the directory ~/webapps/laraveltest

index.php
.htaccess
favicon.ico

Now copy all files and folders inside ~/laravel-develop except vendor and public to ~/laravelapps/laraveltest/


We are almost there!


Editing index.php to point to the the right files

$ cd ~/webapps/laraveltest

$ nano index.php

Change this line

require __DIR__.'/../vendor/autoload.php';

To point to the new path:

require '/home/<<your-webfactio-username>>/laravel-develop/vendor/autoload.php';

Or

require '~/laravel-develop/vendor/autoload.php';

Then change this line

require_once __DIR__.'/../start.php';

To

require_once '/home/<<your-webfactio-username>>/laravelapps/laraveltest/start.php';

Update:

In order to use artisan commands do the same changes you made above to index.php in this file: ~/laravelapps/laraveltest/artisan


Done!!

Now check

http://laraveltest.hostname.com

You should see Hello World from laravel default '/' route.

Happy coding!!

Cheers!! @badu_bizzle

Special thanks to Taylor Otwell for creating the awesome PHP framework