First, you will need to log in to your Ubuntu 22.04 VPS via SSH as the root user:<\/p>\n
ssh master@IP_Address -p Port_number<\/pre>\nYou will need to replace ‘IP_Address’ and ‘Port_number’ with your server’s respective IP address and SSH port number. Additionally, replace ‘master’ with the username of the system user with sudo privileges or ‘root.’<\/p>\n
You can check whether you have the proper Ubuntu 22.04 installed on your server with the following command:<\/p>\n
$ lsb_release -a<\/pre>\nIt will return an output like this.<\/p>\n
No LSB modules are available.\r\nDistributor ID: Ubuntu\r\nDescription: Ubuntu 22.04 LTS\r\nRelease: 22.04\r\nCodename: jammy<\/pre>\n<\/span>Step 1. Install Nginx and PHP<\/span><\/h2>\nWe need to install the web server and PHP to proceed with installing Dokuwiki. In this post, we will use Nginx instead of Apache. So, let’s run the command below to install them. Also, according to Dokuwiki documentation at https:\/\/www.dokuwiki.org\/requirements, using the latest version of the 7.4.x branch or 8.x is highly recommended to run a Dokuwiki website. Since the default PHP version in Ubuntu 22.04 is 8.1, we can proceed with the installation now.<\/p>\n
$ sudo apt install wget unzip nginx-full php-{bcmath,cli,curl,fpm,gd,gmp,json,mbstring,snmp,xml,zip}<\/pre>\nOn Ubuntu 22.04, Nginx is configured to start running upon installation; you can check them by running this command:<\/p>\n
$ sudo systemctl status nginx --lines=0<\/pre>\nPlease note unlike any other wiki software, Dokuwiki does not need a database server. All data are stored in PHP files, and this speeds up the website itself.<\/p>\n
<\/span>Step 2. Download Dokuwiki<\/span><\/h2>\nTo download the latest stable version, you can check their download page at https:\/\/download.dokuwiki.org\/<\/p>\n
Execute the commands below to download the Dokuwiki file and extract it.<\/p>\n
$ sudo wget https:\/\/download.dokuwiki.org\/src\/dokuwiki\/dokuwiki-stable.tgz -O \/tmp\/dokuwiki.tgz\r\n$ sudo mkdir \/var\/www\/html\/dokuwiki\r\n$ sudo tar xvf \/tmp\/dokuwiki.tgz --strip-components=1 -C \/var\/www\/html\/dokuwiki<\/pre>\nNext, let’s give the directory and its contents the correct permission.<\/p>\n
$ sudo chown -R www-data. \/var\/www\/html\/dokuwiki<\/pre>\n<\/span>Step 3. Install Certbot<\/span><\/h2>\nWe are going to host our Dokuwiki website in HTTPS and in this step we will show you how to install a free SSL certificate from Let’s Encrypt using cerbot.<\/p>\n
$ sudo apt install python3-certbot-nginx<\/pre>\nNext, let’s invoke this command below. Make sure to replace wiki.yourdomain.com with your actual domain or subdomain name.<\/p>\n
$ sudo certbot certonly -d wiki.yourdomain.com<\/pre>\nIt should look like this:<\/p>\n
master@wiki:~$ sudo certbot certonly -d wiki.yourdomain.com \r\nSaving debug log to \/var\/log\/letsencrypt\/letsencrypt.log\r\n\r\nHow would you like to authenticate with the ACME CA?\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n1: Nginx Web Server plugin (nginx)\r\n2: Spin up a temporary webserver (standalone)\r\n3: Place files in webroot directory (webroot)\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nSelect the appropriate number [1-3] then [enter] (press 'c' to cancel): 1\r\nEnter email address (used for urgent renewal and security notices)\r\n(Enter 'c' to cancel): you@yourdomain.com\r\n\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nPlease read the Terms of Service at\r\nhttps:\/\/letsencrypt.org\/documents\/LE-SA-v1.2-November-15-2017.pdf. You must\r\nagree in order to register with the ACME server. Do you agree?\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n(Y)es\/(N)o: y\r\n\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nWould you be willing, once your first certificate is successfully issued, to\r\nshare your email address with the Electronic Frontier Foundation, a founding\r\npartner of the Let's Encrypt project and the non-profit organization that\r\ndevelops Certbot? We'd like to send you email about our work encrypting the web,\r\nEFF news, campaigns, and ways to support digital freedom.\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\n(Y)es\/(N)o: n\r\nAccount registered.\r\nRequesting a certificate for wiki.yourdomain.com\r\n\r\nSuccessfully received certificate.\r\nCertificate is saved at: \/etc\/letsencrypt\/live\/wiki.yourdomain.com\/fullchain.pem\r\nKey is saved at: \/etc\/letsencrypt\/live\/wiki.yourdomain.com\/privkey.pem\r\nThis certificate expires on 2022-11-11.\r\nThese files will be updated when the certificate renews.\r\nCertbot has set up a scheduled task to automatically renew this certificate in the background.\r\n\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nIf you like Certbot, please consider supporting our work by:\r\n* Donating to ISRG \/ Let's Encrypt: https:\/\/letsencrypt.org\/donate\r\n* Donating to EFF: https:\/\/eff.org\/donate-le\r\n- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\r\nmaster@wiki:~$<\/pre>\nAs seen in the output, we need these paths below to configure our Dokuwiki nginx server block.<\/p>\n
Certificate is saved at: \/etc\/letsencrypt\/live\/wiki.yourdomain.com\/fullchain.pem\r\nKey is saved at: \/etc\/letsencrypt\/live\/wiki.yourdomain.com\/privkey.pem<\/pre>\n<\/span>Step 4. Configure Nginx<\/span><\/h2>\nNginx has a default server block, and we are going to delete it and create a new server block for our Dokuwiki website.<\/p>\n
$ sudo rm \/etc\/nginx\/sites-enabled\/default -f\r\n$ sudo nano \/etc\/nginx\/sites-enabled\/dokuwiki.conf<\/pre>\nPaste the following in to the file. Again, make sure to replace wiki.yourdomain.com with your actual domain or subdomain name.<\/p>\n
server {\r\nlisten 80;\r\nserver_name wiki.yourdomain.com;\r\nreturn 301 https:\/\/$server_name$request_uri;\r\n}\r\n\r\nserver {\r\nlisten 443 ssl;\r\nssl_certificate \/etc\/letsencrypt\/live\/wiki.yourdomain.com\/fullchain.pem;\r\nssl_certificate_key \/etc\/letsencrypt\/live\/wiki.yourdomain.com\/privkey.pem;\r\n\r\nserver_name wiki.yourdomain.com;\r\n\r\n# Maximum file upload size is 4MB - change accordingly if needed\r\nclient_max_body_size 4M;\r\nclient_body_buffer_size 128k;\r\n\r\nroot \/var\/www\/html\/dokuwiki;\r\nindex doku.php;\r\n\r\n#Remember to comment the below out when you're installing, and uncomment it when done.\r\n#location ~ \/(conf\/|bin\/|inc\/|vendor\/|install.php) { deny all; }\r\n\r\n#Support for X-Accel-Redirect\r\nlocation ~ ^\/data\/ { internal ; }\r\n\r\nlocation ~ ^\/lib.*\\.(js|css|gif|png|ico|jpg|jpeg)$ {\r\nexpires 365d;\r\n}\r\n\r\nlocation \/ { try_files $uri $uri\/ @dokuwiki; }\r\n\r\nlocation @dokuwiki {\r\n# rewrites \"doku.php\/\" out of the URLs if you set the userwrite setting to .htaccess in dokuwiki config page\r\nrewrite ^\/_media\/(.*) \/lib\/exe\/fetch.php?media=$1 last;\r\nrewrite ^\/_detail\/(.*) \/lib\/exe\/detail.php?media=$1 last;\r\nrewrite ^\/_export\/([^\/]+)\/(.*) \/doku.php?do=export_$1&id=$2 last;\r\nrewrite ^\/(.*) \/doku.php?id=$1&$args last;\r\n}\r\n\r\nlocation ~ \\.php$ {\r\ntry_files $uri $uri\/ \/doku.php;\r\ninclude fastcgi_params;\r\nfastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\nfastcgi_param REDIRECT_STATUS 200;\r\nfastcgi_pass unix:\/var\/run\/php\/php7.4-fpm.sock;\r\n}\r\n}<\/pre>\nSave the file then restart nginx<\/p>\n
$ sudo systemctl restart nginx<\/pre>\n