iTranslated by AI
What to do with .htaccess if Apache development stops?
What if Apache Development Stops?
💚Zundamon
Huh! Is it true that Apache might not be developed anymore!? What's going to happen to my .htaccess?!
🎀Metan
That's right. While the Apache HTTP Server project is still being maintained, we're not seeing active feature expansion or HTTP/3 implementation, and a stagnation in development has been pointed out.
🗡️Tsurugi
Configurations depending on .htaccess in particular are difficult to migrate due to Apache's unique design. Thus, countermeasures for shared hosting providers are being discussed.
💚Zundamon
You mean if I switch to another server, I can't use .htaccess anymore?
🎀Metan
Basically, yes. Other major HTTP servers like nginx and Caddy do not support .htaccess. The design of reading configuration files for each directory sequentially is avoided for performance and security reasons.
🗡️Tsurugi
Furthermore, while Apache's .htaccess is convenient, it's complex and carries risks of unintended behavior or security vulnerabilities. Re-implementing this is highly difficult.
💚Zundamon
Then what should I do!? Will my WordPress site still work without Apache?!
🎀Metan
Possible countermeasures for shared hosting providers include:
-
Using nginx/Caddy as a reverse proxy for Apache
A stopgap measure where nginx/Caddy handles static files and TLS while keeping Apache in the backend. -
Providing CMS-specific preset configuration files
For example, providing nginx configuration snippets for WordPress or Drupal so users can choose an alternative to.htaccess. -
Migrating to LiteSpeed
LiteSpeed Web Server can independently parse and process.htaccess. This is because LiteSpeed's PHP SAPI (LSAPI) is under the umbrella of the PHP project itself and claims Apache compatibility. -
Developing a relay FPM for php-fpm
This is a bold approach: designing an FPM (FastCGI Process Manager) that has its own.htaccessprocessing logic.
🗡️Tsurugi
However, none of these options are easy. Achieving full compatibility with .htaccess is particularly challenging. Excluding commercial solutions like LiteSpeed, the question remains: who will shoulder that burden?
💚Zundamon
So, the number of people making Apache is decreasing...?
🎀Metan
Yes. Many OSS projects, including Apache, are facing aging maintainers and talent shortages. There's also the history of nginx developers launching "FreeNginx" due to commercialization issues; relying on individuals has its limits.
🗡️Tsurugi
Because of this, there's a growing movement in the European Union to support open source as a matter of public policy. In the long term, we need institutional designs that guarantee the sustainability of OSS.
💚Zundamon
Huh... .htaccess seems convenient, but relying too much on Apache might put the future in a pinch!
🎀Metan
Exactly. Moving forward, striving for designs that don't depend on .htaccess will be the key to sustainable web development.
🗡️Tsurugi
Look to the future with honor. Selecting technology is an act that supports not only your own site but also the users and developers who walk with you.
Developing a Relay FPM for php-fpm in Rust
💚Zundamon
Huh!? "A FastCGI that pretends to be FastCGI to pass to FastCGI"? What is that!?
The structure makes no sense to me!
🎀Metan
Simply put, a service program created in Rust "pretends to be a temporary PHP execution manager." It acts as a proxy that delegates the actual execution to the real php-fpm.
🗡️Tsurugi
In other words, this Rust service performs these three roles:
-
Behaves as a FastCGI application (= receives requests from the web server)
-
Parses
.htaccessand handles URL rewriting, restrictions, and environment variable control -
Finally, forwards the request to php-fpm via the FastCGI protocol and returns the result to the web server (intermediary)
💚Zundamon
Huh, so .htaccess rewrites and Redirect can work even without Apache?!
🎀Metan
Yes, by reading .htaccess on the Rust side, rules like this:
RewriteEngine On
RewriteRule ^old$ new.php [L]
...will be interpreted by the Rust side, which will then construct a FastCGI request for new.php and send it to php-fpm.
🗡️Tsurugi
I've summarized the characteristics of this method in a table:
| Item | Rust FastCGI Manager (Relay type) |
|---|---|
| Connection with Web Server | Acts as a FastCGI listener (e.g., Unix socket) |
.htaccess Processing |
Independently parses and evaluates to reflect in internal logic |
| Execution of PHP Scripts | Proxy-sends requests to php-fpm (FastCGI client) |
| Use Cases | Shared hosting environments or CMS dependent on .htaccess
|
| Pros |
.htaccess works (to some extent) without Apache |
| Cons | Specifications tend to be complex; limits to reproducibility |
💚Zundamon
This is smarter than a normal FPM! But being a server that speaks FastCGI while also being a client makes my brain glitch!
🎀Metan
The mechanism looks like this:
[Web Server]
↓ FastCGI
[Rust Relay FPM]
↓ FastCGI
[php-fpm (Official)]
On the Rust side, it receives requests from the web server as a FastCGI server, processes the .htaccess rules, and then throws a request to php-fpm as a FastCGI client internally.
🗡️Tsurugi
The samurai-like beauty of this configuration lies in its flexibility: "maintaining apparent Apache compatibility while entrusting only the core responsibilities to php-fpm."
🎀Metan
However, things to watch out for are:
-
mod_rewritespecifications are complex and difficult to fully reproduce. -
Unlike Apache, you need to self-implement things like
.htaccesshierarchical inheritance andAllowOverride. -
Careful design regarding security and root detection is required.
💚Zundamon
It sounds super tough, but a "Relay FPM" sounds like a character from a spy movie!
🗡️Tsurugi
Acting as a "fake Shogun" while opening the path for the true powerhouse... truly a master strategist behind the scenes.
HTTP Server Development Status with Rust
💚Zundamon
Can Rust be used for web server development too?
🎀Metan
Of course. Since Rust balances performance and safety, it is very suitable for rebuilding HTTP servers. It's particularly well-suited for things like .htaccess configuration parsers and middleware design.
🎀Metan
First, let's briefly organize the main Rust library options:
✅ Main HTTP Server Libraries Available in Rust
| Library | Features |
|---|---|
hyper |
Supports asynchronous. Runs on Tokio. HTTP/1/2 support available. |
axum |
Router-type based on hyper + tower. Aimed at web frameworks. |
actix-web |
Built on the actix actor model. Parallel processing is extremely fast. |
warp |
Based on hyper. Can be written in a functional style. |
Ferron |
An emerging project. Features a unique design supporting both PHP (php-fpm) and Python (ASGI/WSGI). |
quiche |
Cloudflare's QUIC library. A key part of HTTP/3 implementation. |
s2n-quic |
AWS's QUIC implementation. Characterized by enhanced TLS security. |
💚Zundamon
Cloudflare's name popped up! Come to think of it, Cloudflare builds things like HTTP/3 and QUIC themselves, don't they!?
🎀Metan
That's right. Cloudflare developed quiche as its own HTTP/3 implementation, optimizing it for high-traffic use cases that NGINX couldn't fully handle. And Cloudflare Server boasts a high market share among HTTP servers, ranking near the top alongside Apache and Nginx according to W3Techs statistics.
🗡️Tsurugi
Cloudflare is no longer just a "CDN provider," but is at the forefront of Rust-based network stack development. quiche is one of the most important reference implementations for Rust + HTTP/3.
💚Zundamon
But I want to use both PHP and Python! Is there a server that supports both?
🎀Metan
That would be Ferron, which appeared recently. Ferron aims for a configuration that can handle ASGI / WSGI (Python) and php-fpm (PHP) at the same time, which is surprisingly rare elsewhere.
🗡️Tsurugi
While there are Uvicorn for Python and Caddy / Nginx for PHP among existing HTTP servers, it is rare for a single web server to "officially support" both.
💚Zundamon
Whoa! Ferron has so much potential!
🔍 Summary: Perspectives on Rust HTTP Server Selection
| Perspective | Points to Note |
|---|---|
| Performance |
hyper, actix-web, quiche, etc., are strong candidates. |
| Versatility (Backend) | Multi-language support like Ferron's will be noteworthy in the future. |
| HTTP/3/QUIC |
quiche and s2n-quic are at the forefront. |
| .htaccess-equivalent Control | Needs to be designed from scratch on the Rust side (e.g., rebuilding mod_rewrite). |
| Security / Maintainability | Rust's safety design is an advantage. However, the ecosystem is still being built. |
🎀Metan
If we were to create a successor to .htaccess or Apache in Rust, how to combine existing Rust libraries would be a major design challenge.
🗡️Tsurugi
Identify the features you truly want to protect. Beyond that, the determination to "build one's own server by oneself" like Cloudflare will shape the infrastructure of the next generation.
Reviewing Apache's MPM (Multi-Processing Module)
💚Zundamon
Huh! What's this "MPM" in Apache? Is it like Monster Power or something?
🎀Metan
No, Zundamon. "MPM (Multi-Processing Module)" is the processing model that determines how Apache handles requests. Apache has several MPMs:
✅ Comparison of Major Apache MPMs
| MPM Name | Model | Features |
|---|---|---|
prefork |
Process-based | Processes each request in an independent process. No thread support. |
worker |
Thread-based | Each process has multiple threads. Memory efficient. |
event |
Asynchronous | Similar to worker, but can manage KeepAlive connections asynchronously. Suitable for HTTP/1.1. |
🗡️Tsurugi
In short, they are all tactics for "how Apache responds to client requests." The oldest and safest is prefork, while the flow leads toward event as the most modern design.
💚Zundamon
But which one should I use when running PHP?
🎀Metan
That's the tricky part. The optimal MPM changes depending on the combination with the PHP execution method (SAPI).
✅ Apache × PHP: Combination Options
| PHP Execution Method | Recommended MPM | Notes |
|---|---|---|
mod_php (Embedded in Apache) |
prefork |
mod_php often doesn't support threads (no ZTS), so it's unstable with thread-based MPMs. |
php-fpm (External FastCGI process) |
worker / event |
Since PHP runs in a separate process, Apache can use high-speed thread-based MPMs. |
mod_http2 (HTTP/2 Support) |
event |
Strong at asynchronous KeepAlive and multiplexing; ideal for HTTP/2. mod_php is not recommended. |
🗡️Tsurugi
So, if you want to use mod_php, go with prefork. If you want high efficiency with HTTP/2 or thread types, you should choose php-fpm.
🎀Metan
By the way, mod_http2 and mod_php are said to be incompatible. This is because the multi-threaded design of HTTP/2 conflicts with the non-threaded design of mod_php.
💚Zundamon
But you know, sometimes people say PHP is "leaking memory!" and tell you to restart Apache. Why does that happen?
🎀Metan
Good question. Regarding that, there's a famous joke from the creator of PHP, Rasmus Lerdorf:
"If you are running PHP scripts, you should restart Apache every 10 requests."
— Rasmus Lerdorf (half-joking)
🗡️Tsurugi
The true meaning behind these words is that "PHP's design is not suited for long-running processes." With extensions that don't fully release memory and code that tends to hold state, it paired well with short-lived process models (prefork type).
🎀Metan
However, nowadays, stability has improved through more flexible regeneration of processes and workers.
✅ "Restart" or "Regeneration" Strategies for Each Server
| Server | Operational Strategy |
|---|---|
Apache (prefork) |
Regenerates child processes based on request count. Periodic restarts depending on config. |
Apache (event) |
Maintains worker count while reusing threads based on KeepAlive time. |
| php-fpm | Regenerates workers when max_requests is reached. A countermeasure for long-lived processes. |
| nginx + php-fpm | nginx is lightweight/asynchronous. Restarts are controlled by pm.max_requests on the php-fpm side. |
| LiteSpeed | Maintains .htaccess compatibility while efficiently regenerating processes internally. |
💚Zundamon
I see! So even when you say "restart," it's not like everything goes down at once, but more like a "gradual hand-over"!
🎀Metan
Exactly. This is a strategy called "process rotation," a modern operational method that achieves both crash prevention and memory cleanup.
🗡️Tsurugi
My conclusion is this:
🗡️ "The era of depending on .htaccess is ending. But the philosophy of process management still holds true today."
What are Processes, Threads, and Workers?
💚Zundamon
Huh!? "Process," "thread," and "worker" keep coming up in talks about Apache—what's the difference? They all sound like they're just working...
🎀Metan
Good question. Let's start with some rough definitions.
✅ What are Processes, Threads, and Workers?
| Term | Description |
|---|---|
| Process | A single independent program running on the OS. |
| Thread | A small unit of execution running concurrently within a process. Shares the same memory space. |
| Worker | An Apache term for "the entity (process or thread) that handles a request." Its meaning changes depending on the MPM. |
| n* * * |
🗡️Tsurugi
In other words, the relationship is like "Process" = General, "Thread" = Vassal. Workers are the soldiers fighting on each battlefield, and their form changes based on their deployment.
💚Zundamon
I see...! So a worker is "the actual thing doing the processing"!
✅ Differences by MPM (Conceptual Diagram)
[MPM: prefork]
┌─────────────┐
│ Master │
├─────────────┤
│ Worker Proc 1│ ← 1 request = 1 process
│ Worker Proc 2│
│ Worker Proc 3│
└─────────────┘
[MPM: worker]
┌─────────────┐
│ Master │
├─────────────┤
│ Proc 1 │
│ ├ Thread 1 │ ← 1 request = 1 thread
│ └ Thread 2 │
│ Proc 2 │
│ ├ Thread 1 │
│ └ Thread 2 │
└─────────────┘
[MPM: event]
┌─────────────┐
│ Master │
├─────────────┤
│ Proc │
│ ├ Thread 1 │
│ ├ Thread 2 │ ← Includes asynchronous processing for KeepAlive connections
└─────────────┘
🎀Metan
While the prefork structure is simpler, it consumes more memory. worker and event offer superior performance.
✅ Checking in Bash! Apache Process and Thread Counts
# Apache processes (parent + children)
ps aux | grep apache2 | grep -v grep
# Parent process PID (Ubuntu/Debian-based)
pgrep -o apache2
# Check the number of child processes (e.g., many in Prefork mode)
pgrep apache2 | wc -l
🗡️Tsurugi
When I kept watch, I saw numerous Apache processes lined up in prefork mode. Meanwhile, in worker or event mode, a small number of processes were handling many threads.
✅ Experiencing Processes and Threads in PHP
<?php
// Display Process ID (PID)
echo "Process ID: " . getmypid() . "\n";
// Generate one child process (UNIX only)
if (function_exists('pcntl_fork')) {
$pid = pcntl_fork();
if ($pid == -1) {
die("Fork failed\n");
} elseif ($pid) {
echo "Parent process (PID: " . getmypid() . ") is running\n";
} else {
echo "Child process (PID: " . getmypid() . ") was generated\n";
exit(0);
}
}
?>
💚Zundamon
Huh!? By using getmypid(), you can see the process even in PHP! And with pcntl_fork(), you can perform the "art of cloning" (splitting) too!
🎀Metan
In actual operation, Apache responds to requests by automatically generating these clones (processes or threads).
🗡️Tsurugi
Restarts and memory releases are also handled through the regeneration of these "soldiers (workers)." They are swapped out according to the situation to maintain the front line.
✅ Review Summary
| Item | Content |
|---|---|
| Process | An independent execution unit. Used heavily by prefork. |
| Thread | A lightweight parallel execution unit. Utilized in worker/event. |
| Worker | The entity that handles requests. Can be either a process or a thread. |
| How to check in PHP | Can be learned via getmypid(), pcntl_fork(), etc. |
| Operational strategy | Unstable workers are rotated via automatic regeneration. |
🎀Metan
Understanding these basics provides a design guide for what kind of parallel model to use if you ever redesign Apache in Rust.
🗡️Tsurugi
Observe the characteristics of your troops (processes/threads) and deploy the optimal formation. That is the essence of server management.
Discussion