wordpress: New app to manage a WordPress site/blog

- Use php-fpm instead of using mod-php.

- Create database and setup permissions manually. Tables and initial data are
created during the initial setup process done by WordPress. Database upgrades
are handled by WordPress. Minor versions are upgraded automatically and major
version need user intervention.

- Backup/restore functionality including database.

- Install recommended extensions for performance.

- Setup and run cron jobs to ensure that scheduled publications are
completed (among other things). Service has systemd security features. Timer is
set to run every 10 minutes.

- Functional tests for adding/removing posts and backup/restore.

- Increase file upload size limit to 128MiB.

- A private mode (default) for keeping the setup process secure. Should be
disabled after first setup is completed. This uses a new approach using
file-based flag for different Apache configurations.

TODO:

- Find a nice way to allow WordPress to upload plugins/themes. Currently this
operation files and users are expected to manually scp the files to
/var/lib/wordpress/wp-content/{plugins,themes} directory.

Tests:

- Functional tests.

- Schedule publishing of a post. Notice that post got published.

- Test uploading a file larger than 2MiB.

- Test enabling permalinks. This leads to nicer looking URLs.

- Test adding images to posts/pages.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa authored and James Valleroy committed 2021-08-25 08:20:01 -04:00
1 parent 5340cf3119
commit efa615201b
15 files changed
+729

No files matched your search

@@ -0,0 +1,56 @@
##
## On all sites, provide WordPress on a default path: /wordpress
##
## Requires the following Apache modules to be enabled:
## mod_alias
## mod_rewrite
## mod_proxy_fcgi
## mod_auth_pubtkt
##
# Match longer aliases first to meet expectations
Alias /wordpress/wp-content /var/lib/wordpress/wp-content
Alias /wordpress /usr/share/wordpress
<Directory /usr/share/wordpress>
Options FollowSymLinks
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /wordpress/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /wordpress/index.php [L]
</IfModule>
# Allow access only if site is marked as public or if user is an admin
<IfFile !/etc/wordpress/is_public>
Include includes/freedombox-single-sign-on.conf
<IfModule mod_auth_pubtkt.c>
TKTAuthToken "admin"
</IfModule>
</IfFile>
# Increase maximum upload file size
<IfModule proxy_fcgi_module>
ProxyFCGISetEnvIf true PHP_VALUE "post_max_size=128M \n upload_max_filesize = 128M"
</IfModule>
</Directory>
<Directory /var/lib/wordpress/wp-content>
Options FollowSymLinks
# Allow access only if site is marked as public or if user is an admin
<IfFile !/etc/wordpress/is_public>
Include includes/freedombox-single-sign-on.conf
<IfModule mod_auth_pubtkt.c>
TKTAuthToken "admin"
</IfModule>
</IfFile>
<IfFile /etc/wordpress/is_public>
Require all granted
</IfFile>
</Directory>
@@ -0,0 +1 @@
plinth.modules.wordpress
@@ -0,0 +1,37 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
[Unit]
Description=WordPress Scheduled Events Trigger (Cron)
Documentation=https://rtcamp.com/tutorials/wordpress/wp-cron-crontab/
[Service]
CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SETUID CAP_SETGID CAP_SETPCAP CAP_CHOWN CAP_FSETID CAP_SETFCAP CAP_DAC_OVERRIDE CAP_DAC_READ_SEARCH CAP_FOWNER CAP_IPC_OWNER CAP_NET_ADMIN CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE CAP_KILL CAP_NET_BIND_SERVICE CAP_NET_RAW CAP_LINUX_IMMUTABLE CAP_IPC_LOCK CAP_SYS_CHROOT CAP_BLOCK_SUSPEND CAP_LEASE CAP_SYS_PACCT CAP_SYS_TTY_CONFIG CAP_SYS_BOOT CAP_MAC_ADMIN CAP_MAC_OVERRIDE CAP_SYS_NICE CAP_SYS_RESOURCE
DevicePolicy=closed
ExecStart=php --file /usr/share/wordpress/wp-cron.php
Group=www-data
LockPersonality=yes
NoNewPrivileges=yes
PrivateDevices=yes
PrivateMounts=yes
PrivateTmp=yes
PrivateUsers=yes
ProtectControlGroups=yes
ProtectClock=yes
ProtectHome=yes
ProtectHostname=yes
ProtectKernelLogs=yes
ProtectKernelModules=yes
ProtectKernelTunables=yes
ProtectSystem=strict
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
RestrictNamespaces=yes
RestrictRealtime=yes
RestrictSUIDSGID=yes
StateDirectory=wordpress/wp-content
SystemCallArchitectures=native
SystemCallFilter=@system-service
SystemCallFilter=~@resources
SystemCallFilter=~@privileged
SystemCallErrorNumber=EPERM
Type=simple
User=www-data
@@ -0,0 +1,11 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
[Unit]
Description=WordPress Scheduled Events Trigger (Cron) Timer
Documentation=https://rtcamp.com/tutorials/wordpress/wp-cron-crontab/
[Timer]
OnCalendar=*:0/10
[Install]
WantedBy=timers.target