Solution Resort

Learn, try and share…

Page 3 of 3

MySQL Integer Types

When declaring an integer in MySQL the number after the integer does not have any bearing on the size of the information in the database or the range of possible values.


INT(1) uses the same space as INT(11)


If you want to specify a smaller / different data size, this can be done with:

TINYINT  = 1byte (256 possible values)

SMALLINT = 2bytes  (65535 possible values)

MEDIUMINT = 3 bytes (16777215)

INT = 4 bytes (4294967295)

BIGINT = 8bytes (18446744073709551615 possible values!!)


The value after the type declaration INT(11), is purely an instruction suggesting to MySQL how many zero digits to left pad the number with for display.  e.g. 00000000001.   In PHP/MySQL it has no effect and is best left to the defaults.


To read more about this, go to


Ubuntu Zero To Hero Guide (best for PHP developers)

Took me quite a while to pull all these information together. This guide should install most basic packages you will need to get started with PHP Development.

*This was tested with Ubuntu 13.04 but most things should also work on Ubuntu 12.

Java First

#remove open jdk and install oracle jdk

sudo apt-get purge openjdk*

sudo apt-get autoremove

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

sudo apt-get install oracle-java7-installer


Basic Stuff

sudo apt-get install apache2 -y

sudo apt-get install php5-curl

sudo apt-get install ant -y

sudo apt-get install php5-intl

sudo apt-get install php5-tidy

sudo apt-get install mysql[*] (type in mysql and it will tell you what version to install)

sudo apt-get install mysql-server -y

sudo apt-get install php5 -y

sudo apt-get install php5-mysql -y

sudo apt-get install ssh -y

sudo apt-get install gnome-system-tools -y

#the PECL_HTTP extension
sudo apt-get install libcurl3-openssl-dev -y
sudo pecl install pecl_http -y
#when this is done, add “” in /etc/php/apache2/php.ini under the “Dynamic Extensions” section

Apache Authentication

sudo a2enmod auth_digest //install digest authentication module

Image libraries

sudo apt-get install php5-imagick
sudo apt-get install php5-gd

#I think it makes sense not to use imagick and gd directly but to use Imagine which is a wrapper for the two available on packagist. It has a much user friendly API which I highly recommend if you want a time saver.
Here is the link to it on packagist


