Install MediaWiki on Apache with mySQL

MediaWiki Logo

From MediaWiki site: MediaWiki is a free software open source wiki package written in PHP, originally for use on Wikipedia.

I decided to give MediaWiki a try as a scripts repository so I thought I’d write a quick guide of how to install it on a Linux/Apache/mySQL server.

Assumptions

  • A fully qualified domain name with a host record pointing to a internet facing server
  • A fully working Linux server (my example is a Debian server)
  • Apache installed on the Linux server and listening on port 80
  • A preconfigured vhost
  • PHP installed
  • mySQL server installed

Installation

1. Download the compressed installation file

wget http://releases.wikimedia.org/mediawiki/1.23/mediawiki-1.23.5.tar.gz

wget mediawiki

2. Extract the compressed archive

tar xvzf mediawiki*.tar.gz
Extract MediaWiki

3. Copy files from mediawiki-1.23.5 folder to the root folder

cd mediawiki-1.23.5
mv * ../
cd ..
rm -rf mediawiki-1.23.5
rm mediawiki-1.23.5.tar.gz
MediaWiki CleanUp

4. Create mySQL Database

CREATE DATABASE $databasename

5.  Create mySQL Database user

CREATE USER '$databaseuser'@'localhost' IDENTIFIED BY '$databasepass';

6. Grant database permissions to database

GRANT ALL PRIVILEGES ON $databasename.* TO '$databaseuser'@'localhost' IDENTIFIED BY '$databasepass';

7. Flush mySQL privileges

flush privileges;

8. Log into the site eg:

http://wiki.example.com

MediaWiki Inital Screen

Click on “Complete the installation”

9. Select the languageMediaWiki Language

10. Click continueMediaWiki Welcome

11. Input all database information

MediaWiki Database Setup

12. Change settings to suit your database requirements

MediaWiki Database Settings

13. Input name of MediaWiki and desired credentials

MediaWiki Name and Credentials

14. Configure options for your MediaWiki

MediaWiki Options

15. Install MediaWikiMediaWiki Install

16. Installation completeMediaWiki Installation Finished

17. Download and copy the LocalSettings.php file to the root of the MediaWiki installationMediaWiki LocalSettings

18. Browse to your MediaWiki installation and log in

Example: http://wiki.example.com

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.

Browse websites in a Linux terminal

linux-logo-300x300

I stumbled upon a package that allows the user to browse websites in a terminal, I thought I’d spin up a VM and try this for myself…

Installing W3M

This is very simple, requires one package (two if you want images displayed in Xterm)

apt-get install w3m w3m-img

Browsing

Now this isn’t going to look pretty as it’s in a terminal but it will work

w3m
w3m google.com
w3m google.com

Navigation

You can use the arrow keys to navigate to the section you want or use the mouse to click on the particular area.

shift+ b = Take you back a page

shift + u = Gives you a URL prompt

Shift + h = Help menu

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.

Rebuild locale on Linux

linux-logo-300x300

A quick note on how to rebuild Linux locale, you might get the following errors if your locale is broken:

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory

To find out what locale is set, run the following:

locale

Output should be something like this:

locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_AU.UTF-8
LANGUAGE=
LC_CTYPE="en_AU.UTF-8"
LC_NUMERIC="en_AU.UTF-8"
LC_TIME="en_AU.UTF-8"
LC_COLLATE="en_AU.UTF-8"
LC_MONETARY="en_AU.UTF-8"
LC_MESSAGES="en_AU.UTF-8"
LC_PAPER="en_AU.UTF-8"
LC_NAME="en_AU.UTF-8"
LC_ADDRESS="en_AU.UTF-8"
LC_TELEPHONE="en_AU.UTF-8"
LC_MEASUREMENT="en_AU.UTF-8"
LC_IDENTI

To rebuild the locale, run the following: (using en_AU.UTF-8 as an example)

locale-gen en_AU.UTF-8

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.

How to Upgrade Cisco Flash Firmware Version

Cisco_logo

 

