Installing the Laravel PHP framework at Hawk Host

Laravel is an increasingly popular PHP framework which means we have customers inquiring how do they go about installing it on their hosting.  I’m going to go through how to install Laravel on our servers on the primary domain of the account.  You could also using this tutorial install it within an add-on domain or sub domain with just a few modifications.

We’re going to do the entire installation from SSH which means you’ll need a SSH client.  I would recommend using Putty if you’re running Windows you do not already have a SSH client.  Once you have your SSH client ready it’s time to start the installation process.

Enable PHAR

By default our servers do not have the PHAR extension enabled.  You will need to enable it from your cPanel.  Login to your cPanel then go to “Select PHP Version”

select-php-version
Once you are on this page you will see a list of extensions.  You will need to be on PHP 5.3, 5.4 or 5.5 and check off PHAR and click save:

select-php-version enabling phar shared hosting

Congratulations we now have Phar enabled on our account.  We can now install composer on our account.

Installing Composer

Composer is a tool for dependency management in PHP.  We are going to use this to install Laravel on our account.  At this point we will now want to login to SSH of our hosting account.  Once you are logged in you will want to run the following command

curl -sS https://getcomposer.org/installer | php

Composer should now be installed at /home/yourusername/composer.phar .  We however want to be able to just run composer rather than specifying where composer.phar is.  We can do that by doing the following:

echo "alias composer='php ~/composer.phar'" >> .bashrc
. ~/.bashrc

What this does is add an alias for composer and then reloads your .bashrc file so it’s available immediately.

Installing Laravel

We now are finally going to install the laravel package.  We can do this by running the following  from SSH:

composer create-project laravel/laravel myproject --prefer-dist

Laravel should now be installed in the folder myproject and there is just one more step to make the the project compatible with our hosting.  You will now need to make so the public folder of laravel is in fact your public_html folder.

mv public_html public_html_backup
ln -s /home/username/myproject/public /home/username/public_html

Make sure to replace username with your accounts username.  You have now successfully installed laravel and if you view http://yourdomain.com/  you will be greeted with

Laravel WelcomeIf you ever want to have your old public_html folder back you would have to run the following from your home folder:

rm public_html
mv public_html_backup public_html

I think that covers everything you need to get your laravel project started.  You will be able to modify files in your myproject folder.  You can use composer to add additional dependencies to your laravel project.  You can also use Laravel’s artisan CLI to assist with the development of your application.

This entry was posted in General and tagged , , , , . Bookmark the permalink.

5 Responses to Installing the Laravel PHP framework at Hawk Host

  1. I have followed your guide but I do not get the laravel welcome page I just get to folderes

  2. Tony Baird says:

    It sounds like you did not create the symbolic link at the end. I believe you opened a ticket with our support team and they found that to be the case and corrected it for you.

  3. Pingback: Installing OctoberCMS at Hawk Host | Hawk Host Blog

  4. Johnmark Wachira says:

    Does the same work on any other shared platform?

  5. Tony Baird says:

    This might work on other shared platforms but there is no guarantee. You need the necessary extensions (many don’t offer the ability to choose them or limit the extension) as well as SSH access.

Leave a Reply

Your email address will not be published. Required fields are marked *