Getting Ionic framework up and running on Ubuntu 14.04

Ionic is a framework for hybrid mobile app development. Throw in electron and you can get a desktop app too!

Note that this will only deal with android app development, there are likely many more steps involved with iOS.

We need the following software setup –

  • NodeJS – ionic is build  using node.
  • Android SDK – to build the android application.
  • Cordova – provides access to phone APIs regardless of platform.
  • Ionic – the framework
  • Bower – manage javascript libraries within the Ionic application
  • Gulp – build scripts for your angular app.

Installing NodeJS

There are multiple ways to install node, we are going to use nvm as it is the most powerful and flexible. It takes a little longer to set up though. Follow the previous link for the long version, here’s the short of it:

Each version of node you install has its own libraries. Some extra nvm commands:

Installing the Android SDK

You can install Android studio, but here we will just install the SDK. Firstly get the SDK downloading by going to https://developer.android.com/sdk/index.html#Other and clicking the Linux link – something like android-sdk_r24.3.3-linux.tgz. It’s a pretty big download.

While that’s happening let’s get the latest version of Java provided by Oracle.

Now back to the Android SDK – I like to install it to /opt so:

The Android SDK Manager will open, and a bunch of libs will be selected but not installed. Install them.

Once that is done you will want to create an Android Virtual Device (AVD) which is used as an emulator. In the SDK manager go Tools -> Manage AVDS , then Create. I created a Nexus 5 named nexus-5 using Google APIs – API Level 22 as the target, Google APIs ARM as a CPU/ABI and HVGA as a skin.

Now export the tool paths in .bashrc:

You should be able to run adb from anywhere now.

Installing Ionic, Bower, Gulp & Cordova

To install the following we use npm, the NodeJS package manager.

Bower helps organise javascript libraries used by our application and Gulp helps build the application.

Getting started with Ionic

Head over to http://ionicframework.com/getting-started and follow along:

 

Setting up Varnish for Drupal on CentOS 6

Varnish has an offical repository so let’s add it to Yum as outlined on https://www.varnish-cache.org/installation/redhat

Set Varnish to start on system boot

Setup DAEMON_OPTS in /etc/sysconfig/varnish, something like below. It will be commented out by default:

Edit the default.vcl file. We use the following for Drupal, which Four Kitchens kindly made available.

Now update your web server to serve from port 8080, and restart the server and varnish.

Download and enable the drupal varnish module:

Add something like the following to settings.php:

Hopefully the site is now using Varnish, you can get some good stats using the varnishlog and varnishstat programs that are included with Varnish.

Setting up memcached with Drupal 7 on Centos 6

Firstly get access to RPMForge repositories. Next install memcached:

Check memcache stats:

Configure memcache:

Configuration details for memcache can be found here

Install the PECL memcached extension for PHP

Install the memcache drupal module and configure the website via settings.php

https://drupal.org/project/memcache

You don’t need to enable the module unless you want a stats UI.

Edit your site’s settings.php, adding something like the following:

Truncate the cache table, clear the cache and check that the cache table stays empty when you load some pages. Check the memcache stats and see that data is going into the cache.

Hopefully it’s working now!

References

Drupal Memcache module – https://drupal.org/node/1131468

Configuring Memcache from the memcache wiki – https://code.google.com/p/memcached/wiki/NewConfiguringServer

 

Installing RPMForge repositories on CentOS

By default CentOS Yum has a pretty poor selection of packages compared to something like Debian. So it can be a good idea to add RPMForge to get access to more up to date packages.

Now choose the appropriate repository for the CentOs version and architecture:

http://wiki.centos.org/AdditionalResources/Repositories/RPMForge

Install the repo:

You should now have access to a heap more packages via Yum.

References

http://wiki.centos.org/AdditionalResources/Repositories/RPMForge

 

Setting up a self signed SSL certificate with Apache

I’m assuming you have Apache installed.

Enable the SSL mod for apache:

Create a directory for the certificates:

Generate the certificate:

Openssl will ask for some information, make sure you set the FQDN properly, the rest don’t matter.

Now edit your virtualhost to point to port 443:

Add the port to the server name directive:

Then enable SSL and point the virtualhost at the certificates:

Save the file and restart Apache

Now if you want to redirect non-SSL requests to the SSL port add another virtualhost that looks like the following:

Then a2ensite the new virtualhost and restart Apache once more.