Skip to main content
.com domains from $2.99 — free WHOIS privacy on every name

Stack build · Intermediate · 45 minutes, then benchmarked

How to install a lamp stack — Build the Four Layers, Then Find Out Which One You Are Waiting On

You can install four packages in ten minutes; what you cannot do yet is say which of the four is responsible when a page takes 800 milliseconds.

The short answer

Install the four layers, then benchmark them separately, because a stack you cannot attribute a delay to is a stack you cannot tune. Apache with the event MPM and PHP-FPM is the configuration worth starting from: prefork with mod_php spawns a heavyweight process per connection and is where most self-built stacks run out of memory under concurrency.

The build itself is straightforward — web server, database with its secure-installation script, PHP with the extensions your application names, and one virtual host per site. What separates a working stack from a fast one is the benchmarking afterwards, and knowing whether you are waiting on PHP, on the database or on the disk.

By the HostingFast team · Reviewed 24 August 2026

Intermediate

Assumed skill

45 minutes

Time at the keyboard

5

Stages in the runbook

24/7

Engineers on shift

Forty-five minutes on a fresh VPS you have already hardened. Every command here has an equivalent on any mainstream distribution; the reasoning matters more than the package names, which is why the reasoning is what this page spends its words on.

Finish with two numbers: time to first byte on a static file, and time to first byte on a PHP page that touches the database. The gap between them tells you which layer to look at first for the rest of the server's life.

Choose the process model before you install

Apache's event MPM with PHP-FPM keeps connection handling and PHP execution separate, so slow clients occupy a lightweight thread rather than a full PHP process. The old prefork-plus-mod_php arrangement ties one heavyweight process to every connection, and on a small VPS that is precisely how you run out of memory while the CPU sits idle.

Set the pool size deliberately. PHP-FPM's max children is the real concurrency limit of the machine, and it should be derived from available memory divided by the average process size rather than left at a default somebody chose for a different server.

Build the layers, then prove each one

Install the web server and load the IP in a browser: the default page appearing confirms the service, the firewall rule and your DNS assumptions all agree. Install the database and run its secure-installation script, which removes anonymous users, the test database and the empty root password — the three defaults that make a fresh install indefensible.

Then PHP 8.x with the extensions your application actually names: mysql, curl, mbstring, xml and gd cover most CMS work. Missing extensions surface as blank pages far more often than as helpful errors, which is why a short script that connects to the database and prints one row is worth writing. Delete it the moment it has answered.

Virtual hosts, and the file that must not stay

One virtual host file per site, each pointing a domain at its own document root, enabled and followed by a reload. Until you do this the server answers every request with the same default page, and the moment you have two sites the separation is what stops one leaking into the other.

Never leave phpinfo() reachable. It publishes your PHP version, module list, paths and configuration to anybody who guesses the filename, which is a complete map for choosing an exploit. Useful for ten seconds during setup, a liability every second afterwards.

Benchmark, then decide whether you wanted this

Run a load tool against a static file and then against a PHP page that queries the database, at a concurrency level you might realistically see. Static-fast and PHP-slow points at the pool configuration or the application; both slow points at the machine or the disk. Now you have an attribution rather than an impression.

It is also the moment to be honest about the trade. Our shared platform runs LiteSpeed with the cache engine compiled into the web server, which is a layer you would otherwise build and maintain yourself. Apache is the more forgiving thing to learn on; OpenLiteSpeed is the quicker thing to finish on, and it reads .htaccess rules in a way Apache users find broadly familiar.

A developer working against a hosted server over SSH

The alternative to building it yourself

The shared platform runs LiteSpeed compiled into the web server, with per-site PHP switching from the control panel and NVMe underneath — the same four layers, tuned and patched by somebody else. Building your own is a good way to learn the stack and a poor way to spend a Tuesday every month.

Human support is on duty every hour of every day, and the scope covers exactly this kind of practical question rather than bouncing it back to you.

  • LiteSpeed compiled into the server, cache engine included
  • Per-site PHP version switching from the control panel
  • NVMe storage on every tier, including the entry plan
  • KVM virtual servers with root access when you want to build it yourself

Why HostingFast

Standard on every plan

The process model decided first

Event MPM with PHP-FPM against prefork with mod_php, explained by what each one does to memory under concurrency.

Concurrency set on purpose

PHP-FPM's max children is derived from your memory and process size rather than inherited from a default.

Each layer proved separately

