Setup of local wiki on Ubuntu
From Stephan
For technical documentation on my PC, I also rather choose to quickly setup a wiki instead of dumping characters in a bunch of text files which I afterwards can not organize easily.
But for backup reasons, I try to change a few things on the standard configuration so the uploaded files and database files are on a location which are automatically backed up using a current online backup system I use (Dropbox).
First I install apache and php5 (with some standard additional extension packages):
sudo apt-get install apache2 php5 php5-mysql php5-gd php5-imagick mysql-server mysql-admin
Contents |
Modify locations
Apache
- Press Ctrl-Alt-t
- In the terminal, type
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/localwiki
- Create a local folder where a backup is automatically taken (in my case i.e:)
mkdir /home/stephanbosal/Dropbox/www
- then edit the conf file:
sudo gedit /etc/apache2/sites-available/localwiki
- In that file, change DocumentRoot to
/home/stephanbosal/Dropbox/www, but make note of the previous value - Now, find a <Directory>-entry with the value noted in previous line and:
- also replace the directory-value (/var/www) to the one noted in the previous line
- Change a possible
AllowOverride NonetoAllowOverride All
- Now enable that site by adding a link in /etc/apache2/sites-enabled:
sudo ln -s ../sites-available/localwiki 001-localwiki
- ...and disable the default:
sudo rm 000-default
Enable mod_rewrite
This is necessary for the short URLs to be used in wiki
- Go to
/etc/apache2/mods-enabledand run this command
sudo ln -s ../mods-available/rewrite.load ./rewrite.load
- Now restart the server one time:
sudo /etc/init.d/apache2 restart
PHP
PHP does not really need to be modified, but we can use php to check some settings first: Add a file on the www-root (in this case /home/stephanbosal/Dropbox/www called index.php and enter this code in it:
<?php
phpinfo();
?>
Now go to http://127.0.0.1 and you should see a page with a lot of configuration data. This can be helpful sometimes.
MySQL
- Either
- Start MySQL Administrator (Applications->Programming->MySQL Administrator) and log in to localhost
- Open'Startup parameters' and look at the bottom to see the location of the my.cnf file
- Or (on the root directory):
sudo find -name my.cnf
- Look in this file:
sudo gedit /etc/mysql/my.cnf
- ... and note the location of the mysql datadir, probably
/var/lib/mysql
Backup script
- In your scripts folder, create a file named something like
gedit ~/Dropbox/scripts/bckmysql.sh
- And give it this code (replace values where necessary)
#/bin/sh! #If you do not have Upstart, change next line to sudo /etc/init.d/mysql stop sudo stop mysql sudo rsync -a --delete /var/lib/mysql /home/stephanbosal/Dropbox/backup/ #This is so Dropbox can read the files, at restore, do a chown/chmod to original settings (mysql:mysql 700): sudo chown -R stephanbosal:stephanbosal /home/stephanbosal/Dropbox/backup/ sudo chmod -R 755 /home/stephanbosal/Dropbox/backup/ #If you do not have Upstart, change next line to sudo /etc/init.d/mysql start sudo start mysql
- You can add a shortcut button of the backup script on a panel or in the menu, whatever...