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

tisuchi's avatar
Level 70

Secure way to host Laravel Project

I am planning to use shared hosting (cPanel) to up my laravel project. Everything is working fine for me.

However, in order to ensure security of my project, do you think that change app location is right? Or is there any better way to do so?

0 likes
4 replies
petehouston's avatar

From my experiences, if you use shared hosting, then I have several suggestions:

  • Never put any sensitive information on ~/www or ~/public_html (such as: .env)
  • All hidden information should be contained in hidden style. In Unix, it is a file start with letter dot, that's why it is named .env
  • Use complicated passwords, but should be easily remembered for you only.
  • Buy a SSL certificate and setup for your account, that leads to use HTTPS for everything.
  • Always remember: you are shared host with many others, so there might happen local hack attempts.

I personally run sites in both shared hosting and own servers, but shared hosting is for small sites with unimportant stuffs only. For big or important ones, I run on my own servers in which I have full controls over.

tisuchi's avatar
Level 70

Nice. TQ. But all sensitive information like .env should be in root directory. How do you think about that?

JeroenVanOort's avatar

What I've done on DirectAdmin servers, is to place the project in ~, remove the ~/public_html folder and make a symlink called public_html to public. This makes sure that the public folder is the only folder actually accessible from the internet.

You could do the same for a cPanel server, but I'm not sure which directories it uses.

tisuchi's avatar
Level 70

I see... its nice if I can do.. In the same hosting, I hosted some other sites, wordpress based. I dont think so that I can rename that... :)

Please or to participate in this conversation.