User Tools

Site Tools


building_a_wiki_machine

Building a wiki machine

build_wiki.sh
# Starting from a fresh, not-yet-updated install of Ubuntu or Mint
 
sudo apt install tig git etckeeper
 
sudo apt update
 
sudo apt upgrade -y
 
sudo reboot
 
cd /etc/
 
sudo etckeeper commit "Fresh build."
 
sudo apt install -y screen mc catdvi gv imagemagick libaspell-dev openssh-server links \
                    w3m lynx arj iselect ncurses-term vim chromium-browser wamerican* \
                    vlc gnuplot remind 
 
# Nice, usable system at this point, let's build a wiki to keep track of notes and stuff.
sudo apt install wget unzip nginx-full php-{bcmath,cli,curl,fpm,gd,gmp,json,mbstring,snmp,xml,zip}
 
sudo systemctl status nginx --lines=0
 
sudo wget https://download.dokuwiki.org/src/dokuwiki/dokuwiki-stable.tgz -O /tmp/dokuwiki.tgz
 
sudo tar xvf /tmp/dokuwiki.tgz --strip-components=1 -C /var/www/html
 
sudo chown -R www-data: /var/www/html
 
# The stuff below is called a 'heredoc' and is a nice way to build a config
# file. In this case, the delimiter EOF is wrapped in quotes to prevent 
# variable substitution in the lines below, the - removes the leading tab.
cat <<-"EOF" | sudo tee /etc/nginx/sites-enabled/dokuwiki.conf
    server {
    listen 80;
    server_name wiki.cyli.org
 
    # Maximum file upload size is 4MB - change accordingly if needed
    client_max_body_size 4M;
    client_body_buffer_size 128k;
 
    root /var/www/html;
    index doku.php;
 
    #Remember to comment the below out when you're installing, and uncomment it when done.
    #location ~ /(conf/|bin/|inc/|vendor/|install.php) { deny all; }
 
    #Support for X-Accel-Redirect
    location ~ ^/data/ { internal ; }
 
    location ~ ^/lib.*\.(js|css|gif|png|ico|jpg|jpeg)$ {
    expires 365d;
    }
 
    location / { try_files $uri $uri/ @dokuwiki; }
 
    location @dokuwiki {
    # rewrites "doku.php/" out of the URLs if you set the userwrite setting 
    # to .htaccess in dokuwiki config page
    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;
    }
 
    location ~ \.php$ {
    try_files $uri $uri/ /doku.php;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param REDIRECT_STATUS 200;
    fastcgi_pass unix:/var/run/php/php-fpm.sock;
    }
    }
EOF
 
sudo rm /etc/nginx/sites-enabled/default -f
 
sudo systemctl restart nginx
 
# Visit the site http://wiki.cyli.org/install.php
# Configure a user or two, then run the lines below;
 
sudo sed -i.bak -e 's/#location/location/' /etc/nginx/sites-enabled/dokuwiki.conf 
 
diff /etc/nginx/sites-enabled/dokuwiki.conf*
# 13c13
# < location ~ /(conf/|bin/|inc/|vendor/|install.php) { deny all; }
# ---
# > #location ~ /(conf/|bin/|inc/|vendor/|install.php) { deny all; }
 
sudo systemctl restart nginx
building_a_wiki_machine.txt · Last modified: by steve