creating a development machine

How to set up a world-class development machine for less than $1000:

  • purchase basic 15" laptop. Important are: plenty of RAM, SSD, reasonably fast processor
  • install ubuntu alongside windows or on its own

We use the following stack / setup:

  • Ubuntu 16.04 - with downgraded PHP version (5.6) - for now
  • All websites live in the /var/www folder (e.g. /var/www/
  • All sites can be accessed locally using, for example,
  • Atom as editor
  • Gimp as graphics tool
  • Geany as backup editor
  • Custom git committer:


Ubuntu Installation hints

In order to preserve users files between Ubuntu upgrades/reinstallation it is desirable to keep system and users files in different partitions. This practice makes System management easier along the years. While installing UBUNTU, the installer will offer an automatic installation that will create 2 or 3 partitions. Usually one "ext4" for the system (where the root directory "/" will be installed) and another swap for memory swapping (preferably twice as big as your RAM).  

If your computer BIOS is modern, it will be managed by an Unified Extensible Firmware Interface (UFEI or EFI). In this case, your LINUX-OS needs to have  a 3rd partition, preferably in the beginning of the hard disk, to install an UFEI boot loader.
The file system structure describe above is usually installed alongside a Windows partition if you want your system to have a dual boot. Although this structure works perfectly, the /home folder with the users files lives inside the same partition as the rest of the system. If for any reason you would like to format it all users data will be lost (obviously you might keep a backup of the files somewhere else (:D)!). This can be solved in two ways. You can define your partition manually before installing the system (you must be careful and include the partition for the UFEI boot loader), or your can follow the automatic installation and split the system partition afterwards. Here the second option will be described.

Once your UBUNTU has finished the installation, reboot the system using the USB stick and choose Try Ubuntu. This will give you a Live system, which allows you to make some changes in your disk structure. After UBUNTU has booted up, open the gparted program from your UBUNTU menu. 

Ubuntu menu gpartedIn the gparted GUI choose the partition formatted as ext4 and resize to 40-60GB, which is plenty for your system to run smoothly. Apply these changes.

You will be left with an unallocated space between the root partition and swap. Delete the swap partition (it will be recreated later). Create a new partition in the unallocated space and leave twice the size of RAM available (for swap), create a label "/home" for future identification.newPartition

In the space left create the a swap partition, such as bellow.
new swap partition

 At the end your partition table should look like the following.

gpartedAfter this, reboot your system to the installed one. The created partitions must be declared in mounting table, which is described in the /etc/fstab file. For the structure shown in the picture above /etc/fstab looks like. 

# /etc/fstab: static file system information.
# <file system> <mount point> <type> <options> <dump> <pass>
# / was on /dev/sda2 during installation
UUID=4bd62067-9f1b-42bd-a1ad-d9278ee6da58 / ext4 errors=remount-ro 0 1
UUID=dd9789db-9b84-4c4e-92bd-8c871ba6cbcd /home ext4 errors=remount-ro 0 1
# /boot/efi was on /dev/sda1 during installation
UUID=ED88-3EF2 /boot/efi vfat umask=0077 0 1
# swap was on /dev/sda3 during installation
UUID=444df643-a53f-4a98-ac06-1e8109c36309 none swap sw 0 0

The UUID of each partition must be copied accordingly. UUID's can be obtained with gparted software, right click on the partition, ->information. 

Once UBUNTU is installed, run the following script:

Make sure that you replace each instance of [user] with the appropriate user

# Installing the necessary packages

#latest and greatest sudo apt-get update #svn sudo apt-get install subversion #git sudo apt-get install git git config core.fileMode false git config --global core.filemode false
#php and apache settings and extras # php 5.6 (downgrade) sudo apt-get purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "` sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install php5.6

# php modules
sudo apt-get install libapache2-mod-php5.6
sudo apt-get install php5.6-mcrypt
sudo apt-get install php5.6-curl
sudo apt-get install php5.6-tidy
sudo apt-get install php5.6-gd
sudo apt-get install php5.6-gd
sudo apt-get install php5.6-curl
#apache sudo apt-get install apache2 #mysql sudo apt-get install mysql-server sudo apt-get install libapache2-mod-auth-mysql sudo apt-get install php5.6-mysql sudo /usr/bin/mysql_secure_installation
# php5.6 modules
## mcrypt
sudo apt-get install php5.6-mcrypt sudo phpenmod -v php5.6 mcrypt

# apache modules sudo a2enmod rewrite sudo a2enmod vhost_alias sudo service apache2 restart

#phpmyadmin sudo apt-get install phpmyadmin locate php.ini
#change php.ini (see below) sudo geany /etc/php5/apache2/php.ini #edit sites-enabled (see below) sudo geany /etc/apache2/sites-enabled/000-default.conf sudo service apache2 restart #meld sudo apt-get install meld #geany sudo apt-get install geany sudo chown [your name] ~/.config/geany -R #composer curl -sS | php sudo mv composer.phar /usr/local/bin/composer #composer install
sudo add-apt-repository ppa:webupd8team/atom
sudo apt update; sudo apt install atom
#test site sudo chown yourname:www-data /var/www/ -R sudo nano /etc/hosts cd /var/www/ composer create-project silverstripe/installer test 3.1.10 cd test ls chmod 0777 . -R ls #ssh sudo nano ~/.ssh/config ssh-keygen -t rsa -b 4096 -C "[user]" #install google chrome wget
sudo apt-get install libxss1 libgconf2-4 libappindicator1 libindicator7
sudo dpkg -i google-chrome-stable_current_amd64.deb #install gimp sudo add-apt-repository ppa:otto-kesselgulasch/gimp sudo apt-get install gimp

Bash Setup

echo "cd /var/www/" >> ~/.bashrc

# php.ini settings, eg:

date.timezone = 'Pacific/Auckland'



chmod +x phpdox-0.8.1.phar
sudo mv phpdox-0.8.1.phar /usr/bin/phpdox

You can also set up a few shortcuts for git (commit + push origin master). 

PSR2 Fixer

wget -O php-cs-fixer
sudo chmod a+x php-cs-fixer
sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer

Apache setup:

<VirtualHost *:80>
   DocumentRoot /usr/share/phpmyadmin

<VirtualHost *:80>
        ServerName localhost
        ServerAlias localhost *.localhost
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        VirtualDocumentRoot /var/www/%-2+/

        <Directory />
                Options FollowSymLinks
                AllowOverride None

        <Directory /var/www >
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
                RewriteEngine On
                RewriteBase /
                SetEnv HTTP_MOD_REWRITE On
                RewriteEngine On
                RewriteCond %{REQUEST_URI} ^(.*)$
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteRule .* sapphire/main.php?url=%1 [QSA]

                RewriteCond %{REQUEST_URI} ^(.*)/sapphire/main.php$
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteRule .* framework/main.php?url=%1 [QSA]

        ErrorLog ${APACHE_LOG_DIR}/error.log

        LogLevel debug


 Atom Config

      default_beautifier: "CSScomb"
      disabled: true
    php: {}
    disabledPackages: [
    excludeVcsIgnoredPaths: false
    ignoredNames: [
    openEmptyEditorOnStart: false
    projectHome: "/var/www/"
    telemetryConsent: "no"
    fontSize: 11
    invisibles: {}
    showInvisibles: true
    softTabs: false
    tabLength: 4
    tabType: "soft"
    normalizeEolOnSave: "Unix (LF)"
    onSave: "untabify"
  "tree-view": {}
    showOnStartup: false
    tabLength: 4
    tabLength: 4
    tabLength: 4
    tabLength: 4
    tabLength: 4

Key Map

  'ctrl-D': 'editor:duplicate-lines'
  'ctrl-space': 'tabs-to-spaces:untabify'

Installed Packages

  • atom-silverstripe
  • autoclose-html
  • autocomplete-php
  • cssbeautify
  • docblockr
  • duplicate-line-or-selection
  • editorconfig
  • go-config
  • go-get
  • language-SCSS
  • line-ending-converter
  • navigator-godef
  • php-integrator-autocomplete-plus
  • tabs-to-spaces

adding yourself to www-data group:

sudo usermod -a -G www-data myusernameoncommandline
id myusernameoncommandline
groups myusernameoncommandline

Switching php Versions

# Install php7.0 and install the php7.0 versions of extensions
sudo apt-get install php7.0 php7.0-curl php7.0-mysqli php7.0-mbstring php7.0-xml php7.0-intl
#make sure both php5.6 and php7.0 are installed
sudo a2dismod php5.6
sudo a2enmod php7.0
sudo service apache2 restart