### Run PHP-FPM Integration Examples
Source: https://ramaproxy.org/book/gateway/fastcgi.html
Commands to install necessary dependencies and execute the FastCGI PHP gateway and migration demos.
```bash
# install dependencies (Debian/Ubuntu)
apt-get install -y php-fpm jq curl
# run either or both
just example-fastcgi-php-gateway
just example-fastcgi-php-migration
just test-fastcgi-php # both, sequentially
```
--------------------------------
### Install Rama CLI via Package Managers
Source: https://ramaproxy.org/book/deploy/rama-cli.html
Install the binary using Homebrew on MacOS or Winget on Windows.
```bash
brew install plabayo/rama/rama
```
```bash
winget install Plabayo.Rama
```
--------------------------------
### Run FastCGI Reverse Proxy Example
Source: https://ramaproxy.org/book/gateway/fastcgi.html
Executes the self-contained reverse proxy example and verifies it with a curl request.
```bash
cargo run --example fastcgi_reverse_proxy --features=http-full,fastcgi
curl -v http://127.0.0.1:62053/hello?foo=bar
```
--------------------------------
### Install Rama CLI via Script
Source: https://ramaproxy.org/book/deploy/rama-cli.html
Download and install the CLI using shell scripts with support for version pinning and pre-releases.
```bash
curl https://raw.githubusercontent.com/plabayo/rama/main/rama-cli/scripts/install.sh | bash
```
```bash
wget -qO- https://raw.githubusercontent.com/plabayo/rama/main/rama-cli/scripts/install.sh | bash
```
```bash
curl https://raw.githubusercontent.com/plabayo/rama/main/rama-cli/scripts/install.sh | bash -s -- --pre
curl https://raw.githubusercontent.com/plabayo/rama/main/rama-cli/scripts/install.sh | bash -s -- --version 0.3.0
```
--------------------------------
### Run XPC CA Exchange Example
Source: https://ramaproxy.org/book/xpc.html
Executes the CA exchange example, modeling a client requesting CA material over XPC request/reply.
```bash
cargo run --example xpc_ca_exchange --features=net-apple-xpc
```
--------------------------------
### Run XPC Echo Example
Source: https://ramaproxy.org/book/xpc.html
Executes the self-contained XPC echo example to demonstrate fire-and-forget, request-reply, and connection shutdown patterns.
```bash
cargo run --example xpc_echo --features=net-apple-xpc
```
--------------------------------
### Install Rama CLI via Cargo
Source: https://ramaproxy.org/book/deploy/rama-cli.html
Install the CLI tool from source or using pre-built binaries via cargo binstall.
```bash
cargo install rama-cli@0.3.0
```
```bash
cargo binstall rama-cli@0.3.0
```
--------------------------------
### HTTP Chunked Transfer Example
Source: https://ramaproxy.org/book/http/declarative_partial_updates.html
A conceptual representation of how the server streams the HTML shell followed by individual fragment chunks.
```http
__
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
-- chunk 1: the shell with placeholders, flushed immediately
-- chunk 2: … (200ms later)
-- chunk 3: … (900ms later)
-- chunk 4: … (1500ms later)
```
--------------------------------
### HTTP/1.1 WebSocket Upgrade Request
Source: https://ramaproxy.org/book/http/ws.html
Initial GET request sent by a client to initiate a WebSocket upgrade over HTTP/1.1.
```http
GET / HTTP/1.1
Host: example.com
Connection: upgrade
Upgrade: websocket
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==
```
--------------------------------
### Example SSE frame
Source: https://ramaproxy.org/book/http/sse.html
A standard SSE message format containing an ID, event name, and JSON data payload.
```text
__
id: 42
event: update
data: {"status":"ok"}
```
--------------------------------
### Display Rama CLI help
Source: https://ramaproxy.org/book/deploy/rama-cli.html
Access the help menu for the rama binary.
```bash
rama --help
```
--------------------------------
### Build and run Rama binary
Source: https://ramaproxy.org/book/deploy/overview.html
Standard commands to compile a release build and execute the resulting binary on a server or VM.
```bash
cargo build --release .
cargo run ./target/release/
```
--------------------------------
### Connect to php-fpm via TCP
Source: https://ramaproxy.org/book/gateway/fastcgi.html
Initializes a FastCGI HTTP client using a TCP connector configured for a php-fpm backend.
```rust
use rama::gateway::fastcgi::{FastCgiHttpClient, FastCgiTcpConnector};
// php-fpm at 127.0.0.1:9000, front controller at /var/www/index.php
let client = FastCgiHttpClient::new(FastCgiTcpConnector::php_fpm(
"127.0.0.1:9000".parse()?,
"/var/www/index.php",
));
```
--------------------------------
### Connect to php-fpm via Unix socket
Source: https://ramaproxy.org/book/gateway/fastcgi.html
Initializes a FastCGI HTTP client using a Unix socket connector for php-fpm, available on Unix-family targets.
```rust
use rama::gateway::fastcgi::{FastCgiHttpClient, FastCgiUnixConnector};
let client = FastCgiHttpClient::new(FastCgiUnixConnector::php_fpm(
"/run/php/php8.3-fpm.sock",
"/var/www/index.php",
));
```
--------------------------------
### Run Rama CLI via Docker
Source: https://ramaproxy.org/book/deploy/rama-cli.html
Pull and execute the Rama CLI tool using a Docker container.
```bash
docker pull glendc/rama:latest
docker run --rm glendc/rama:latest example.com
```
--------------------------------
### Provision a Postgres database with Shuttle
Source: https://ramaproxy.org/book/deploy/shuttle.html
Uses the shuttle_shared_db macro to automatically provision a Postgres database and provide an authenticated connection pool.
```rust
#[shuttle_runtime::main]
async fn main(
// Automatically provisions a Postgres database
// and provides an authenticated connection pool
#[shuttle_shared_db::Postgres] pool: sqlx::PgPool,
) -> Result {
// Application code
}
```
--------------------------------
### Service serve method signature
Source: https://ramaproxy.org/book/intro/state.html
The signature for the serve method in a Rama service, which handles requests and returns a future.
```rust
fn serve(
&self,
req: Request,
) -> impl Future