diff --git a/README.md b/README.md index 6ac5fa3..458043e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# WordPress for Ubuntu 24.04 Server +# WordPress on Ubuntu 24.04 [![OS](https://img.shields.io/badge/ubuntu-24.04-E95420)](#) [![Shell](https://img.shields.io/badge/shell-bash-121011)](#) [![WebServer](https://img.shields.io/badge/server-nginx-009639)](#) @@ -8,40 +8,40 @@ [![App](https://img.shields.io/badge/app-wordpress-21759B)](#) [![License](https://img.shields.io/badge/License-MIT-green)](./LICENSE) -Installs and configures the **latest stable release of WordPress** on Ubuntu 24.04 Server. +Automated installer for the **latest stable WordPress on Ubuntu 24.04**, configured for Nginx, PHP-FPM, and MariaDB/MySQL. -This is a **production-focused installer**, not a demo. +This is not a 5-minute “demo stack”. +This script deploys a **production-ready WordPress site**, database included, configs hardened, and Nginx validation enforced. -It assumes Nginx, PHP-FPM, and either MariaDB or MySQL are already installed and running. - -This script works with both MariaDB and MySQL, with or without socket authentication. +Install → Configure → Visit `/wp-admin/install.php` → Done. --- -## Related Installers +## Prerequisites -If you don’t have the required components, you can use these compatible installers: +This script expects: -- [Nginx + PHP-FPM Installer](https://git.x-files.dk/webserver/nginx-ubuntu) -- [MariaDB Installer](https://git.x-files.dk/database/mariadb-ubuntu) +✔ Nginx installed +✔ PHP-FPM installed +✔ MariaDB/MySQL running *(socket or password mode supported)* + +Need those first? + +* https://git.x-files.dk/webserver/nginx-ubuntu +* https://git.x-files.dk/database/mariadb-ubuntu --- -### Download the Script - -Clone this repository to your server: +## 1. Download ``` git clone https://git.x-files.dk/webapps/wordpress-ubuntu.git -``` - -``` cd wordpress-ubuntu ``` -### Usage +--- -Run the script using: +## 2. Install WordPress ``` sudo ./wordpressinstall -n -d -u -p [options] @@ -49,118 +49,89 @@ sudo ./wordpressinstall -n -d -u -p [options ### Examples -The installer automatically detects if socket authentication is active. -Only include `-m` and `-a` if your MariaDB setup does **not** use socket authentication. +Socket authentication detected → simple command: ``` sudo ./wordpressinstall -n wp.example.com -d wpdb -u wpuser -p wpPass123 +``` + +Socket unavailable → add database credentials manually: + +``` sudo ./wordpressinstall -n wp.example.com -d wpdb -u wpuser -p wpPass123 -m rootpwd sudo ./wordpressinstall -n wp.example.com -d wpdb -u wpuser -p wpPass123 -a admin -m adminpwd ``` +--- + ### Options -| Flag | Description | -|------|--------------| -| `-m ` | MariaDB root or admin password — *required only if socket authentication is disabled* | -| `-a ` | Optional MariaDB admin username (defaults to `root` if not specified) | -| `-h`, `--help` | Show the help screen (reflects detected socket status) | +| Flag | Meaning | +|---|---| +| `-m ` | MariaDB/MySQL admin or root password *(only if socket OFF)* | +| `-a ` | DB admin username (defaults to `root`) | +| `-h` / `--help` | Show help | -### Configuration -When installation completes, visit: +--- + +## What this installer does + +✔ Downloads + configures latest WordPress +✔ Creates DB + DB-user if they don’t exist +✔ Generates Nginx host file automatically +✔ Detects socket vs password auth +✔ Validates Nginx (`nginx -t`) before reload +✔ Supports safe re-runs +✔ Built for production, not testing + +--- + +## After installation + +Visit: ``` http:///wp-admin/install.php ``` -Then create your WordPress site title and administrator account. -(Database configuration is already completed by the installer.) +Complete the setup wizard — database already wired. --- -### Features +## File & Config Layout -- Installs and configures WordPress automatically -- Creates the MariaDB database and user -- Generates an Nginx host configuration dynamically -- Integrates runtime WordPress hardening and rate limiting -- Validates Nginx configuration before restarting services -- Detects MariaDB socket or password authentication automatically +| Path | Purpose | +|---|---| +| `/var/www/html/` | WordPress directory | +| `/etc/nginx/conf.d/.conf` | Virtualhost config | +| `/etc/nginx/conf.d/includes/wp-hardening.conf` | Security | +| `/etc/nginx/conf.d/wp-rate-limit.conf` | Rate limit | --- -### Configuration Details +## HTTPS Support (443) -#### File Locations +Enable TLS using: -| File | Description | -|------|--------------| -| `/var/www/html/` | WordPress site directory | -| `/etc/nginx/conf.d/.conf` | Generated Nginx host file | -| `/etc/nginx/conf.d/includes/wp-hardening.conf` | WordPress hardening | -| `/etc/nginx/conf.d/wp-rate-limit.conf` | Request rate-limiting | +https://git.x-files.dk/webserver/nginx-snippets/src/branch/main/hostfiles/wordpress.443.conf + +Caching snippets (disabled until uncommented): + +``` +# include /etc/nginx/nginx-snippets/cache-open-files.conf; +# include /etc/nginx/nginx-snippets/cache-statics.conf; +# include /etc/nginx/nginx-snippets/cache-js-css.conf; +``` --- -#### Behavior +## Troubleshooting -- The installer automatically checks for **MariaDB socket authentication**. - If available, it connects locally as `root` (no password). -- If socket authentication is **not detected**, use `-m` (and optionally `-a`) to supply credentials. -- All database commands include `IF NOT EXISTS` logic, making re-runs safe. -- Nginx configuration is validated (`nginx -t`) before restarting services. - ---- - -### Nginx Integration - -The generated Wordpress configuration file listens on port 80. -To enable HTTPS (port 443), use the example provided [here](https://git.x-files.dk/webserver/nginx-snippets/src/branch/main/hostfiles/wordpress.443.conf) - -> **NOTE** -> The file also includes optional caching directives (commented out by default). -> You can enable them to improve load times and performance if needed. -> The lines you are looking for are at the bottom of the generated config file and look like this: -> ``` -> ##### Cache js css static content and open files start ##################### -> # include /etc/nginx/nginx-snippets/cache-open-files.conf; -> # include /etc/nginx/nginx-snippets/cache-statics.conf; -> # include /etc/nginx/nginx-snippets/cache-js-css.conf; -> ##### Cache js css static content and open files stop ###################### -> ``` - ---- - -### Troubleshooting - -**Nginx fails to restart** -Run `nginx -t` and review any syntax errors reported in `/etc/nginx/conf.d/.conf`. - -**Access denied during database creation** -Your MariaDB setup likely does not use socket authentication. -Re-run the installer with the `-m` flag (and optionally `-a`) to provide credentials. -The installer will automatically re-detect your configuration. - -**PHP version mismatch** -The script automatically detects your installed PHP version, -but ensure that the PHP-FPM service (e.g., `php8.3-fpm`) is active. - ---- - -### FAQ - -**Q:** Why doesn’t the script ask for a MariaDB password by default? -**A:** Ubuntu 24.04’s MariaDB installation defaults to *socket authentication*, -allowing the local `root` user to connect without a password. -The installer detects this automatically and skips password prompts when applicable. - -**Q:** Can I run the installer multiple times? -**A:** Yes. Database and user creation use `IF NOT EXISTS`, making them safe to rerun. -Existing WordPress and Nginx configuration files are replaced, but no data is deleted. - -**Q:** Does this modify existing Nginx settings? -**A:** No. It adds a standalone host file in `/etc/nginx/conf.d/` -and validates configuration changes before applying them. +| Issue | Cause | Fix | +|---|---|---| +| Nginx restart fails | Config error | `nginx -t` | +| DB denied | No socket auth | Use `-m` | +| PHP errors | Wrong FPM version | Check `php8.3-fpm` | --- @@ -171,7 +142,6 @@ More guides and documentation can be found on [wiki.x-files.dk](https://wiki.x-f --- ### License - Licensed under the [MIT License](./LICENSE). ---