<\/span><\/h2>\nDokuWiki can run on almost all of the popular web servers that support PHP, but in this tutorial, we already installed nginx and it is time to configure it to host our DokuWiki website. Let’s create a new nginx server block for our website.<\/p>\n
# nano \/etc\/nginx\/sites-enabled\/dokuwiki.conf<\/pre>\nPaste the following into the file.<\/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 exit, do not<\/strong> restart or reload nginx at this time. It will throw an error because the configuration needs to access the SSL certificate, and we haven’t installed it yet.<\/p>\n<\/span>Step 5. Install SSL\/TLS Certificate<\/span><\/h2>\nIn this modern era, it is important to run a website in HTTPS mode. In this step, we will show you how to install an SSL\/TLS certificate for your DokuWiki website using the free one from Let\u2019s Encrypt.<\/p>\n
# apt install python3-certbot-nginx<\/pre>\nThen, invoke this command to issue an SSL\/TLS certificate for your domain\/subdomain. Make sure to replace dokuwiki.yourdomain.com with an actual domain or subdomain name pointing to your VPS.<\/p>\n
# certbot certonly --nginx -d dokuwiki.yourdomain.com<\/pre>\nThe command will ask for your email address, and it will ask you whether to agree with the agreement or not. Finally, your SSL\/TLS certificate will be generated if everything is okay.<\/p>\n
Saving debug log to \/var\/log\/letsencrypt\/letsencrypt.log\r\nPlugins selected: Authenticator nginx, Installer nginx\r\nObtaining a new certificate\r\nPerforming the following challenges:\r\nhttp-01 challenge for dokuwiki.yourdomain.com\r\nWaiting for verification...\r\nCleaning up challenges\r\n\r\nIMPORTANT NOTES:\r\n- Congratulations! Your certificate and chain have been saved at:\r\n\/etc\/letsencrypt\/live\/dokuwiki.yourdomain.com\/fullchain.pem\r\nYour key file has been saved at:\r\n\/etc\/letsencrypt\/live\/dokuwiki.yourdomain.com\/privkey.pem\r\nYour cert will expire on 2023-03-09. To obtain a new or tweaked\r\nversion of this certificate in the future, simply run certbot\r\nagain. To non-interactively renew *all* of your certificates, run\r\n\"certbot renew\"\r\n- If you like Certbot, please consider supporting our work by:\r\n\r\nDonating to ISRG \/ Let's Encrypt: https:\/\/letsencrypt.org\/donate\r\nDonating to EFF: https:\/\/eff.org\/donate-le<\/pre>\nCertbot has now issued an SSL\/TLS certificate for your domain\/subdomain, we can restart nginx now.<\/p>\n
# systemctl restart nginx<\/pre>\n