I recently had to upgrade a Cisco router to a new firmware version, so I thought I’d write up a quick how-to guide.

Prerequisites:

  • Download the new flash version from Cisco here (you need a valid Cisco login)
  • TFTP the firmware to the Cisco device by following this TFTP guide
  • Connect to the Cisco device using a console cable (highly recommended!

1. Log into the router
2. Elevate to enable

enable
<password>

3. Check to see if the flash is in the correct location

dir flash:

4. Enter configuration terminal

config term

5. Disable current flash

no boot system

6. Specify flash file

boot system flash: <fullfilenameplusextension>

7. Exit out of configuration terminal

exit

8. Display the version

show version

If the last digit in the configuration register is 0 or 1 the n go to next step however if the last digit in the configuration register is between 2 and F then proceed to step 12

9. Enter configuration terminal

config term

10. Run config-register command

config-register 0x2102

11. Exit out of configuration terminal

exit

12. Copy the running to startup

copy run start

13. Restart the Cisco device

reload

When prompted to save the configuration, enter no

When prompted to confirm and reload, enter yes

If the router reboots and then reboots again straight away, it has not worked and has reverted back to the last firmware version

If it simply reboots, log in and check the version

show version

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.

Citrix XenApp: Event 10001 – A usable server cannot be found on which to launch the application. Check your worker group definitions and load balancing policies to verify appropriate servers are assigned

citrix-logo

After rebooting my Citrix XenApp server,  I was presented with an error in the application event log for the Citrix application stating the following: “A usable server cannot be found on which to launch the application. Check your worker group definitions and load balancing policies to verify appropriate servers are assigned”.

Event_10001

Details blanked out to protect the innocent

After doing a lot of Google searching, I came across a forum with someone with the same problem, to verify the issue I ran the following command:

qfarm /load

It gave me a result of “1000” which apparently isn’t right

So to resolve this issue you have to rebuild the perfmon counters, in my example I am using Microsoft Windows 2008

lodctr.exe /r

Citrix_XenApp_Qfarm_lodctr
If you need to rebuild the counters for Microsoft Windows Server 2003, see this article here

Additionally, you will find a summary of what the qfarm values are here:

0 to 9998 = This is a normal range for the load manager
99999  = No load evaluator is configured
10000 = load is at 100 percent (full)
10000! = Application disabled for this server
10001 = Out of licenses
10002 = No ICA connections are available for that server
20000 = Incorrect server edition or a license mismatch
99990 = No permission to run qfarm

It fixed the problem for me, hopefully for you too.

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.

Enable SNMP Traps on a VMware ESX 5.1 + Physical Host

LOGO1

I reinstalled my VMware ESX servers the other month and haven’t got around to setting the SNMP traps back up for Observium to use so I thought I’d make a quick article to show how it is done (as I had to look it up again).

1. Log into the console or shell to the box

2. Run the following command to set the trap name (Replace TRAPNAME with the community name you use)

esxcli system snmp set --communities TRAPNAME

2. Enable the trap

esxcli system snmp set --enable yes

3. Log into vSphere

4. Select the host

5. Select the configuration tab

6. Select Software -> Security Profile

7. Under Firewall, click properties

8. Find the SNMP Server under labelVMware ESX SNMP Server 1

9. Go into the options of the service

10. Change to “Start and stop with host”

11. Click on StartVMware ESX SNMP Server 2

 

Your traps should now be working

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.

 

Installing Piwik for Website Visitor Tracking on Apache

piwik_logo

 

Okay so I have been using Piwik for about a year now and find it to be  flawless so I thought I’d do a write up about it.

From the Piwik website: Piwik is the leading open source web analytics platform that give s you valuable insights into your website’s visitors, your marketing campaigns and much more, so you can optimize your strategy and online experience of your visitors.

Installing

Assumptions

This is assuming the following is already configured:

  • A valid public domain
  • The said public domain has A records pointing to a publicly visible Apache web server
  • The said Apache web server has a valid vhost configuration for said domain
  • The said Apache web server has PHP 5.5 or greater installed and working
  • The said Apache server has internet access to download files
  • The said web server has mySQL installed and configured correctly

Configuring Apache

Create a directing for the Piwik install, I will be using example.com as an example domain

mkdir -p /var/www/vhosts/example.com/piwik

Download Piwik

cd /var/www/vhosts/example.com/piwik
wget http://builds.piwik.org/piwik.zip

Install Unzip (if not installed)

apt-get install unzip

Unzip the contents of the zip file

unzip piwik.zip -d ../

Change ownership and permissions

chown -R www-data:www-data /var/www/vhosts/example.com/piwik
chmod -R 0755 /var/www/vhosts/example.com/piwik/tmp
chmod -R 0755 /var/www/vhosts/example.com/piwik/tmp/assets/
chmod -R 0755 /var/www/vhosts/example.com/piwik/tmp/cache/
chmod -R 0755 /var/www/vhosts/example.com/piwik/tmp/logs/
chmod -R 0755 /var/www/vhosts/example.com/piwik/tmp/tcpdf/
chmod -R 0755 /var/www/vhosts/example.com/piwik/tmp/templates_c/

Configuring mySQL

Note1: Do not use the “mysql>” at the beginning of the command, that is just to indicate you are in mysql command prompt.

Note2: mySQL commands require a “;” at the end of the command

Log into mySQL

mysql -u root -p

Create  a new database

mysql> CREATE DATABASE piwik;

Use the database

mysql> USE piwik;

Create a user

mysql> CREATE USER 'piwik'@'localhost' IDENTIFIED BY 'password123';

Grant permissions for the piwik account to the piwik database (don’t use password123)

mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON piwik.* TO 'piwik'@'localhost' WITH GRANT OPTION;

Finish Install

Browse to the Piwik installation using your browser (I am using example.com)Piwik Install Step 1

 

Select “Next”

 

Make sure everything has green ticks next to them and click “Next”Piwik Install Step 2

Leave the database server as 127.0.0.1

Type in the username

Type in the password

Type in the database name

Select PDO/MYSQL

Click “Next”

Piwik Install Step 3

 

Ensure tables are created and click “Next”Piwik Install Step 4

Type in the desired admin login name, password and email address and press “Next”Piwik Install Step 5

Type in the website name, URL, time zone and whether or not it is a ecommerce site or not and then press “Next”

Piwik Install Step 6

 

Take a copy of the Javascript tracking code and select “Next”Piwik Install Step 7

 

Click on “Continue to Piwik” to continuePiwik Install Step 8

 

If prompted, upgrade databasePiwik Install Step 9

 

I recommend donating using the secure PayPal feature, select “Continue to Piwik”Piwik Install Step 10

Sign in to start using PiwikPiwik_Sign_In

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.

Apple Mac Native VPN Drops Cisco IPSec VPN Connections

apple_logo

When using the Mac OS X (currently 10.9.4) native VPN client to connect over VPN to a Cisco device you might find it disconnects every 45 to 60 minutes without any warning and no attempt to redial to the VPN server. If you are like me and have a lot of sessions running, reconnecting them all again can be a real pain and that’s not even considering the transfers that also terminate and have to be restarted.

I was surprised to find this has been a “bug” for a while now, there does seem to be a fix but it’s designed for people that know Linux somewhat..

Here is how I solved the problem:

1. Connect to the VPN (this generates a file)

2. Copy the generated conf file to /etc/racoon

sudo cp /var/run/racoon/1.2.3.4.conf /etc/racoon

3. Edit the racoon file (I’m using vi but you could use vim or nano)

sudo vi /etc/racoon/racoon.conf

4. At the end of the file comment out the following line:

include "/var/run/racoon/*.conf";

It should look like this:

# include "/var/run/racoon/*.conf";

5. Add the following line (Change 1.2.3.4 to the IP address of your VPN server)

include "/etc/racoon/1.2.3.4.conf";

Save and close

6. Edit the following file /etc/racoon/1.2.3.4.conf (change 1.2.3.4 to the ip address of your VPN server)

sudo vi /etc/racoon/1.2.3.4.conf

7. Disable dead peer detection by changing the value to “0”:

dpd_delay 0;

8. Change proposal check from “obey” to “claim”

proposal_check claim;

9. Change the proposed lifetime in each proposal from 3600 to 86400 (24 hours):

lifetime time 86400;

Note: Change them all, not just one!

10. Disconnect and reconnect

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.

Set up Apache as a reverse proxy using mod_proxy

linux-logo-300x300

Okay so I love Apache and at every chance I will use it over Microsoft IIS or any other web serving service, unless a specific application is only written for Microsoft IIS – such as (Citrix Web Interface) !!

So in the case of only having one public IP and Citrix Web Interface behind it but wanting to host on Apache, I had to set up an Apache box to proxy all traffic for a certain domain name to the IIS box. Did I explain that well, probably not, … lets draw a picture!

Apache mod_proxy

 

Apache mod_proxy

mod_proxy is the Apache module for redirecting web pages, it isn’t just one module but rather a collection of them:

  • mod_proxy
  • modproxyhttp
  • modproxyftp
  • modproxyconnect
  • modproxyajp
  • modproxywstunnel
  • modproxywstunnel
  • modproxybalancer
  • mod_cache
  • mod_headers
  • mod_deflate

Installing Apache mod_proxy

This assumes you have Apache installed and running, if not just run the following to install:

apt-get update && apt-get upgrade
apt-get install apache2

Install Essential Build Tools

The package is required to install from source code

apt-get install -y build-essential

Install Module and Dependancies

apt-get install -y libapache2-mod-proxy-html libxml2-dev

Activating the Modules

We need to enable the necessary modules before configuring Apache, to check to see what modules are available, run the following:

a2enmod

Input the following modules to load:

proxy proxy_ajp proxy_http rewrite deflate headers proxy_balancer proxy_connect proxy_htmla2enmod

 

Restart Apache

service apache2 restart

Configuring Apache vHosts for mod_proxy

In this example I will be using “citrix.example.com” to a webserver at 192.168.0.11 as a domain and IP to get mod_proxy to redirect to, you will need to change this to suit your needs.

Create a vhost

vi /etc/apache2/sites-available/citrix.example.com

Copy and paste the following into the conf file

<VirtualHost *:80>
 ProxyPreserveHost On
 ProxyPass / http://192.168.0.11/
 ServerName citrix.example.com
</VirtualHost>

Save and quit (:wq)

Enable Site

Enable the site by running the following:

a2ensite citrix.example.com

Restart Apache

Finally, restart Apache web server

service apache2 reload

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.

How to save web form data to text file

PHP logo

 

I’ve been working to get a simple web form to post to a local file on the web server filesystem, this can be modified for your purposes but will give you a base to start with.

You will need a working Apache web server or equivalent and PHP installed and working.

index.html

1. Create a file called “index.html” and paste the following:

<form name="web_form" id="web_form" method="post" action="process-form-data.php">
 <p><label>Enter name: </label><input type="text" name="name" id="name" /></p>
 <p><label>Enter email: </label><input type="text" name="email" id="email" /></p>
 <p><input type="submit" name="s1. id="s1. value="Submit" /></p>
</form>

process-form-data.php

2. Create a file called “process-form-data.php” in the same location as “index.html” and paste the following information:

<?php
$name = $_POST['name'];
$email = $_POST['email'];
$fp = fopen("formdata.txt", "a");
$savestring = $name . "," . $email . "n";
fwrite($fp, $savestring);
fclose($fp);
echo "<h1>You data has been saved in a text file!</h1>";
?>

Input some data and browse to where you placed the php file, you will find a file called “formdata.txt” with your data seperated with a “,”

Screenshots

Initial Page

Web Form Text Input Fields

Results Page

Web Form Result Page

Should you have any questions, comments or suggestions, please don’t hesitate to comment below. If you like what you have read, please share it on your favourite social media medium.