Category: Mac OS X


Installing Ansible

Ansible is a bit like puPHPet, in that it provisions Vagrant boxes etc. My latest project is using PPI Framework 2, and provisions with Ansible, so I had to get everything installed.

Essentially we just clone from the Github repo and install a few python things:

$ git clone git://github.com/ansible/ansible.git --recursive
$ cd ansible
$ source hacking/env-setup
$ sudo easy_install pip
$ sudo pip install paramiko PyYAML Jinja2 httplib2 six

And that should be you. Run ansible from the terminal in ay folder now and you should get all the available options etc. Have fun!

Advertisements

Upgrade your Terminal!

If you are using the Bash terminal, or the Mac OSX Terminal, time to get rid of it! You need Zsh! (pronounced zoosh). From the Github page:

Oh My Zsh is an open source, community-driven framework for managing your zsh configuration. That sounds boring. Let's try this again.
Oh My Zsh is a way of life! Once installed, your terminal prompt will become the talk of the town or your money back! Each time you interface with your command prompt, you'll be able take advantage of the hundreds of bundled plugins and pretty themes. Strangers will come up to you in cafés and ask you, "that is amazing. are you some sort of genius?" Finally, you'll begin to get the sort of attention that you always felt that you deserved. ...or maybe you'll just use the time that you saved to start flossing more often.

So, what are you waiting for? Give it a spin!

curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh

Or using wget:

wget https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O - | sh

Well worth a try! https://github.com/robbyrussell/oh-my-zsh

You may have noticed that if you have made your website into an iOS webapp, that <a> tags leave the app and launch in Safari, which is slightly irritating. To fix this, it’s just a little Javascript:

<script>(function(a,b,c){if(c in b&&b[c]){var d,e=a.location,f=/^(a|html)$/i;a.addEventListener("click",function(a){d=a.target;while(!f.test(d.nodeName))d=d.parentNode;"href"in d&&(d.href.indexOf("http")||~d.href.indexOf(e.host))&&(a.preventDefault(),e.href=d.href)},!1)}})(document,window.navigator,"standalone")</script>

 

Fixing the Shellshock Vulnerability

While I was on holiday in Andalucia (Olé!) a vulnerability was found for the Bash shell, called Shellshock (or BashDoor).
http://en.wikipedia.org/wiki/Shellshock_%28software_bug%29
So you’ll be wanting to secure yourself up then. First up, lets see if you are vulnerable:

env x='() { :;}; echo vulnerable' bash -c "echo this is a test"

If the output contains ‘vulnerable’, then you need to fix it. If not, you’re all good. To fix it:

sudo apt-get update
sudo apt-get -s upgrade
sudo apt-get  upgrade

Now get back on with your work! 😉

There’s a stack of different icon sizes and splash screen sizes now, depending which iPod, iPhone, or iPad you are using. iPad can also splash screen in Landscape, iPhone 5 has a different aspect ratio, etc! It has been a while since I last made web app icons etc, so I brought myself up to speed, and found the following Gist on Github:

Very handy 🙂

<!– Run in full-screen mode. –>
<meta name=“apple-mobile-web-app-capable” content=“yes”>
<!– Make the status bar black with white text. –>
<meta name=“apple-mobile-web-app-status-bar-style” content=“black”>
<!– Customize home screen title. –>
<meta name=“apple-mobile-web-app-title” content=“Web App”>
<!– Disable phone number detection. –>
<meta name=“format-detection” content=“telephone=no”>
<!– Set viewport. –>
<meta name=“viewport” content=“initial-scale=1”>
<!– Prevent text size adjustment on orientation change. –>
<style>html { webkittextsizeadjust: 100%; }</style>
<title>iOS 7 Web App</title>
<!– Icons –>
<!– iOS 7 iPad (retina) –>
<link href=“/static/images/apple-touch-icon-152×152.png”
sizes=“152×152”
rel=“apple-touch-icon”>
<!– iOS 6 iPad (retina) –>
<link href=“/static/images/apple-touch-icon-144×144.png”
sizes=“144×144”
rel=“apple-touch-icon”>
<!– iOS 7 iPhone (retina) –>
<link href=“/static/images/apple-touch-icon-120×120.png”
sizes=“120×120”
rel=“apple-touch-icon”>
<!– iOS 6 iPhone (retina) –>
<link href=“/static/images/apple-touch-icon-114×114.png”
sizes=“114×114”
rel=“apple-touch-icon”>
<!– iOS 7 iPad –>
<link href=“/static/images/apple-touch-icon-76×76.png”
sizes=“76×76”
rel=“apple-touch-icon”>
<!– iOS 6 iPad –>
<link href=“/static/images/apple-touch-icon-72×72.png”
sizes=“72×72”
rel=“apple-touch-icon”>
<!– iOS 6 iPhone –>
<link href=“/static/images/apple-touch-icon-57×57.png”
sizes=“57×57”
rel=“apple-touch-icon”>
<!– Startup images –>
<!– iOS 6 & 7 iPad (retina, portrait) –>
<link href=“/static/images/apple-touch-startup-image-1536×2008.png”
media=“(device-width: 768px) and (device-height: 1024px)
and (orientation: portrait)
and (-webkit-device-pixel-ratio: 2)”
rel=“apple-touch-startup-image”>
<!– iOS 6 & 7 iPad (retina, landscape) –>
<link href=“/static/images/apple-touch-startup-image-1496×2048.png”
media=“(device-width: 768px) and (device-height: 1024px)
and (orientation: landscape)
and (-webkit-device-pixel-ratio: 2)”
rel=“apple-touch-startup-image”>
<!– iOS 6 iPad (portrait) –>
<link href=“/static/images/apple-touch-startup-image-768×1004.png”
media=“(device-width: 768px) and (device-height: 1024px)
and (orientation: portrait)
and (-webkit-device-pixel-ratio: 1)”
rel=“apple-touch-startup-image”>
<!– iOS 6 iPad (landscape) –>
<link href=“/static/images/apple-touch-startup-image-748×1024.png”
media=“(device-width: 768px) and (device-height: 1024px)
and (orientation: landscape)
and (-webkit-device-pixel-ratio: 1)”
rel=“apple-touch-startup-image”>
<!– iOS 6 & 7 iPhone 5 –>
<link href=“/static/images/apple-touch-startup-image-640×1096.png”
media=“(device-width: 320px) and (device-height: 568px)
and (-webkit-device-pixel-ratio: 2)”
rel=“apple-touch-startup-image”>
<!– iOS 6 & 7 iPhone (retina) –>
<link href=“/static/images/apple-touch-startup-image-640×920.png”
media=“(device-width: 320px) and (device-height: 480px)
and (-webkit-device-pixel-ratio: 2)”
rel=“apple-touch-startup-image”>
<!– iOS 6 iPhone –>
<link href=“/static/images/apple-touch-startup-image-320×460.png”
media=“(device-width: 320px) and (device-height: 480px)
and (-webkit-device-pixel-ratio: 1)”
rel=“apple-touch-startup-image”>

							

cd-ing into a directory then running ./command, or worse yet, php command.php, sucks!
As an example, I wanted to run the doctrine command from anywhere.
I already have composer installed globally, and no longer have to type php composer.phar, but I haven’t blogged it since it was pretty easy, but anyway here it is:

curl -sS https://getcomposer.org/installer | php
 sudo mv composer.phar /usr/local/bin/composer

Then you can just type composer from anywhere. If you already have composer you should run sudo composer self-update. Anyway on to our php binaries (Doctrine, PHPUnit, Behat, you name it). If it’s a fresh install of composer you should see when you type composer global install:

Composer could not find a composer.json file in /home/username/.composer

Now we know where we can create our composer.json. Go to the sites for the packages you would like and copy paste the require field info; Here is Doctrine’s:

{
    "require":
    {
       "doctrine/dbal": "2.3.4",
       "doctrine/orm": "2.3.5"
    }
}

Now run composer global install and it will install in /home/username/.composer/vendor. The bin folder is inside that. Lastly we need to have our bin path set in our PATH environment variable, so the system knows to check that folder for a binary matching the command’s name. edit ~/.bashrc (it could be .bash_profile or something similar). At the end, paste this in:

export PATH=$PATH:/home/username/.composer/vendor/bin

now exit the shell and open a new terminal up and log back in. you can now type doctrine into the command line and lo and behold, your composer executables are rocking!

Sick of being asked for your password? Set up SSH authorised keys and forget about it!

you@localmachine:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa): 
Created directory '/home/you/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/you/.ssh/id_rsa.
Your public key has been saved in /home/you/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4
you@localmachine

you@localmachine:~> chmod -R go-rwx ~/.ssh

Now copy the contents of /home/you/.ssh/id_rsa.pub, and SSH in for the last time with your password to your remote machine:

you@localmachine:~> ssh user@remote.com
Password:
Last login: Tue Jan 28 14:14:51 2014 from 83.86.250.39
CentOS release 6.3 (Final)

user@remote.com:~> cd .ssh
user@remote.com:.ssh> nano authorized_keys

Paste in the contents you copied from your public key file. Make sure it is all on ONE LINE. Save and exit.

user@remote.com:.ssh> cd ..
user@remote.com:~> chmod -R go-rwx ~/.ssh
user@remote.com:.ssh> exit
you@localmachine:.ssh> ssh user@remote.com
Last login: Tue Jan 28 15:28:51 2014 from 83.86.250.39
CentOS release 6.3 (Final)

Awesome!

Yay! Free OS upgrade! But oh! Something’s bound to be affected, my apache or php or something. And you’d be right. So here are my list of issues I had, and how I overcame them.

First up, Mavericks looks really cool, and seems to zip along a lot faster than lion did. Nice one! A few other nice looking things, I’ll get into those later, but are my sites loading? I open Safari, type in one of my vhosts, and then it displays a white web page with a times new roman bold h1 tag claiming ‘It works!’. Yes, Apache is working, but not a lot else! :-s

When I finally realised a while back that all-in-one things like XAMPP are actually no good for serious development, I got my PHP running with the built in Apache, and the same tweaks apply here. Edit /etc/apache2/httpd.conf :

#LoadModule php5_module libexec/apache2/libphp5.so
to
LoadModule php5_module libexec/apache2/libphp5.so

And allow use of .htaccess to override:

AllowOverride All

That should bring you back up. I wasn’t getting any db connection, so I checked to see if my MySQL server was still running. It reported so, so I fired up SequelPro and was able to get access to my data. Hmm.

My next thought that possibly more modules for apache were needing installed or something. I checked a phpinfo();  It was running v5.4.17, with no debug or anything installed, so I guessed it was the Mavericks installed PHP. I thought, well, if I’m updating, we might as well have PHP 5.5 installed, so I went to work on that.

The terminal command ‘port’ experienced difficulties, and I quickly realised that I would need to update Xcode, and Xcode Developer Command Line Tools. Once you have done that, open Xcode up, and agree to the terms and conditions, then close it. If you don’t do this some of the terminal commands will fail.  Then you can run :

sudo port self update
sudo port upgrade outdated

I came across a hanging point when it was trying to build a thing called ‘boost’. Apparently other people on the net were complaining about the same thing but no one had an answer. After failing a few times I decided I would concentrate on just upgrading packages that I needed, so I typed this to see what was already installed: (results listed to give you an idea of what i have running)

