Install Dokuwiki with Nginx and PHP5-FPM Debian 7

By | December 3, 2014

In this post we will see how to Install Dokuwiki with Nginx and PHP5-FPM Debian 7. Dokuwiki is a php based wiki software. It does not require a database like MySql becuase it stores data using flat files.

Installation of nginx and php5-fpm on Debian 7 is something which I have already discussed in an earlier post. It talks about how to install LEMP stack on Debian 7 (LINUX, NGINX, PHP5-FPM and MariaDB). You may avoid the MariaDB part and have a look at the rest using this LINK .

I have tested this on Debian 7. It will work on other distributions as well like CentOS etc, as long as Nginx is used as the web server with php fast page module .

Lets Proceed.

Download the latest tarball of Dokuwiki and extract it

root@debian:~# cd /tmp/
root@debian:/tmp# ls
root@debian:/tmp# wget http://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz -O dokuwiki.tgz
root@debian:/tmp# tar -xf dokuwiki.tgz 
root@debian:/tmp# ls
dokuwiki-2014-09-29a  dokuwiki.tgz

Make a directory by name “dokuwiki” in side the webroot (my webroot is “/usr/share/nginx ” )and copy the contents of ” dokuwiki-2014-09-29a” in it.

root@debian:/tmp# mkdir /usr/share/nginx/dokuwiki
root@debian:/tmp# cp -R dokuwiki-2014-09-29a/* /usr/share/nginx/dokuwiki/

Check which user nginx service is running as using the following command

root@debian:/tmp# head /etc/nginx/nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
root@debian:/tmp#

Note the output, in my machine nginx is running as the user “nginx”, {it may also run as the user “www-data” }. Once this is identified, we will change the ownership of our directory “/usr/share/nginx/dokuwiki” to that user, so that nginx web service has full access in it. We will be hardening the web access to it a little later.

root@debian:/tmp# chown -R nginx.root /usr/share/nginx/dokuwiki/

Now lets configure Nginx to serve our dokuwiki site. My url to access my wiki here is blog.example.com. And my nginx configuration directory is “/etc/nginx/conf.d”. I will create a file called “dokuwiki.conf” in it.

root@debian:/tmp# touch /etc/nginx/conf.d/dokuwiki.conf

Add the site serving definitions as well as the access restictions in the file as follows using your favourite editor. I am using “vi editor”.

root@debian:/tmp# vi /etc/nginx/conf.d/dokuwiki.conf
server {
 listen 80;
 root /usr/share/nginx/dokuwiki;
 index index.php index.html index.htm doku.php;
 server_name blog.example.com;
 autoindex off;
 client_max_body_size 15M;
 client_body_buffer_size 128k;
 index index.html index.htm index.php doku.php;
 access_log /var/log/nginx/access.log;
 error_log /var/log/nginx/error.log;
 location / {
 try_files $uri $uri/ @dokuwiki;
 }
 error_page 404 /404.html;
 error_page 500 502 503 504 /50x.html;
 location = /50x.html {
 root /usr/share/nginx/html;
 }
 location ~ ^/lib.*\.(gif|png|ico|jpg)$ {
 expires 30d;
 }
 location = /robots.txt { access_log off; log_not_found off; }
 location = /favicon.ico { access_log off; log_not_found off; }
 location ~ /\. { access_log off; log_not_found off; deny all; }
 location ~ ~$ { access_log off; log_not_found off; deny all; }
 # pass the PHP scripts to FastCGI server listening on /var/run/php5-fpm.sock
 location ~ \.php$ {
 try_files $uri =404;
 fastcgi_pass unix:/var/run/php5-fpm.sock;
 fastcgi_index index.php;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 include /etc/nginx/fastcgi_params;
 fastcgi_param QUERY_STRING $query_string;
 fastcgi_param REQUEST_METHOD $request_method;
 fastcgi_param CONTENT_TYPE $content_type;
 fastcgi_param CONTENT_LENGTH $content_length;
 fastcgi_intercept_errors on;
 fastcgi_ignore_client_abort off;
 fastcgi_connect_timeout 60;
 fastcgi_send_timeout 180;
 fastcgi_read_timeout 180;
 fastcgi_buffer_size 128k;
 fastcgi_buffers 4 256k;
 fastcgi_busy_buffers_size 256k;
 fastcgi_temp_file_write_size 256k;
 }
 location ~ /(data|conf|bin|inc)/ {
 deny all;
 }
 location ~ /\.ht {
 deny all;
 }
}

Now run the installer program. My url is “http://blog.example.com/install.php”. Replace “blog.example.com” with your own FQDN.

Dokuwiki1

Fill in the required information superuser, real name, password, email address. I have chosen Initial ACL policy as public wiki (read dor every one and write and upload for registered users) from the drop down menu. You may select anything of your choice as per your requirement.

Once done do not forget to delete the install.php file.

root@debian:/tmp# rm -r /usr/share/nginx/dokuwiki/install.php

Thats it the wiki site is ready and accessible with the url “http://blog.example.com” .

Installation Referencehttps://www.dokuwiki.org/install

2 thoughts on “Install Dokuwiki with Nginx and PHP5-FPM Debian 7

    1. rudraraj Post author

      Hello Mr. Ron Kierstead,
      Good to know that this little installation guide has helped you.
      Take Care. 🙂

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *