From 709dddd8e3a7d1c49d580f32156a70138eb046e1 Mon Sep 17 00:00:00 2001 From: allan Date: Thu, 23 Oct 2025 15:43:13 +0200 Subject: [PATCH] initial commit --- LICENSE | 21 +++++++ README.md | 107 +++++++++++++++++++++++++++++++++++ dokuwikiinstall | 145 ++++++++++++++++++++++++++++++++++++++++++++++++ last-tested | 4 ++ 4 files changed, 277 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100755 dokuwikiinstall create mode 100644 last-tested diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..3eaaa81 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Allan Christensen + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..b6dbe3d --- /dev/null +++ b/README.md @@ -0,0 +1,107 @@ +# DokuWiki for Ubuntu 24.04 Server +[![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)](#) +[![App](https://img.shields.io/badge/app-dokuwiki-0098D4)](#) +[![License](https://img.shields.io/badge/License-MIT-green)](./LICENSE) + +Automated Bash installer for deploying the **latest stable release of DokuWiki** on Ubuntu 24.04 Server. + +This is a **production-focused installer**, not a demo. + +It assumes that Nginx and PHP-FPM are already installed and running. + +--- + +## Related Installers + +If you don’t have the required components, you can use this compatible installer: + +- [Nginx + PHP-FPM Installer](https://git.x-files.dk/webserver/nginx-ubuntu) + +--- + +### Download the Script +Clone the repository to your server: + +``` +git clone https://git.x-files.dk/webapps/dokuwiki-ubuntu.git +``` + +``` +cd dokuwiki-ubuntu +``` + +### Usage +Run the script and provide your desired domain name as an argument: + +``` +sudo ./dokuwikiinstall +``` + +### Example +``` +sudo ./dokuwikiinstall wiki.example.com +``` + +### Configuration +When the installation completes, visit: + +``` +http:///install.php +``` + +and complete the initial DokuWiki setup through the web interface. + +--- + +### Post-install +After completing the web-based installation, run the post-install script to apply security and hardening settings: + +``` +sudo /tmp/dokuwiki-postinstall +``` + +--- + +### Nginx Integration + +The generated DokuWiki 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/dokuwiki.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`. + +**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. + +--- + +### 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). + +--- diff --git a/dokuwikiinstall b/dokuwikiinstall new file mode 100755 index 0000000..c826495 --- /dev/null +++ b/dokuwikiinstall @@ -0,0 +1,145 @@ +#!/usr/bin/env bash + +# Author : Allan Christensen +# First Created : 05012022 (DD-MM-YYYY) +# Description : Installs DokuWiki on Ubuntu 24.04 +# License : MIT License (see LICENSE file for details) + +# +# Are we root +# +if [[ $(id -u) -ne 0 ]]; then echo "" && echo "Must be root or use sudo" && echo "" ; exit 1 ; fi + +# +# Define variables and functions +# +hostname="$1" +phpver=$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;') ; phpfpm="php$phpver-fpm" + +# +# Function usage +# +usage () { + printf -- "\ndokuwikiinstall\n\n" + printf -- "Installs DokuWiki on Ubuntu\n\n" + printf -- "Usage:\n" + printf -- "sudo ./dokuwikiinstall \n" + printf -- "Examples:\n" + printf -- "sudo ./dokuwikiinstall wiki.something.xyz\n\n" +} + +# +# Function to check if a service is already running or not +# +serviceno () { printf "\n%s" "$service" ; printf " is not running cannot continue...\n\n"; } +servicedead () { status=$(systemctl is-active "$service"); if [[ "$status" != "active" ]]; then serviceno ; exit 1 ; fi; } + +# +# Function input check +# +inputcheck () { if [[ -z "$1" ]]; then usage ; printf "ERROR: DOMAIN CANNOT BE EMPTY!\n\n" ; exit; fi; } + +# +# If Nginx is not running then die +# +service="nginx" ; servicedead + +# +# Let's go +# +clear + +# +# Check if input conditions are met +# +inputcheck "$hostname" + +# +# Clone nginx-snippets; if nginx-snippets exists then just pull latest changes +# +nginxsnippets="/etc/nginx/nginx-snippets" +repo="https://git.x-files.dk/webserver/nginx-snippets.git" +if [[ -d "$nginxsnippets/.git" ]]; then git -C "$nginxsnippets" pull --quiet; else git clone --quiet "$repo" "$nginxsnippets"; fi + +# +# Download the latest Dokuwiki +# +wikidir="/var/www/html/$hostname" ; mkdir -p "$wikidir" +curl -sL https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz | tar -xzf - -C "$wikidir" --strip-components=1 || { echo "Download or extraction failed"; exit 1; } +chown -R www-data: "$wikidir" + +# +# Create a DokuWiki nginx configuration file +# +cp "$nginxsnippets/hostfiles/dokuwiki.80.conf" /etc/nginx/conf.d/"$hostname".conf +sed -i "s/DOMAIN/$hostname/g" /etc/nginx/conf.d/"$hostname".conf +sed -i "s/VERSION/$phpver/" /etc/nginx/conf.d/"$hostname".conf + +# +# Restarting Nginx and Phpfpm for changes to take effect +# +systemctl restart "$phpfpm" ; systemctl restart nginx + +# +# Create postinstall script +# +cat > /tmp/dokuwiki-postinstall <