Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

yossi's avatar
Level 2

How and what to deploy?

I have a laravel 8 app, i am done with the development.

  1. what should i do before upload?
  2. what files should i upload?

i ask because i have clockwork and debugbar, which i am sure shouldn't be uploaded. and so most of the vendors folder..

I will deploy it to a shared hosting account, with cPanel.

0 likes
3 replies
ycsm's avatar

Also, you may need to delete your config.php file if you get errors

kokoshneta's avatar

Before you start thinking about deploying, you need to make sure you have an appropriate target.

Most shared hosting is not suitable for Laravel apps.

The structure of a Laravel app hinges on sensitive content being located in a location that is not accessible through a browser – most importantly, your .env file. When you go to www.example.com, what happens is that the server software (Apache, Nginx, etc.) on that server looks in a specific directory for a file matching either the file name specified (e.g., if you to go www.example.com/myfile.jpg, it looks for myfile.jpg) or, if no file name is specified, one of a number of predefined names, such as index.htm or index.php. Then it opens and evaluates that file, and finally it sends the content returned by the file to the user’s browser, which shows it as HTML. The directory the server uses as its ‘starting point’ to look for the file is called the document root.

In a Laravel app, the index.php file that is meant to be loaded, and which will return the content for the user, is located inside the public folder. So when you deploy to a server, you have to make sure, then, that the server’s document root is the public folder inside your Laravel app.

On shared hosting, you only have access to a single folder on the server (for example /www/yossis_account/), and everything you upload goes inside that folder. So if you upload your whole Laravel app there, the index.php file be located at /www/yossis_account/public/index.php). That in itself is not a problem, as long as you can instruct the server’s software that when serving content, it should use /www/yossis_account/public as the document root.

The problem is that on shared hosting, you normally can’t change the document root. Most shared hosting will use in /www/yossis_account/ and only that, and that is the root folder of your Laravel app, the one containing your .env file, your Composer files, and lots of other stuff, but no index.php file. So if the user goes to your website’s home page, they’ll get an error because there’s no index file (bad!) – and even worse, if they go to www.example.com/.env, they will see the contents of your .env file, including all your passwords (very bad!).

So before you start deploying, check if your cPanel allows you to change the document root. If it doesn’t, then don’t deploy your app to that server/hosting.

1 like

Please or to participate in this conversation.