$ port -qv installed
  apache2 @2.2.22_2+preforkmpm platform='darwin 11' archs='x86_64'
  apache2 @2.2.25_0+preforkmpm (active) platform='darwin 13' archs='x86_64'
  apr @1.4.6_1 platform='darwin 11' archs='x86_64'
  apr @1.4.8_0 (active) platform='darwin 13' archs='x86_64'
  apr-util @1.4.1_0 platform='darwin 11' archs='x86_64'
  apr-util @1.5.2_1 (active) platform='darwin 13' archs='x86_64'
  autoconf @2.69_0 platform='darwin 11' archs='noarch'
  autoconf @2.69_2 (active) platform='darwin 13' archs='noarch'
  automake @1.12_0 platform='darwin 11' archs='noarch'
  automake @1.14_0 (active) platform='darwin 13' archs='noarch'
  boost @1.50.0_0+no_single+no_static (active) platform='darwin 11' archs='x86_64'
  bzip2 @1.0.6_0 (active) platform='darwin 13' archs='x86_64'
  corkscrew @2.0_0 (active) platform='darwin 11' archs='x86_64'
  cppunit @1.12.1_0 (active) platform='darwin 11' archs='x86_64'
  curl @7.27.0_1+ssl (active) platform='darwin 11' archs='x86_64'
  curl-ca-bundle @7.27.0_0 (active) platform='darwin 11' archs='noarch'
  db46 @4.6.21_6 platform='darwin 11' archs='x86_64'
  db46 @4.6.21_8 (active) platform='darwin 13' archs='x86_64'
  db_select @0.1_2 (active) platform='darwin 13' archs='noarch'
  dirac @1.0.2_1 (active) platform='darwin 11' archs='x86_64'
  docbook-xml @5.0_0 (active) platform='darwin 11' archs='noarch'
  docbook-xml-4.1.2 @4.1.2_1 (active) platform='darwin 11' archs='noarch'
  docbook-xml-4.2 @4.2_0 (active) platform='darwin 11' archs='noarch'
  docbook-xml-4.3 @4.3_0 (active) platform='darwin 11' archs='noarch'
  docbook-xml-4.4 @4.4_0 (active) platform='darwin 11' archs='noarch'
  docbook-xml-4.5 @4.5_0 (active) platform='darwin 11' archs='noarch'
  docbook-xml-5.0 @5.0_0 (active) platform='darwin 11' archs='noarch'
  docbook-xsl @1.76.1_1 (active) platform='darwin 11' archs='noarch'
  dyld-headers @239.3_0 (active) platform='darwin 13' archs='noarch'
  expat @2.1.0_0 (active) platform='darwin 13' archs='x86_64'
  ffmpeg @0.7.13_2+gpl2+mmx (active) platform='darwin 11' archs='x86_64'
  fftw-3 @3.3.2_0 (active) platform='darwin 11' archs='x86_64'
  fontconfig @2.9.0_1 (active) platform='darwin 11' archs='x86_64'
  freetype @2.4.10_0 (active) platform='darwin 11' archs='x86_64'
  gdbm @1.10_1 platform='darwin 11' archs='x86_64'
  gdbm @1.10_2 (active) platform='darwin 13' archs='x86_64'
  gettext @0.18.1.1_2 platform='darwin 11' archs='x86_64'
  gettext @0.18.3.1_1 (active) platform='darwin 13' archs='x86_64'
  ghostscript @9.05_3 (active) platform='darwin 11' archs='x86_64'
  glib2 @2.32.4_0 (active) platform='darwin 11' archs='x86_64'
  gperf @3.0.4_2 (active) platform='darwin 13' archs='x86_64'
  gsed @4.2.1_2 (active) platform='darwin 11' archs='x86_64'
  help2man @1.40.5_3 platform='darwin 11' archs='x86_64'
  help2man @1.40.10_0 (active) platform='darwin 11' archs='x86_64'
  htop @0.8.2.1_0 (active) platform='darwin 11' archs='x86_64'
  icu @4.8.1_0 platform='darwin 11' archs='x86_64'
  icu @51.2_1 (active) platform='darwin 13' archs='x86_64'
  ImageMagick @6.7.9-0_1+q16 (active) platform='darwin 11' archs='x86_64'
  ircii @20111115_0 (active) platform='darwin 11' archs='x86_64'
  jbig2dec @0.11_1 (active) platform='darwin 11' archs='x86_64'
  jbigkit @2.0_2 (active) platform='darwin 11' archs='x86_64'
  jpeg @8d_0 (active) platform='darwin 11' archs='x86_64'
  lame @3.99.5_0 (active) platform='darwin 11' archs='x86_64'
  lcms2 @2.3_0 (active) platform='darwin 11' archs='x86_64'
  libedit @20120601-3.0_0 platform='darwin 11' archs='x86_64'
  libedit @20121213-3.0_0 (active) platform='darwin 13' archs='x86_64'
  libffi @3.0.11_0 (active) platform='darwin 11' archs='x86_64'
  libiconv @1.14_0 (active) platform='darwin 13' archs='x86_64'
  libidn @1.25_0 (active) platform='darwin 11' archs='x86_64'
  libmcrypt @2.5.8_1 (active) platform='darwin 11' archs='x86_64'
  libogg @1.3.0_1 (active) platform='darwin 11' archs='x86_64'
  libpaper @1.1.24_0 (active) platform='darwin 11' archs='x86_64'
  libpcap @1.2.1_0 (active) platform='darwin 11' archs='x86_64'
  libpng @1.5.12_0 (active) platform='darwin 11' archs='x86_64'
  libsdl @1.2.15_0+x11 (active) platform='darwin 11' archs='x86_64'
  libtheora @1.1.1_1 (active) platform='darwin 11' archs='x86_64'
  libtool @2.4.2_0 platform='darwin 11' archs='x86_64'
  libtool @2.4.2_2 platform='darwin 11' archs='x86_64'
  libtool @2.4.2_3 (active) platform='darwin 13' archs='x86_64'
  libunwind-headers @35.1_1 (active) platform='darwin 13' archs='noarch'
  libvorbis @1.3.3_0 (active) platform='darwin 11' archs='x86_64'
  libvpx @1.1.0_0 (active) platform='darwin 11' archs='x86_64'
  libxml2 @2.8.0_0 (active) platform='darwin 11' archs='x86_64'
  libxslt @1.1.26_0 (active) platform='darwin 11' archs='x86_64'
  lynx @2.8.7rel.1_1+ssl (active) platform='darwin 11' archs='x86_64'
  lzo2 @2.05_1 (active) platform='darwin 11' archs='x86_64'
  m4 @1.4.16_0 (active) platform='darwin 13' archs='x86_64'
  mhash @0.9.9.9_0 (active) platform='darwin 11' archs='x86_64'
  ncurses @5.9_1 platform='darwin 11' archs='x86_64'
  ncurses @5.9_2 (active) platform='darwin 13' archs='x86_64'
  nspr @4.8.9_0 (active) platform='darwin 11' archs='x86_64'
  openjpeg @1.5.0_3 (active) platform='darwin 11' archs='x86_64'
  openssl @1.0.1b_0 platform='darwin 11' archs='x86_64'
  openssl @1.0.1c_0 platform='darwin 11' archs='x86_64'
  openssl @1.0.1e_1 (active) platform='darwin 13' archs='x86_64'
  orc @0.4.16_0 (active) platform='darwin 11' archs='x86_64'
  p5.12-locale-gettext @1.50.0_6 platform='darwin 11' archs='x86_64'
  p5.12-locale-gettext @1.50.0_7 (active) platform='darwin 11' archs='x86_64'
  pcre @8.31_0 platform='darwin 11' archs='x86_64'
  pcre @8.33_0 (active) platform='darwin 13' archs='x86_64'
  perl5 @5.12.3_1+perl5_12 platform='darwin 11' archs='noarch'
  perl5 @5.12.4_0+perl5_12 (active) platform='darwin 13' archs='noarch'
  perl5.12 @5.12.4_0 platform='darwin 11' archs='x86_64'
  perl5.12 @5.12.4_1 platform='darwin 11' archs='x86_64'
  perl5.12 @5.12.4_2 (active) platform='darwin 13' archs='x86_64'
  php53 @5.3.16_1+libedit (active) platform='darwin 11' archs='x86_64'
  php53-curl @5.3.16_1 (active) platform='darwin 11' archs='x86_64'
  php53-ftp @5.3.16_1 (active) platform='darwin 11' archs='x86_64'
  php53-iconv @5.3.16_1 (active) platform='darwin 11' archs='x86_64'
  php53-mbstring @5.3.16_1 (active) platform='darwin 11' archs='x86_64'
  php53-mcrypt @5.3.16_1 (active) platform='darwin 11' archs='x86_64'
  php53-mongo @1.2.12_0 (active) platform='darwin 11' archs='x86_64'
  php53-mysql @5.3.16_1+mysqlnd (active) platform='darwin 11' archs='x86_64'
  php53-openssl @5.3.16_1 (active) platform='darwin 11' archs='x86_64'
  php53-soap @5.3.16_1 (active) platform='darwin 11' archs='x86_64'
  php53-sqlite @5.3.16_1 (active) platform='darwin 11' archs='x86_64'
  php53-xdebug @2.2.1_0 (active) platform='darwin 11' archs='x86_64'
  php53-xsl @5.3.16_1 (active) platform='darwin 11' archs='x86_64'
  php53-zip @5.3.16_1 (active) platform='darwin 11' archs='x86_64'
  php54 @5.4.6_1+libedit (active) platform='darwin 11' archs='x86_64'
  php54-apache2handler @5.4.6_1 (active) platform='darwin 11' archs='x86_64'
  php54-curl @5.4.6_1 (active) platform='darwin 11' archs='x86_64'
  php54-ftp @5.4.6_1 (active) platform='darwin 11' archs='x86_64'
  php54-gd @5.4.6_1 (active) platform='darwin 11' archs='x86_64'
  php54-iconv @5.4.6_1 (active) platform='darwin 11' archs='x86_64'
  php54-mbstring @5.4.6_1 (active) platform='darwin 11' archs='x86_64'
  php54-mcrypt @5.4.6_1 (active) platform='darwin 11' archs='x86_64'
  php54-mongo @1.2.12_0 (active) platform='darwin 11' archs='x86_64'
  php54-mysql @5.4.6_1+mysqlnd (active) platform='darwin 11' archs='x86_64'
  php54-openssl @5.4.6_1 (active) platform='darwin 11' archs='x86_64'
  php54-soap @5.4.6_1 (active) platform='darwin 11' archs='x86_64'
  php54-sqlite @5.4.6_1 (active) platform='darwin 11' archs='x86_64'
  php54-xdebug @2.2.1_0 (active) platform='darwin 11' archs='x86_64'
  php54-xsl @5.4.6_1 (active) platform='darwin 11' archs='x86_64'
  php54-zip @5.4.6_1 (active) platform='darwin 11' archs='x86_64'
  php_select @1.0_0 (active) platform='darwin 11' archs='noarch'
  pkgconfig @0.27_0 (active) platform='darwin 11' archs='x86_64'
  python27 @2.7.3_0 platform='darwin 11' archs='x86_64'
  python27 @2.7.6_0 (active) platform='darwin 13' archs='x86_64'
  python_select @0.3_1 platform='darwin 11' archs='noarch'
  python_select @0.3_3 (active) platform='darwin 13' archs='noarch'
  re2c @0.13.5_0 (active) platform='darwin 11' archs='x86_64'
  readline @6.2.000_0 (active) platform='darwin 11' archs='x86_64'
  schroedinger @1.0.11_0 (active) platform='darwin 11' archs='x86_64'
  scons @2.2.0_0 (active) platform='darwin 11' archs='noarch'
  snappy @1.0.5_0 (active) platform='darwin 11' archs='x86_64'
  speex @1.2rc1_0 (active) platform='darwin 11' archs='x86_64'
  spidermonkey @1.7.0_5 (active) platform='darwin 11' archs='x86_64'
  sqlite3 @3.7.14_1 platform='darwin 11' archs='x86_64'
  sqlite3 @3.8.0.2_0 (active) platform='darwin 13' archs='x86_64'
  tiff @3.9.5_0 (active) platform='darwin 11' archs='x86_64'
  urw-fonts @1.0.7pre44_0 (active) platform='darwin 11' archs='noarch'
  webp @0.2.0_1 (active) platform='darwin 11' archs='x86_64'
  x264 @20111210_0 (active) platform='darwin 11' archs='x86_64'
  xmlcatmgr @2.2_1 (active) platform='darwin 11' archs='x86_64'
  xorg-kbproto @1.0.6_0 (active) platform='darwin 11' archs='noarch'
  xorg-libice @1.0.8_0 (active) platform='darwin 11' archs='x86_64'
  xorg-libpthread-stubs @0.3_0 (active) platform='darwin 11' archs='noarch'
  xorg-libsm @1.2.1_0 (active) platform='darwin 11' archs='x86_64'
  xorg-libX11 @1.5.0_0 (active) platform='darwin 11' archs='x86_64'
  xorg-libXau @1.0.7_0 (active) platform='darwin 11' archs='x86_64'
  xorg-libxcb @1.8.1_2+python27 (active) platform='darwin 11' archs='x86_64'
  xorg-libXdmcp @1.1.1_0 (active) platform='darwin 11' archs='x86_64'
  xorg-libXext @1.3.1_0 (active) platform='darwin 11' archs='x86_64'
  xorg-libXrandr @1.3.2_0 (active) platform='darwin 11' archs='x86_64'
  xorg-libXt @1.1.3_0 (active) platform='darwin 11' archs='x86_64'
  xorg-randrproto @1.4.0_0 (active) platform='darwin 11' archs='noarch'
  xorg-renderproto @0.11.1_0 (active) platform='darwin 11' archs='noarch'
  xorg-xcb-proto @1.7.1_0+python27 (active) platform='darwin 11' archs='noarch'
  xorg-xextproto @7.2.1_0 (active) platform='darwin 11' archs='noarch'
  xorg-xproto @7.0.23_0 (active) platform='darwin 11' archs='noarch'
  xrender @0.9.7_0 (active) platform='darwin 11' archs='x86_64'
  XviD @1.3.2_3 (active) platform='darwin 11' archs='x86_64'
  xz @5.0.3_0 platform='darwin 11' archs='x86_64'
  xz @5.0.4_0 platform='darwin 11' archs='x86_64'
  xz @5.0.5_0 (active) platform='darwin 13' archs='x86_64'
  zlib @1.2.6_0 platform='darwin 11' archs='x86_64'
  zlib @1.2.7_0 platform='darwin 11' archs='x86_64'
  zlib @1.2.8_0 (active) platform='darwin 13' archs='x86_64'

