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

ezheng's avatar

How to deploy laravel project on synology securely?

I already deploy my laravel project on SYNOLOGY DS720+ and it runs well already. I can access that project using \IPADDRESS\public and all the feature run well.

But it is not secure. I can access my .env using \IPADDRESS.env.

How can i secure my .env file?

I have tried :

  • change permission of .env to 640 , it can secure my .env but it make the laravel project cannot be accessed too.
  • create .htaccess to protect the .env file, but the results is same. .Env and my laravel project cannot be accessed.

Everytime i make .env cannot be accessed from public, it makes make laravel project cannot be access too.

So how to secure my .env file?

0 likes
5 replies
kokoshneta's avatar

I have no idea how Synology works (never heard of it before), but the server that your Laravel app is running on should be set up so that the public root (the directory that is loaded when you go to https://serveraddres.com) should be the public directory, not the main Laravel app.

Looking into it, it seems like Synology DS720+ is a piece of hardware? So how are you actually serving the app? What server software are you using?

Sinnbeck's avatar

I'm about to do the same on the exact synology. I'll let you know how it goes

I plan to use the build in webserver with nginx and php 8.0

Maybe explain your setup so I can compare

ezheng's avatar

@Sinnbeck Hi. I am so sorry not reply it yet. i am still following the instructions there. I am stuck on the 8th step there. But i still try and googling it too. I will inform the results after I passed the 8th steps. thanks bro

Please or to participate in this conversation.