Deploying your Laravel Project to 000webhost
(Tested for Laravel 5.6)
Hi everyone! This tutorial will help you deploy your Laravel project into your 000webhost site in a professional manner. I am more good at writing code instead of writing articles, so lets get straight to the subject!
Before we start, your website must be ‘clean’. It must not contain a single file in it, that to prevent interface with Laravel. Please back up your current website content and database, then go to 000webhost cPanel (choose the website you want to work with) > Settings > General > Reset website. After you’re done, you can continue further
Laravel contains a lot of files and folders, especially in
/vendor directory. If we would attempt to upload every file manually either over FTP either over our built-in File Manager it would take a lifetime.
Having that said, the best way to quickly upload your Laravel project to 000webhost is to: archive it, upload the archived content, extract it, and then apply whatever changes are necessary.
Go to the root of your Laravel project:
Select all files, folders and ZIP them:
Make sure the archiving method is ZIP. 000webhost can’t extract RAR archives.
Zipping process can take a while. After it is done, make sure you have the following output file:
Now go to File Manager and upload the newly created archive:
After file has been uploaded, right click on it and hit ‘Extract’:
That’s it! You have uploaded your project to 000webhost
2. Setting up the environment.
You have successfully uploaded your project to 000webhost. However your application is not ready yet. You’ll have to move on with further configuration.
Moving folders to appropriate path
The entire application alongside Laravel System itself is not accessible to the public. It must not stay in
/public_html. We could create a
.htaccessredirect to point to the index file from
/publicbut it will not be recommended: a) for security reasons and b) because this is not the way it supposed to work. Therefore we must move the entire Project to the root path of our website:
Make sure the destination is:
Configuring the public path
Great, we have migrated the entire project from frontend to backend! However 000webhost’s public path is
/public_htmland Laravel’s default public path is
/public. 000webhost and Laravel must reach a consent, otherwise the project won’t be online. Since we can’t configure 000webhost, we should configure Laravel
A. Remove the current
/public_html. We don’t need it.
C. Go to
/app/Providers/AppServiceProvider.phpand append the following code to
$this -> app -> bind('path.public', function()
Integrate application in new environment
Almost done. Now we need to set up the configuration. And remove previous cache so that Laravel will behave normally in the new environment.
.envfile. Open it.
B. Copy the the value of
C. Go to
/config/app.php, locate ‘
key’ and update its value to your
APP_KEYaccording to the image:
D. (optional) If you have a database, update the database credentials in
/config/database.phpwith the ones from 000webhost cPanel > Manage databases:
E. Clear old Laravel cache: Delete all files from
3. The end.
That’s it! You have successfully deployed your Laravel project.
For any further questions please check our FAQ section or open a new topic and we’ll discuss.
I am receiving
Wrong COM_STMT_PREPARE response size. Received 7error.
Please go to
/config/database.phpand append the following line of code to your database connection configuration:
'options' => [PDO::ATTR_EMULATE_PREPARES => true,],
I have deployed my project but I am still receiving
Error 500/Something went wrong/Exception. What should I do?
Please go to
debugvector and set the value to
true. Now access the URL which is giving errors and start tracking the bugs.
Why does the configuration from
.envis not loaded automatically?
Mainly said, Laravel uses
putenv()to retrieve the variables from
.envfile and store them as PHP environment variables.
putenv()has been disabled on 000webhost for security reasons. Your remaining choice is to update the configuration into
How to use Composer via SSH to manage my dependencies?
Free plans do not allow SSH connections to your websites. Paid plans do. You may purchase a cheap paid plan here.