Deploy Laravel 5 to /htdocs

I am looking for clear steps/guide to deploy Laravel on free shared hosting plan on this platform. I tried to find on this forum and also Google but none of them are clear and working, perhaps my Laravel knowledge is insufficient.
Nevertheless, my understanding is that this is very much dependent on the hosting provider. SO, if InfinityFree can provide such steps to deploy Laravel on its shared hosting server, that will be much appreciated.

The first thing to understand is that Laravel is definitely not designed with the typical characteristics of a website hosting service. While it’s possible to run Laravel here, it’s not pretty or easy. If you want to have good hosting for Laravel, you’d need a service with at least SSH/command line support, and preferably Composer and Git support as well.

That said, you can run Laravel here, by simply uploading all the files of your Laravel codebase to the htdocs folder of your website using an FTP client of your choice (like FileZilla). This should include the vendor folder created by Composer, since you cannot install the Composer dependencies by hand.

After that, you’ll need to make any changes necessary to your .env file, and finally add a .htaccess file as described here:

Note that you’ll still lack:

  • Access to the artisan CLI.
  • InnoDB database support.
  • Automatic deployment from Git.
  • Installation of Composer dependencies on the hosting server.
  • Preparation of static files (Laravel Mix) on the hosting server.

If you can live with these limitations, you can use Laravel here.


Thank you Admin for the feedback. Yes, Laravel deployment on free shared host is not ideal and certainly the lack of features as you mentioned like Laravel Mix, SSH, Artisan CLI and automatic Git support are probably for premium hosting services, thus making Laravel deployment on shared host more tricky.
Certainly, my aim here is just to test how good is infinity free’s free shared hosting for Laravel deployment. One thing I noticed of significant shortage is the lack of clarity by using htdocs/ and restriction to create directory at the htdocs/ level. What this means is that it is difficult to keep the Laravel file structure.
Coming back to your answer, I understand that the steps are:

  1. Upload all Laravel codebase files to htdocs/, flatening the public/, via any FTP client.
    1.1: Use phpMyAdmin to create a database, can use the phpMyAdmin import/export feature.
  2. Make necessary changes to .env file - put in database credentials, APP_URL.
  3. Make necessary changes to index.php?
  4. Make changes to .htaccess file. Unfortunately the RewriteRule (.*) /public/$1 [L] seems not working under this deployment scenario. I am not expert in .htaccess codes but there needs to be example codes from you in order to make it works.
    The principles you mentioned are fine but the devil is in its details I think. I think Infinity Free has good cPanel features but lacking the flexibility of its directory creation support making the simple laravel deployment difficult on shared hosting.
    So, if I can live with those limitations, are you sure that Laravel deployment on Infinity Free shared host is possible? I have tried with the steps above and they are not working so far…The key questions are:
  5. If you Apache settings are good, then why can’t I keep the Laravel file structure under htdocs/?. This should be possible as I have done so in my local machine using XAMPP.
  6. Pending answer from (1), what changes needed to be made on index.php?
  7. Similarly for .htaccess, I cannot find any workable codes so far.

If you kindly provide some answers, that will be appreciated.

Premium hosting doesn’t have most of those things either. They do have Git deploys, but not command line access or a good way to run Mix/Webpack.

If you want all of those things, I’d recommend a VPS or an application hosting platform like Heroku or Cloudways. The InfinityFree client area (also built with Laravel) is runs on VPS, where it can use things like Queue workers, Redis and Deployer to use more advanced features.

You’re making it unnecessary complicated for yourself.

Just follow the instructions I gave above. Upload the Laravel installation to your htdocs folder and add the .htaccess file I provided as-is to the main folder of the application.

Don’t flatten the public directory, don’t edit the index.php and don’t edit the .htaccess file provided by Laravel. The .htaccess file abuses rewrite rules to create a “fake” document root change. That way, you can keep the entire Laravel directory structure as-is.

So the setup is:

  1. Upload Laravel code to htdocs folder including Composer vendor folder and prepared static files.
  2. Add .htaccess file to htdocs folder.
  3. Create database and import dump.
  4. Update settings in .env file.
  5. Live happily ever after.

The database can be created through the MySQL Databases section in the control panel, not phpMyAdmin. Since you can’t run migrations and seed scripts from the command line, it’s probably best if you run those on your own computer, dump the database there and import it here.


Thanks Admin for the reassurance and guide. As this is my first attempt, nerve/tension is high and I over-complicated the deployment. Having given it a second proper attempt, I successfully deploy the laravel project. So, here are the steps:

  1. Upload all your laravel files (as it is) from localhost to /htdocs - it is better to create a subfolder under /htdocs to better manage the project.
  2. Export phpMyAdmin DB and import to infinity DB. Should obtain all the credentials needed to set the DB credentials in .env file.
  3. Update the DB settings in .env file.
  4. Create a .htaccess file at /htdocs folder. see e.g. file
    < IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule (.*) /your_subfolder/public/$1 [L]
    < /IfModule>
    The shared host server therefore is quite friendly to Laravel deployment and this is a top-class server configuration, different from other hosting providers.
    Due to lack of SSH, one may face laravel specific error but this is not a big issue if one is familiar with Laravel.
1 Like

I wouldn’t go so far as to call it that. There are probably quite a few things which don’t work right away, if at all, which I’m not aware of. And I still consider the experience to be to messy to say we properly support Laravel.

But I’m glad to hear you’re liking the system so far, and I’m very curious as to how well your site will run when the traffic actually comes in!


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.