Files
nginx-ubuntu/README.md
2025-11-28 14:05:35 +01:00

2.8 KiB
Raw Blame History

Nginx + PHP-FPM on Ubuntu 24.04

OS Shell WebServer PHP License

Automated Bash installer for Nginx + PHP-FPM on Ubuntu 24.04 Server.
Tuned for production, battle-ready, and built for people who like uptime more than debugging.

This isnt a “hello world” demo environment.
This script builds a real web server — hardened, structured, and ready to host more than one weekend project.


Why this installer exists

Because the default Nginx package leaves you with:

default site you immediately disable
configs scattered like confetti
wrong IPs when behind Cloudflare
no snippet structure
caching off, security minimal
weird defaults nobody asked for

This script fixes that:

✔ Creates /etc/nginx/nginx-snippets/
✔ Cloudflare Real-IP awareness
✔ Default virtualhost returns 444 instead of smiling politely
✔ Optional security snippets
✔ PHP-FPM pre-wired and ready

You deploy once — not fight it for half a day.


1. Prepare your system

sudo apt update -y

2. Download and enter the installer

git clone https://git.x-files.dk/webserver/nginx-ubuntu.git
cd nginx-ubuntu

3. Run the installer

sudo ./nginxinstall

After this runs, you have:

Feature Status
Nginx installed & enabled
PHP-FPM configured
Snippet structure created
Default website disabled ✓ (returns HTTP 444)
Cloudflare Real-IP support
Bad-bot blocking available
Custom error pages ✓ editable

Included Nginx Features

📁 /etc/nginx/nginx-snippets/

Reusable drop-in configs:

Snippet Purpose
cloudflare.conf Fixes real visitor IPs
block-bots.conf Drops garbage traffic
csp.conf Security headers
ssl.conf TLS configuration
errorpages/ Custom 40x/50x pages

Default IP response

Server IP access = 444 Drop.
Because your server is not public property.


Caching

Performance tuning examples included, commented until activated intentionally.


What happens after install?

Example vhost:

server {
    listen 443 ssl http2;
    server_name yourdomain.com;

    include nginx-snippets/cloudflare.conf;
    include nginx-snippets/block-bots.conf;

    root /var/www/yourproject;
    index index.php index.html;
}

More Information

More guides and documentation can be found on wiki.x-files.dk


License

Licensed under the MIT License.