As you can see I have quite a few! But I was incredibly lucky, I typed in :

sudo port upgrade curl

And it installed, also fixing the boost problem, allowing me to continue with ‘sudo port upgrade outdated’ without the error happening!

Be prepared to wait a while for all of this compiling to go on! Once you are bang up to date we can install PHP 5.5. First lets get rid of all the old stuff compiled for your old OS (actually this works when if you put a -u flag on the sudo port -u upgrade outdated):

sudo port uninstall inactive

Now for 5.5! Feel free to add more PHP modules, full list available at the macports website.

sudo port install php55 php55-curl php55-ftp php55-iconv php55-mbstring php55-mcrypt php55-mongo php55-mysql php55-openssl php55-soap php55-sqlite php55-xdebug php55xsl php55-zip php55-apache2handler

cd /opt/local/apache2/modules
sudo /opt/local/apache2/bin/apxs -a -e -n php5 mod_php55.so

Now edit your httpd.conf to load 5.5:

LoadModule php5_module /opt/local/apache2/modules/mod_php55.so

sudo apachectl restart

Job done. My thoughts on all this? First you had all in one nonsense like MAMP and XAMPP. No good. Then we have the option of using a package manager such as MacPorts or Homebrew (macports in my case), but in all honesty I really think manually compiling and configuring everything is a much better idea, as per my other posts regarding the Ubuntu server in my work.

