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

laracoft's avatar

Easiest production Linux for Laravel

Hi,

Just checking to see if there is a distro that is easy for production. By easy, I mean the following:

  1. Easy to update when vulnerabilities are found, i.e. well supported, no need to self compile patches etc
  2. Easy to secure, i.e. easy to find tutorials and solutions on the web to harden the Linux
  3. Easy to upgrade to latest PHP, i.e. well supported, no need to self compile PHP from sources

I was on CentOS previously. My aim is to minimize server administration and I'm open to paid options. Thank you.

0 likes
18 replies
Tray2's avatar
Tray2
Best Answer
Level 73

I usually go with Ubuntu since I've been running it for years. I just install the server version without any GUI and then ssh into it to manage it.

When it comes to keeping up with the most bleeding edge version of php you might need to add some other sources to the package manager to be able to install it but it's not that tricky.

If I would run it on a onprem non public intranet I would just follow one of these guides to set it up. https://www.howtoforge.com/tutorial/install-laravel-on-ubuntu-for-apache/

https://www.howtoforge.com/tutorial/ubuntu-laravel-php-nginx/

If I would have to host it on a cloud host then I would probably run docker on it

https://www.howtoforge.com/dockerizing-laravel-with-nginx-mysql-and-docker-compose/

There are many many options for this.

Another one that I think might be worth checking out is this course

https://laraveldocker.com/

It covers both setting up docker for your development environment and for production using Alpine linux.

The good thing about docker images is that you don't need to worry about updating since the official images handles that so you can generate the latest version on your dev and when you know that it works you can push it to production.

You also have the Laracastified version of the above course here https://laracasts.com/series/the-docker-tutorial

3 likes
laracoft's avatar

@tray2

Thanks for the details, regarding docker, you don't mean to run it in production do you? I'm aimed specifically at production here. I mean, is docker performant for production? Thank you.

Tray2's avatar

@laracoft Docker is very performant in production. So there are no issues on running docker in production. And it's very easily scaled if you have a load balancer. Then you can just spin up another instance of your server.

1 like
laracoft's avatar

@Tray2

I tried out ubuntu 21 and I must say, it is significantly faster than CentOS 8 running in VirtualBox. Not sure if it is because of SELInux.

Anyway, I was wondering if you can share whether you use SELinux or AppArmor? It is the last item on my checklist. :)

Thank you.

Tray2's avatar

@laracoft On my server that sits behind a firewall with no ports opened for access from the internet I only run apparmor which comes by default when installing Ubuntu. I've read some about apparmor and selinux and they aren't strictly necessary to run a server securely if you have the correct permissions set to the files and directories. They are however recommended. SELinux is a bit harder to configure while Apparmor is not as precise ( for a lack of a better word).

This might give you a hint which to use

https://ritcsec.wordpress.com/2016/11/30/apparmor-vs-selinux/

laracoft's avatar

@tray2 i know this is discussion is said and done, but I'm running into this issue and can't seem to find a solution.

The error below happens when ubuntu first boots, causing the website to load with SSL errors. (Note: apache2 is running as verified by service apache2 status and also being able to connect.

Once I run service apache2 restart, the website loads normally and without errors.

I deduced it to be something in particular to ubuntu and/or apache2. It would have been much easier if the service apache2 restart did not solve the problem, now I'm quite confused and in need of help.

Thank you.

# openssl s_client -connect example.com:443
CONNECTED(00000003)
139778191202112:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:ssl/record/ssl3_record.c:332:
laracoft's avatar

@Tray2 I came across that link, apachectl -S produced a list of vhosts but I could not see any issue with them. (apache works, so syntax of config files must be valid)

I have a number *.conf files, 1 for each domain with it's own specific certificate. This worked on CentOS. What I did was to link these files as-is into the site-enabled/ folder.

The more puzzling thing is that the issue goes away after I manually run service apache restart. That seems to me that the config is not only syntactically correct, but also functionally correct, it is just that things don't get loaded properly at boot and I can't find anything in the logs.

laracoft's avatar

@tray2 sorry, I have spent hours on this, any idea of a good forum? Thank you.

laracoft's avatar

@tray2 I managed to narrow down upon boot up, port 443 was serving HTTP instead of HTTPS. Utterly confused.

Sinnbeck's avatar

You could use either ploi or forge, and let them handle the server. Ploi just got insights that aims to fix stuff for you

1 like
laracoft's avatar

@Sinnbeck

Yea, but AFAIK, there is only 1 forge provider at the moment yea? ;) haha

Sinnbeck's avatar

@laracoft I personally use ploi, and it supports 6-7 providers I believe

They aren't that far with security yet, but it evolves day by day, and there is a market place for installing stuff.

But it is true that they only support Ubuntu, but it is my goto anyway (or Debian)

Please or to participate in this conversation.