How To Deploy A Laravel Project On Linux Shared Hosting In 5 Minutes

How To Deploy A Laravel Project On Linux Shared Hosting In 5 Minutes

https://ift.tt/2vpfzuP

In my 2019 review I mentioned that I was working on a side project which is setting up a shared hosting platform with Laravel developers in mind.

I have deployed lots of Laravel projects on Linux shared hosting and I know how painful it is especially when there is no ssh access.

Litehost is here to solve that problem. It has ssh access on all its hosting plans and it has Composer, Git & PHP CLI pre-installed on its servers. Finally it pretty affordable, just ₦400/month ($1.11). Isn’t that amazing? Litehost is live and its been accepting customer since 24th December 2019.

Just yesterday I moved my blog which I built with Laravel to Litehost server. So I am going to show you how I did it in 5 minutes.

Lets get to the main thing. I will assume you have already a Cpanel account with ssh access on it.

Project Setup

Push your Laravel project to a remote git repository. I already have my blog’s repository on GitHub and its open source.

Now lets go back to our Cpanel. If you have ssh access on your hosting plan, look for terminal under the advanced tab and click on it.

Move into your public directory and pull your Laravel project from your remote repository.

cd public_html git clone https://github.com/stephenjude/stephenjude.tech.git blog 

With this command you now have your project inside public_html/blog folder.

Make a copy of your .env.example file and update your .env variables. You can do this using the CPanel file manager. Remember that Show Hidden Files (dotfiles) must be enabled from the CPanel file manager settings.

Now enter into the project folder and pull all the required dependencies.

cd blog composer install 

Fine, now we have our Laravel project ready to be served but its remaining one more thing. Laravel makes use of the storage folder for lots of things like writing logs, caching views and local file storage for uploads. Lets make that folder writable.

 chmod 777 storage 

I know this is not advisable but we are not on a VPS. We are on a shared server with some some limits to what we can do. Yeah.

Finally you have to setup your .htaccess file to point to your Laravel public folder. You can find this .htaccess file inside the public_html folder. If its not there then create one and update it with the code below.

RewriteEngine on RewriteCond %{REQUEST_URI} !^blog/public RewriteRule ^(.*)$ /blog/public/$1 [L] 

That’s it, you have successfully deployed your Laravel project.

Conclusion

I know this not the best way to deploy a Laravel project but I believe it’s efficient enough to get your project up and running on a Linux shared hosting.

I am still working on setting up shared hosting plans tailored for Laravel developers. The idea is to save time and deploy faster on shared hosting.

Join my weekly newsletter and never miss out on new tutorials, tips and more.

You can also follow me on twitter @stephenjudeso

programming

via Laravel News Links https://ift.tt/2dvygAJ

January 23, 2020 at 06:42AM