Sick of having to recompile everything after an OS upgrade? Think about setting up a Ubuntu Server Virtual Machine using VirtualBox! And then your server can run on any machine with any configuration, and the pain will be a lot less in the future!

Feel free to comment on anything you may have come across during the process! Everyone’s set up is different!

This look familiar?

PHP Warning:  PHP Startup: memcached: Unable to initialize module
Module compiled with module API=20090626
PHP    compiled with module API=20100525
These options need to match

I don’t know about you, but i like to be up to date! My PHP is on 5.5, and I had to install some modules. But sometimes, old versions can rear their ugly head, and cause all manner of grief. Package managers do a good job to take care of all this for you, but sometimes they just don’t work. Leaving you to compile yourself! So lets do it! I’m going to install memcached, and then the imagick libraries (now i know what i’m doing!)

I’m doing this on a CentOS 6 server, but as we are doing the old skool way of compiling etc, this should work on any other flavour of Linux, or indeed Mac OS X.

First step is to download your .tar.gz  then unzip it with tar -zxvf file.tar.gz and change into the folder.
Bring up a web page displaying your servers php.ini. You are looking for the version of PHP API, and the extension_dir.
In your terminal, cd into the module source code folder, and type phpize.

If when you check the API versions , they are different from your php.ini, then an old version of php is being used in the terminal, and your module will not work! In this case, you need to get it to use the correct phpize.

