This guide installs a minimal ClassicPress stack with Apache, PHP, and MariaDB.
It supports Debian 10 to latest stable, Ubuntu LTS, and RHEL 9+ compatible systems.
- name: Install ClassicPress
hosts: classicpress
become: true
vars:
classicpress_version: "2.2.0"
classicpress_webroot: /var/www/classicpress
classicpress_db_name: classicpress
classicpress_db_user: classicpress
classicpress_db_password: change_me_now
tasks:
- name: Install dependencies on Debian/Ubuntu
apt:
name:
- apache2
- mariadb-server
- php
- php-mysql
- php-gd
- php-xml
- php-mbstring
- php-curl
- php-zip
- unzip
- wget
- curl
state: present
update_cache: true
when: ansible_os_family == "Debian"
- name: Install dependencies on RHEL family
dnf:
name:
- httpd
- mariadb-server
- php
- php-mysqlnd
- php-gd
- php-xml
- php-mbstring
- php-curl
- php-zip
- unzip
- wget
state: present
when: ansible_os_family == "RedHat"
- name: Ensure web and database services are enabled and started
service:
name: "{{ item }}"
state: started
enabled: true
loop:
- "{{ 'apache2' if ansible_os_family == 'Debian' else 'httpd' }}"
- mariadb
- name: Create ClassicPress web root
file:
path: "{{ classicpress_webroot }}"
state: directory
mode: "0755"
- name: Download ClassicPress release archive
get_url:
url: "https://github.com/ClassicPress/ClassicPress-release/archive/refs/tags/{{ classicpress_version }}.zip"
dest: /tmp/classicpress.zip
mode: "0644"
- name: Extract ClassicPress
unarchive:
src: /tmp/classicpress.zip
dest: /tmp
remote_src: true
- name: Sync ClassicPress files into web root
shell: |
set -euo pipefail
src_dir="$(find /tmp -maxdepth 2 -type d -name 'ClassicPress-release-*' | head -n1)"
rsync -a --delete "$src_dir"/ "{{ classicpress_webroot }}/"
args:
executable: /bin/bash
- name: Set ownership for web root
file:
path: "{{ classicpress_webroot }}"
state: directory
recurse: true
owner: "{{ 'www-data' if ansible_os_family == 'Debian' else 'apache' }}"
group: "{{ 'www-data' if ansible_os_family == 'Debian' else 'apache' }}"
Beyond this playbook, we offer:
Contact our automation team: office@linux-server-admin.com