Web server, database, PHP and the connection between them, each confirmed before the next one is installed on top.

A benchmark you can attribute

Static file against database-backed page, so a slow response points at a layer rather than at the whole machine.

The diagnostic file removed

phpinfo() is treated as the ten-second tool it is, and the page says plainly what leaving it costs you.

The build-or-buy question answered

What you gain from your own stack and what you take on maintaining it, stated rather than assumed.

Quick Start

From order to online

  1. 1

    Pick the MPM and the pool size

    Event MPM with PHP-FPM, and max children derived from available memory divided by average process size. This decision sets the machine's real concurrency ceiling.

  2. 2

    Install the web server and check port 80

    Load the server's IP. The default page appearing confirms the service is running, the firewall rule exists and DNS is doing what you assumed.

  3. 3

    Install the database and secure it

    Run the secure-installation script: anonymous users, the test database and the empty root password all go. Bind it to localhost while you are there.

  4. 4

    Add PHP and its extensions, then prove the chain

    PHP 8.x plus mysql, curl, mbstring, xml and gd. A short script that connects and prints one row exercises all four layers — then delete the script.

  5. 5

    Configure virtual hosts and benchmark

    One file per site, its own document root, reload. Then load-test a static file and a database-backed page and note both first-byte figures.

Built In

Loaded onto every plan

  • NVMe SSD storage on every tier, including the entry plan
  • SSH, Git and Composer on the developer-focused plans
  • Per-site PHP version switching from the control panel
  • LiteSpeed caching compiled into the server, not bolted on by plugin
  • DDoS filtering absorbed out at the network edge
  • cPanel — the control panel most of the industry already runs
  • Daily backups on every plan, with restores you run yourself from the panel
  • Staging environments for rehearsing a change before it ships
  • Zero setup charges — there is no joining fee, ever
  • Human support on duty every hour of every day

Frequently Asked

What people ask us most often

prefork, worker or event — which MPM should I run with PHP-FPM?

Event, in almost every case. It handles keep-alive connections on lightweight threads while PHP-FPM runs PHP in its own pool, which is far kinder to memory under concurrency than prefork with mod_php tying a heavyweight process to every open connection. Prefork survives mainly because old tutorials keep recommending it.

How do I benchmark a fresh stack without fooling myself?

Test two things separately at a realistic concurrency: a static file, and a PHP page that actually queries the database. Run it from another machine rather than from the server itself, and run it more than once. Static-fast with PHP-slow points at the pool or the application; both slow points at the machine or the disk.

Which PHP extensions do the common CMSes actually need?

mysql, curl, mbstring, xml and gd cover most WordPress, Joomla and Drupal installs, with imagick and zip frequently wanted too. Missing extensions rarely produce a useful error — a blank page is the normal symptom — so install the set your application documents and confirm with a one-line script before you start debugging the application itself.

Is OpenLiteSpeed a straight swap for an Apache configuration?

Close, not identical. It reads .htaccess rules in a way Apache users find broadly familiar and brings a caching engine Apache does not have, but virtual host configuration and some directives differ enough to need reading. Our shared platform runs LiteSpeed with the cache compiled in, which is the same benefit without the migration afternoon.

Keep reading

  • How to Create a Subdomain

    Point blog.yourdomain or app.yourdomain at its own document root, with the certificate covering it — beginner, roughly 5 minutes.

  • How to Minify CSS and JavaScript

    Measure render-blocking milliseconds, then change one flag at a time with the console open — intermediate, roughly 30 minutes.

  • Best LiteSpeed Hosting

    The same decision as a buying guide: what the cache engine changes, and the plan we would sign.

  • Web Hosting

    cPanel hosting on NVMe behind a LiteSpeed cache — SSL, migration and a year-one domain included.

  • VPS Hosting

    KVM virtual servers with root access, DDoS filtering and one flat monthly price.

Changing hosts? Run through our checklist first.

A straightforward sequence for a switch your visitors never feel: which files move first, how to shift email across without losing a single message, the right moment to repoint DNS, and the two mistakes behind almost all the downtime we get asked to rescue.

You'll get the checklist email, then occasional pointers on keeping a site running fast. Unsubscribe the moment you want out — the privacy policy covers the rest.

Build it, or skip to the tuned version.

KVM servers with root access if you want the stack yourself — or LiteSpeed compiled in, per-site PHP and NVMe if you would rather not.

View Web Hosting plans