type 'which phpize' to find out where the offending file is. (mine was /usr/bin/phpize)

My PHP appeared to be in /usr/local, so I tried running /usr/local/phpize. The API’s matched. So then I did the following:

mv /usr/bin/phpize /usr/bin/phpize-old
 ln -s /usr/local/bin/phpize /usr/bin/phpize

Half way there! We need to do the same for php-config

mv /usr/bin/php-config /usr/bin/php-config-old
 ln -s /usr/local/bin/php-config /usr/bin/php-config

Now you have done that, installation should be trivial, and work as per loads of tutorial/instrruction pages on the web.

./configure
 make
 make install

Finally edit your php.ini and add ‘extension = memcached.so’ (or whatever module you compiled), and restart your apache server!

EDIT : you may need to run ‘phpize –clean’ if it is still compiling with the older stuff from within the modules source folder

If you’ve ever done any sort of image processing in your PHP applications, you’ll start to realise how limited you are when using native PHP commands such as createimagefromjpg etc. It eats your web servers memory! Nowadays, what with people carrying 5 Megapixel cameras in their phones, uploading and resizing a photo can be areal strain on resources, especially if several users on the website are doing it at the same time.

To get around this conundrum, there is a PHP library called imagick which allows you to access a program called ImageMagick. ImageMagick runs natively on the machine, and is available for Unix, Linux, Mac, and Windows, so running it shouldn’t be a problem. The only thing to take into consideration here is whether your hosting providers PHP has imagick available. If not, depending on your hosting package you may be able to SSH into your server and install it.

