Deploy Laravel Application on Shared Hosting (Godaddy)

Bour Abdelhadi
4 min readMay 5, 2018

--

In this article , I’ll try to explain how you can deploy your laravel application on shared hosting .

I’ll use godaddy.com .

First of all , you should choose a domain name & select a plan for your hosting .

We can select the first option : Starter with 2.99 € / month .

After the purchase , you’ll have access to your cpanel . The first thing which we should do is enabling the SSH , to do that , you should go to your products , then click on Manage .

You’ll be redirected to your Cpanel page , in the bottom-right , you’ll be able to enable your SSH .

To connect to your SSH , you’ll need : Host , USERNAME , PASSWORD . If you are using windows , it’s easy to connect with Putty ? on linux , you can use your Terminal by typing :

SSH username@ip_address

It will ask you for the password which is the same as your Cpanel .

Laravel Deployment :

Login to your SSH account and Install composer using these 4 commands

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"php composer-setup.phpphp -r "unlink('composer-setup.php');"

to verify that composer has been installed on your server , you can check the version :

composer --version

Now we can create fresh Laravel installation using composer :

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

If you already developed your application on local , you can zip your files and upload them to your Cpanel using FTP or the uploader thru file manager.

How ?

Create a new folder in your public_html and rename it for example : blog

Upload your zip and extract all your files .

Now you must move your public folder to public_html

Now we should go to our folder public and edit index.php

You should edit the line 22 & 36 by adding the name of the path which we already created , in my case it’s blogf , in the top of the article I said : blog

PS : I renamed the folder to blogf because I had a route in my laravel project which has the same name , so you should take in consideration this case .

If you visit your link now , you’ll face HTTP Error 403 — Forbidden .

How to fix this ?

Just create an .htaccess file in your public_html and pass this :

In our .htaccess , you should change blog if you used different folder name.

Now you can visit your application .

For Database :

1 / Update your .env file .

2 / Create a database and user (Link them) .

3 / Run php artisan migrate (It’s working on goddady now) .

If you want to install node in your server : (we can use nvm )

Login to your SSH and type this command :

wget -qO- https://cdn.rawgit.com/creationix/nvm/master/install.sh | bash

run this command in order to be able to use it :

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

After that you can install node :

nvm install node

If you have questions please let me know .

Check my gigs on fiverr :

https://www.fiverr.com/bohrhadi

Follow me on linkedin :

https://www.linkedin.com/in/bohr/

--

--