MySQL Optimization for InnoDB, (This will significant increase the query time for InnoDB but it’s important to leave this as 1 on a live environment. For more information, see

innodb_flush_log_at_trx_commit = 0

#To debug slow queries, set the following configuration options

log_queries_not_using_indexes = on
slow_query_log = on
log_output = table

and then look at the ‘slow_query’ table in the ‘mysql’ database.

Install MongoDB

sudo apt-key adv –keyserver hkp:// –recv 7F0CEB10
echo ‘deb dist 10gen’ | sudo tee /etc/apt/sources.list.d/mongodb.list
sudo apt-get update
sudo apt-get install mongodb-10gen

#gui tool


If your Ubuntu is installed as a Virtual Machine, it’s very likely you’ll come cross using Samba to share folders so that a mapped drive can be created in your native OS to access them directly.

The easiest way to do this is by right clicking on a folder and select Sharing Options, then tick the Share this folder box and the Allow others to create and delete files in this folder box. Save your changes.

Once this is done, you’ll need to manually create a Samba user to gain access to the shared folder. This can be simply done by,

sudo smbpasswd -a <username>




sudo apt-get install php5-dev -y

sudo apt-get install php-pear -y

sudo pecl install xdebug

#then add the following lines into /etc/php5/apache2/php.ini








#finally make sure xdebug shows in phpinfo();

Xdebug – CMD setup

edit /etc/php5/apache2/php.ini and add the following section on the bottom,








I am using Netbeans as my IDE, Type in

export XDEBUG_CONFIG=idekey=netbeans-xdebug on command line and start Netbean debug session to listen on the same key.

Now, simply run phpunit <Test Script Name>.php should start the debug session.

If you need to stop debugging from command line, type in


Rabbitvcs (svn client gui on linux)

#the following line is a fix for utuntu 13.04 (please note that in Ubuntu 13.04, you can only bring up the GUI from command line. E.g. rabbitvcs commit)

sudo ln -s /usr/lib/x86_64-linux-gnu/ /usr/lib/


Firewall GUI tool

search gufw from software manager


VHost Setup

First, follow the guide from

Just a quite note, to enable or disable a vhost,

Enable: sudo a2ensite [site-name]

Disable: sudo a2dissite [site-name]


#Enable rewriteengine

a2enmod rewrite

In order to use the .htaccess file, you need to set

AllowOverRide All within the Apache config file


#install node

sudo apt-get install g++ curl libssl_dev apache2-utils git-core
sudo apt-get install python-software-properties
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

If these commands don’t work, check

Bower (A Package Manager for the web)

sudo apt-get install npm

Then follow


Install PHPUnit

Firstly, run:

sudo pear channel-discover
sudo pear install

Then run:

sudo pear channel-discover

//this may take a while depending on your internet speed
pear install –alldeps

p.s. is the most up to date official PHPUnit site. If you install it from the default pear package, it will be version 3.4 or 3.5 which has a lot of the useful features missing.  It’s possible this guide will fail because there are some dependencies missing. If that happens, follow the instructions on your screen to install the missing packages first (e.g. php-dom).

Virtual Box Mount new Disk (Centos 6)

This is a step to step guide mounting a disk to Centos 6 running on Virtual Box.

  1. Add a new disk under virtualbox setting -> storage.

  2. Set the new disk as Primary Slave

  3. Boot up centos and type in fdisk -l

You should see a disk called Disk /dev/sdb something like ,

Disk /dev/sdb: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

  1. Run mkfs -t ext3 /dev/sdb will create a partition for the drive

  2. Mount the drive to /mnt/disk-extended by typing the following commands

mkdir /mnt/disk-extended
mount -t ext3 /dev/sdb /mnt/disk-extended

  1. Finally, automount the disk on boot by adding a line to /etc/fstab

LABEL=79d3d2d4  / ext4 defaults,noatime 0 0
LABEL=e21a3e10  /boot ext3 defaults,noatime 0 0
devpts /dev/pts  devpts  gid=5,mode=620   0 0
tmpfs   /dev/shm  tmpfs   defaults      0 0
proc    /proc proc defaults      0 0
sysfs   /sys   sysfs   defaults      0 0
/dev/sdb   /mnt/disk-extended   ext3  defaults   0 0

SSH Public / Private Key Setup

Create Public / Private key pairs

ssh-keygen -t [Type of the key]  -b [Number of bits in the key to create]

e.g. ssh-keygen -t rsa -b 4096

Copy public key to remote server

ssh-copy-id -i [path to public key] [username]@[host]

e.g. ssh-copy-id -i keys/



Public key is always associated with a user when it gets copied onto the remote server. The default location storing the keys is usually ~/[user]/.ssh/. All public keys are appended to the ~/[user]/.ssh/authorized_keys file.


Useful Linux Commands

Commonly used Linux commands.

//change permissions recursively on Directories:
find . -type d -exec chmod XXX {} ;

//change permissions recursively on Files:
find . -type f -exec chmod XXX {} ;

//extract .tar.gz file:
tar -zxvf [file].tar.gz


//switch user:
su [username]

//change owner of a directory recursively
chown -Rv [username] [somedir]

//change group of a directory recursively
chgrp -Rv [usergroup] [somedir]

//add a user and add to group
useradd -G [group-name] [username]

//add a group
groupadd [groupname]

//add an existing user to group
usermod -a -G [group name] [username]

//SSH into another server
ssh -i [path/to/private/keyfile] [username]@[ip]

//Find files / folders greater than a size
du -h / | grep ^[0-9.]*G
du -h /usr/ | grep ^[1-9][0-9][0-9][0-9]*M

Page 3 of 3

Powered by WordPress & Theme by Anders Norén