Deploy Laravel Project into 000webhost site

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! :sunglasses:

1. Uploading.

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 :slight_smile:


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.

  1. Go to the root of your Laravel project:
     

  2. Select all files, folders (except node_modules) and ZIP them:
     

  3. Make sure the archiving method is ZIP. 000webhost can’t extract RAR archives.

  4. Zipping process can take a while. After it is done, make sure you have the following output file:
     

  5. Now go to File Manager and upload the newly created archive:
     

  6. After file has been uploaded, right click on it and hit ‘Extract’:
     


     

That’s it! You have uploaded your project to 000webhost :slight_smile:

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.

  1. 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 .htaccess redirect to point to the index file from /public but 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: /
     

  2. Configuring the public path
     
    Great, we have migrated the entire project from frontend to backend! However 000webhost’s public path is /public_html and 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 :slight_smile:
     
    A. Remove the current /public_html. We don’t need it.
    B. Rename /public to /public_html
    C. Go to /app/Providers/AppServiceProvider.php and append the following code to register() method:
     
    $this -> app -> bind('path.public', function()
    {
            return base_path('public_html');
    });
     

  3. 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.
     
    A. Locate .env file. Open it.
    B. Copy the the value of APP_KEY without ‘base64:
     


     
    C. Go to /config/app.php, locate ‘key’ and update its value to your APP_KEY according to the image:
     

     
    D. (optional) If you have a database, update the database credentials in /config/database.php with the ones from 000webhost cPanel > Manage databases:
     

     
    E. Clear old Laravel cache: Delete all files from /bootstrap/cache except .gitignore
     

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. :slight_smile:


FAQ.

  1. I am receiving Wrong COM_STMT_PREPARE response size. Received 7 error.
     
    Please go to /config/database.php and append the following line of code to your database connection configuration: 'options' => [PDO::ATTR_EMULATE_PREPARES => true,],

  2. I have deployed my project but I am still receiving Error 500/Something went wrong/Exception. What should I do?
     
    Please go to /config/app.php at debug vector and set the value to true. Now access the URL which is giving errors and start tracking the bugs.

  3. Why does the configuration from .env is not loaded automatically?
     
    Mainly said, Laravel uses putenv() to retrieve the variables from .env file 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 /config/[...] manually.

  4. 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. :slight_smile:

4 Likes
Code Error 500 on Laravel Projects
Laravel website error
How I can host my laravel project
Laravel Database connectivity issues
Laravel sites down?
Http 500 error. Please help
Laravel (5.5.*) and php (5.6.4) Application error (An error occurred in the website and your page could not be displayed. If you are the website owner, check your logs for details.)
Laravel (5.5.*) and php (5.6.4) Application error (An error occurred in the website and your page could not be displayed. If you are the website owner, check your logs for details.)
How to fix 500 () error?
how do i upload laravel to hosting ?
The only supported ciphers are AES-128-CBC and AES-256-CBC with the correct key lengths.
La página gestioneletk.000webhostapp.com no puede procesar esta solicitud ahora. HTTP ERROR 500
Laravel (5.5.*) and php (5.6.4) Application error (An error occurred in the website and your page could not be displayed. If you are the website owner, check your logs for details.)
SQLSTATE[HY000] [1045] ProxySQL Error: Access denied for user 'forge'@'
Problemas con el fichero index.php
Laravel .env can't be accessed but worked fine a week ago
Website not working after the Sleeping time
Host Lumen as a web API
Storage path on laravel project
Blank page after installation
Internal Server Error during deployment
Ftp_mkdir(): Can't create directory: File exists while unzipping zip folder in public_html
Deloy laravel 5.8 to 000webhost
500 error in laravel website
Fatal error: Uncaught RuntimeException: A facade root has not been set
Whats wrong here
Availability of host services and my php site and sql db
Can 000webhost install software?
Tengo un problema al subir laravel 5.7 a webhost
ERROR: SQLSTATE[HY000] [2002] Connection refused with Lumen
Wrong COM_STMT_PREPARE response size. Received 7 error
Why my webpages except first page are writting (404. That’s an error. The requested URL was not found on this server.)

Thnx man…I just had to put my APP_KEY to app.php

how to fix this sir

Make sure you are using the correct database credentials in /config/database.php

Your DB credentials are located in 000webhost cPanel > Manage databases

thank you sir it work … I change my config/database.php from “127.0.0.1” to localhost…