ImageMagick can do all sorts of crazy image editing things, and can handle pretty much whatever you throw at it! Find out more here:
http://www.imagemagick.org/script/index.php

Anyway, looks good, so let’s get cracking! If you have been following my posts you’ll see I upgraded my PHP from the old version that ships with Lion using ports. I’m also going to use ports to get ImageMagick.

sudo port install ImageMagick

This will take up to ten minutes! It gets all its dependencies, configures, and compiles from the source code specifically for your computer’s setup. Once it’s done there are several commands you can run from the terminal:

animate
compare
composite
conjure
convert
display
identify
import
mogrify
montage
stream

For more info see http://www.imagemagick.org/script/command-line-tools.php

Now that we’ve done that, we need to install the imagick PHP library that accesses it.
Depending on your luck this may work straight away for you:

sudo pecl install imagick

When it asks for the prefix, type it /opt/local.

If it fails to install, you are probably running PHP 5.4 like me. In this case, you need to tell pear to use the latest beta, which WILL compile.

sudo pear config-set preferred_state beta
sudo pecl install imagick
sudo pear config-set preferred_state stable

Last but least you should add “extension=imagick.so” to php.ini, and restart apache. Boom! now we have a very powerful tool for image manipulation!

Update: If you get this error – Please provide a path to MagickWand-config or Wand-config program.
Then – ensure “ImageMagick-devel” and NOT “ImageMagick” package is installed instead