Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,150 of 9,150 pages
About the help in other languages
All help pages

Lesson 1.1: How a request is served

Learners compare the four ways to serve an Exponential site, trace a request through the routing rules and prove with four curl requests that the rules are active. 40 minutes.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/help/trainers/hosting-operations/module-01-serving-the-site/how-a-request-is-served.md

On this page

Lesson 1.1: How a request is served

An installed Exponential is a directory of PHP files. Something must accept connections, speak HTTP and HTTPS, hand out static files and pass every other request to a front controller. This lesson gives learners the map they need for the whole course: the four ways to serve a site, the one routing rule list they all share, and a quick check that shows whether a server really applies it.

Warning

.htaccess slows down every request. When .htaccess files are enabled (AllowOverride anything but None), let alone used, Apache looks for them and reads and evaluates them on every request, in every directory of the path, and page loading times go up drastically (measured). The only real fix is to switch the feature off for the virtual host: AllowOverride None in the HTTPS virtual host, and the rules in the virtual host's own configuration as mod_rewrite rules. That is far faster in production speed tests and well worth the time it takes to optimize a production configuration. Switch over right away: copy the rules of the example HTTPS virtual host into your virtual host (with the static cache, also staticcache_offload.conf), set AllowOverride None, run apachectl configtest, reload Apache and test the site. The same rules for other servers: nginx, LiteSpeed, Caddy, IIS, Velocity (built in); where virtual host rules go in a control panel: Plesk, cPanel, DirectAdmin, ISPConfig. On LiteSpeed or OpenLiteSpeed, the server's own page cache can also answer anonymous visitors and crawlers without PHP: Page caching with LiteSpeed and OpenLiteSpeed.

Note

Every exercise in this course runs on the learner's own training installation or virtual machine, never on a live customer site.

At a glance

CourseHosting and operations
ModuleModule 1: Serving the site
Duration40 minutes (20 presenting, 20 exercise)
LevelIntermediate
AudienceSystem administrators and hosting support staff
PrerequisitesA training installation per learner, served on the learner's machine (see One installation per learner); a terminal with curl

Learning objectives

After this lesson, learners can:

  • name the four ways to serve a site (Velocity with the qbix engine, FrankenPHP through Velocity, Apache with PHP-FPM, nginx with PHP-FPM) and say which one the project recommends;
  • explain why the document root is the installation root;
  • describe what happens to a request for a dot file, a PHP file below the root, an asset and any other path;
  • check with four curl requests that the routing rules are active on a server.

Trainer's notes

How to present it

Source: Chapter 8: Serving the site, sections 8.1 and 8.2.

  1. The choice in one table (6 minutes). Put the table of section 8.1 on the projector. Point out three rows: Separate web server needed (no for Velocity and FrankenPHP), Application kept in memory between requests (only Velocity) and Suits shared hosting (usually only Apache with PHP-FPM). Velocity's qbix engine is the recommended way at every stage; FrankenPHP is a production-ready alternative; Apache and nginx with PHP-FPM are the traditional setups.
  2. When to choose a traditional server (4 minutes). From section 8.1: hosting that forbids long-running processes, a tuned Apache or nginx the customer wants to keep, or customers that need operating-system isolation from each other. (A machine with only PHP 8.0 is no longer on the list: Velocity runs on 8.0 from its release 0.0.4.54.)
  3. One routing list (6 minutes). Draw the diagram of section 8.2. The rules are written down once in .htaccess_root; Velocity's engines and the generated FrankenPHP configuration implement the same list. Stress the two security consequences: no PHP file runs because its path was asked for (except the front controllers at the root), and a file outside the asset list is never handed out.
  4. The check (4 minutes). Show the four curl requests from section 8.2 against your own training site and explain each expected answer.

Common questions

Why is the document root not a public/ directory? The installation root is the document root under every server; the routing rules decide what is reachable. A 404 for every asset under design/ is the sign that the document root is set wrong.

Can I use PHP's built-in server? It is the third Velocity engine (php) and the shipped default only because it needs nothing installed. It has no TLS and is for development, not for visitors.

Can two servers serve the same files? Yes. Velocity beside Apache during a migration is a common shape; the file ownership rules of section 8.7.2 then matter (lesson 1.2).

Where are the rules for nginx? The project ships none; chapter 8 gives a derived server block, translated rule for rule from .htaccess_root (lesson 1.2).

Pitfalls

  • A 200 for /.git/config. The rules are not active: Apache without .htaccess or AllowOverride, or an nginx block that is not the chapter's. Stop and fix it before anything else; this is the most important result of the lesson. Under Apache, ./console exp:setup:status shows at once whether .htaccess exists and which template it is a copy of (Setting up .htaccess and config.php from the console).
  • Wrong port. Learners copy 127.0.0.1:8088 from the book while their site runs elsewhere. Have them run php bin/php/console exp:velocity status first; it lists every address as a full URL.
  • The qbix engine answers 403, not 404, for dot paths. Both mean the file was refused.

Hands-on exercise

Use your own training installation, served on your machine (for example with php bin/php/console exp:velocity start after exp:install, see The console install).

  1. In a terminal, change to the installation root (the directory that holds index.php).

  2. Run php bin/php/console exp:velocity status and note the address of the site.

  3. Open .htaccess_root in a text viewer (less .htaccess_root). Find the rule for dot files and the final rule that sends everything else to index.php.

  4. Request a dot file, replacing the address with your own:

    curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8088/.git/config
  5. Request a kernel source file:

    curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8088/kernel/classes/ezcontentobject.php
  6. Request robots.txt the same way and note the code.

  7. Ask for the settings file and count whether its content came back:

    curl -s http://127.0.0.1:8088/settings/site.ini | grep -c '^\[DatabaseSettings\]'
  8. Request a stylesheet path from the site's front page (copy one from the page source) and check that it answers 200.

  9. Write down, in one sentence each, what happened to the requests of steps 4 to 8 and why.

Expected result

  • Step 4: 404 (or 403 from the qbix engine).
  • Step 5: 404; the PHP file was neither run nor sent.
  • Step 6: 200 when the file exists.
  • Step 7: 0: the request reached index.php, which answered with a page, not the file.
  • Step 8: 200 for a listed asset path.
  • The trainer checks by asking two learners to read their codes aloud and explain the step 7 result.

Quiz

  1. Which way of serving a site does the project recommend for every stage? A. Apache with PHP-FPM B. nginx with PHP-FPM C. Velocity with the qbix engine D. PHP's built-in server
  2. What is the document root of an Exponential site?
  3. A request for /settings/site.ini returns the file's contents. What does that tell you?
  4. Name two reasons to choose Apache or nginx with PHP-FPM instead of Velocity.
  5. True or false: a .php file inside an extension's design directory runs when its path is requested.
Answers
  1. C. Chapter 8 calls Velocity's qbix engine the recommended way at every stage.
  2. The installation root, the directory that holds index.php (section 8.2).
  3. The routing rules are not active; fix the server before the site is reachable from outside.
  4. Any two of: hosting that forbids long-running processes, an existing tuned server, operating-system isolation between customers (section 8.1).
  5. False. Scripts and dot paths are never served or run below the root, even in a listed asset directory.

Further reading

Become an Exponential Partner

Partners share their information, provide funding, contribute back and develop the products with us, and that is how Exponential grows. A partner website and dashboard are planned for mid-2027: please become a partner today to speed up our growth rate and land new features faster.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x