wiki.allensmith.net

Personal "Rough Notes" & Useful Links

User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

kb:linux:lts14lxcnginxphpdokuwiki [2015/05/20 02:13]
Allen Smith edit as using
kb:linux:lts14lxcnginxphpdokuwiki [2016/01/14 01:35]
Line 1: Line 1:
-====== Lxc 1.0: DokuWiki in an Nginx & PHP Container ====== 
-{{INLINETOC}} 
  
-<​note>​The below **Dokuwiki Development Server** is created & deployed using an lxc-clone of the already created [[kb:​linux:​lts14lxcnginxphp | Lxc 1.0 Nginx and PHP Container]]. In this example, the wiki will be found at http://​dokuwiki.lxc/​ (The container is ''​dokuwiki''​ and the website directory is ''/''​ ... which is stored at ''/​var/​www/​html/''​)</​note>​ 
- 
-{{page>​data:​kb:​bashprompts&​noheader&​nofooter&​noeditbtn}} 
- 
-**References:​**\\ ​ 
-[[http://​the.binbashtheory.com/​using-overlayfs-with-lxc/​|The /bin/bash Theory -- Using Overlayfs With LXC]]\\ ​ 
-[[https://​www.digitalocean.com/​community/​tutorials/​how-to-install-dokuwiki-with-nginx-on-an-ubuntu-12-04-vps|DigitalOcean -- How To Install DokuWiki with Nginx on an Ubuntu 12.04 VPS]] 
- 
-===== Create the Nginx & PHP Container to Install DokuWiki ===== 
-  * Create the dokuwiki development container using an Overlayfs clone of nginx14lts<​code>​ 
-$ sudo su 
-# lxc-clone -o nginx14lts -n dokuwiki -B overlayfs -s 
-</​code>​which produced the below output<​file>​ 
-Created container dokuwiki as snapshot of nginx14lts 
-</​file><​code>​ 
-# exit 
-</​code>​ 
- 
-  * The default user & password for this just created container will be **ubuntu** & **ubuntu** 
- 
-  * Start this just created container & Log-in to it:<​code>​ 
-$ sudo lxc-start -n dokuwiki -d 
-$ sudo lxc-console -n dokuwiki 
-</​code>​ 
-  * Change the default password for the **ubuntu** user:<​code>​ 
-$ passwd 
-</​code>​ 
-    * set the password to something else (and remember it). 
-    * logout & log back in to ensure the password was set correctly. 
- 
-===== Configure Nginx to use dokuwiki.lxc as a DokuWiki site ===== 
-<note warning>​**Please Note:** The following Nginx rewrite rules -- to enable DokuWiki to use "​nice"​ URLs -- work **only** if DokuWiki is installed in the **webhosting root** for the container. (e.g. <​nowiki>​http://​dokuwiki.lxc/​wiki:​welcome</​nowiki>​ will work.)</​note>​ 
-  * Replace the Nginx configuration file for the Virtual Server with an edited (for DokuWiki) version<​code>​ 
-$ sudo mv /​etc/​nginx/​sites-available/​virtual /​etc/​nginx/​sites-available/​virtual.old 
-$ sudo nano /​etc/​nginx/​sites-available/​virtual ​    # put the following into this empty file 
-</​code><​file txt /​etc/​nginx/​sites-available/​virtual>​ 
-## 
-# You should look at the following URL's in order to grasp a solid understanding 
-# of Nginx configuration files in order to fully unleash the power of Nginx. 
-# http://​wiki.nginx.org/​Pitfalls 
-# http://​wiki.nginx.org/​QuickStart 
-# http://​wiki.nginx.org/​Configuration 
-# 
-# Generally, you will want to move this file somewhere, and start with a clean 
-# file but keep this around for reference. Or just disable in sites-enabled. 
-# 
-# Please see /​usr/​share/​doc/​nginx-doc/​examples/​ for more detailed examples. 
-## 
- 
-# Default server configuration 
-# 
-server { 
-        listen 80 default_server;​ 
-        listen [::]:80 default_server;​ 
- 
-        # SSL configuration 
-        # 
-        # listen 443 ssl default_server;​ 
-        # listen [::]:443 ssl default_server;​ 
-        # 
-        # Self signed certs generated by the ssl-cert package 
-        # Don't use them in a production server! 
-        # 
-        # include snippets/​snakeoil.conf;​ 
- 
-        root /​var/​www/​html;​ 
- 
-        # Add index.php to the list if you are using PHP 
-        index doku.php; 
- 
-        server_name dokuwiki.lxc;​ 
- 
-        # nice URL rewrite 
-        location @dokuwiki { 
-                rewrite ^/​_media/​(.*) /​lib/​exe/​fetch.php?​media=$1 last; 
-                rewrite ^/​_detail/​(.*) /​lib/​exe/​detail.php?​media=$1 last; 
-                rewrite ^/​_export/​([^/​]+)/​(.*) /​doku.php?​do=export_$1&​id=$2 last; 
-                rewrite ^/(.*) /​doku.php?​id=$1&​$args last; 
-        } 
- 
-        # Security Rules from www.dokuwiki.org/​security#​deny_directory_access_in_nginx 
-        location ~ /​(data|conf|bin|inc)/​ { 
-          deny all; 
-        } 
- 
-        location / { 
-                # First attempt to serve request as file, then 
-                # as directory, then try the nice URL rewite. 
-                try_files $uri $uri/ @dokuwiki; 
-        } 
-        location ~ /\.ht { 
-                # deny access to .htaccess files, if Apache'​s document root 
-                # concurs with nginx'​s one 
-                        deny all; 
-        } 
- 
-        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:​9000 
-        # 
-        location ~ \.php$ { 
-                try_files $uri =404; 
-        #       # With php5-cgi alone: 
-        #       ​fastcgi_pass 127.0.0.1:​9000;​ 
-                # With php5-fpm: 
-                fastcgi_pass unix:/​var/​run/​php5-fpm.sock;​ 
-                fastcgi_index index.php; 
-                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;​ 
-                include fastcgi_params;​ 
-        } 
-} 
-</​file>​ 
-<note important>​If the **container name** is something other than **''​dokuwiki''​**,​ then edit the above **''​server_name dokuwiki.lxc;''​** line to use the **''​.lxc''​** version of the name for your container. (Mind the ending semicolon.)</​note>​ 
-  * Now restart the nginx & php-fpm services:<​code>​ 
-$ sudo service nginx restart 
-$ sudo service php5-fpm restart 
-</​code>​ 
- 
-===== Download & Install the DokuWiki Files===== 
-  * download the latest stable version of DokuWiki into ~/<​code>​ 
-$ wget http://​download.dokuwiki.org/​src/​dokuwiki/​dokuwiki-stable.tgz 
-</​code>​This produced the following output:<​file>​ 
---2015-05-19 21:​40:​30-- ​ http://​download.dokuwiki.org/​src/​dokuwiki/​dokuwiki-stable.tgz 
-Resolving download.dokuwiki.org (download.dokuwiki.org)... 46.4.55.201,​ 2a01:​4f8:​140:​13e4::​b00b 
-Connecting to download.dokuwiki.org (download.dokuwiki.org)|46.4.55.201|:​80... connected. 
-HTTP request sent, awaiting response... 200 OK 
-Length: 3283317 (3.1M) [application/​octet-stream] 
-Saving to: ‘dokuwiki-stable.tgz’ 
- 
-100%[===================================================>​] 3,​283,​317 ​   618KB/​s ​  in 6.5s    
- 
-2015-05-19 21:40:39 (496 KB/s) - ‘dokuwiki-stable.tgz’ saved [3283317/​3283317] 
-</​file>​ 
-  * From the download tarball, extract the directory structure by typing<​code>​ 
-$ tar xzvf dokuwiki-stable.tgz 
-</​code>​ 
-  * Now delete the tarball by typing<​code>​ 
-$ rm dokuwiki-stable.tgz 
-</​code>​ 
-  * change the name of the directory to where the wiki will be stored -- which will be **''/​var/​www/​html/''​** for the webserver root<​code>​ 
-$ mv doku* html 
-</​code>​ 
-  * remove the "​testing"​ files in the webserver root (below ''​mv''​ command needs empty directory)<​code>​ 
-$ sudo rm -R /​var/​www/​html/​* 
-</​code>​ 
-  * move this directory into the web root, and set ownership -- to allow access to this by typing **''​dokuwiki.lxc''​**<​code>​ 
-$ sudo mv html  /var/www/ 
-$ sudo chown -R  www-data:​www-data /​var/​www/​html 
-</​code>​ 
- 
-===== Run the DokuWiki Installer Script ===== 
-  * http://​dokuwiki.lxc/​install.php 
-{{  kb:​linux:​dokuwiki_install.png ​ }} 
- 
-  * Once the DokuWiki installer has been run, **delete** the install.php file<​code>​ 
-$ sudo rm /​var/​www/​html/​install.php 
-</​code>​ 
- 
-===== Suggested Post-Install Configuration ===== 
-  * Log-in to the just created DokuWiki site 
-  * Admin >> Configuration Settings 
-    * In the **Display** section: 
-      * Number of "​trace"​ breadcrumbs. Set to 0 to disable. → set to **0** 
-      * Use hierarchical breadcrumbs ... → SELECT this 
-      * Top level for table of contents → **2** 
-      * Use first heading for pagenames → set to **Always** 
-      * By default, DokuWiki will show all namespaces in the sitemap. ... → SELECT this option 
-    * In the **Links** section: 
-      * Target window for external links → set to **_blank** 
-    * In the **Advanced** section: 
-      * Use nice URLs → set to **.htaccess** 
-      * Size in bytes up to which images referenced in CSS files should be embedded right into the stylesheet → set to **512** 
-      * Use gzip Content-Encoding for xhtml → SELECT this