Files

164 lines
4.1 KiB
Markdown
Raw Permalink Normal View History

2025-12-19 15:40:50 +01:00
# WordPress for 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)](#)
[![PHP](https://img.shields.io/badge/php-fpm-777BB4)](#)
[![MariaDB](https://img.shields.io/badge/db-mariadb-003545)](#)
[![MySQL](https://img.shields.io/badge/db-mysql-4479A1)](#)
[![App](https://img.shields.io/badge/app-wordpress-21759B)](#)
[![License](https://img.shields.io/badge/License-MIT-green)](./LICENSE)
Install WordPress on Ubuntu 24.04 server.
This is not a demo and not an experiment.
A production-focused installer — correct permissions, prepared DB, no web-based setup guessing.
## Why this installer exists
Most WordPress guides leave insecure permissions, unclear DB setup and missing caching. This avoids all three.
## What this installer does
✔ Downloads the latest WordPress release
✔ Creates database + user automatically
✔ Generates validated Nginx host config
✔ Socket or password authentication supported
✔ Safe to re-run without data loss
## What this installer does *NOT* do
It wont stop you from running the script without reading the documentation like theres no tomorrow.
Skip the README, and whatever happens next is your headache, not a bug report.
---
## Prerequisites
This script expects:
✔ Nginx installed
✔ PHP-FPM installed
✔ MariaDB/MySQL running *(socket or password mode supported)*
### Optional Installers (if you need them — saves you some googling)
- [Install Nginx + PHP-FPM on Ubuntu](https://git.x-files.dk/webserver/nginx-ubuntu)
- [Install MariaDB on Ubuntu](https://git.x-files.dk/database/mariadb-ubuntu)
- [Install MySQL on Ubuntu](https://git.x-files.dk/database/mysql-ubuntu)
---
## 1. Download
```
git clone https://git.x-files.dk/webapps/wordpress-ubuntu.git
```
```
cd wordpress-ubuntu
```
---
## 2. Install WordPress
```
sudo ./wordpressinstall -n <domain> -d <dbname> -u <dbuser> -p <dbpass> [options]
```
### Examples
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 | Meaning |
|---|---|
| `-m <password>` | MariaDB/MySQL admin or root password *(only if socket OFF)* |
| `-a <username>` | DB admin username (defaults to `root`) |
| `-h` / `--help` | Show help |
---
## What this installer does
✔ Downloads + configures latest WordPress
✔ Creates DB + DB-user if they dont 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://<domain>/wp-admin/install.php
```
Complete the setup wizard — database already wired.
---
## File & Config Layout
| Path | Purpose |
|---|---|
| `/var/www/html/<domain>` | WordPress directory |
| `/etc/nginx/conf.d/<domain>.conf` | Virtualhost config |
| `/etc/nginx/conf.d/includes/wp-hardening.conf` | Security |
| `/etc/nginx/conf.d/wp-rate-limit.conf` | Rate limit |
---
## HTTPS Support (443)
Enable TLS using:
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;
```
---
## Troubleshooting
| 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` |
---
### More Information
More guides and documentation can be found on [wiki.x-files.dk](https://wiki.x-files.dk)
---
### License
Licensed under the [MIT License](./LICENSE).
---