“the j stands for Jacent”
about me | research blog | wordpress plugins | jQuery plugins

21 November, 2015

Fixing Apache, PHP, Pear and Haskell Platform after upgrading to OSX El Capitan

Another OSX upgrade, another long list of things that need to be manually fixed afterwards. This time it was even worse than the Mavericks upgrade.

Enable mod_rewrite and PHP in Apache

Uncomment the following lines in /etc/apache2/httpd.conf:

LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so

Also set AllowOverride All for <Directory "/Library/WebServer/Documents">.
Restart apache with:

sudo apachectl restart

PHP

I started with a fresh config file:

sudo cp -a /etc/php.ini.default /etc/php.ini

Then added timezone information:

date.timezone = "Europe/Stockholm"

Turn off SIP

  1. Reboot into recovery mode by pressing Command + R before the apple logo appears.
  2. Open up a terminal
  3. csrutil disable; reboot

Install PEAR & PECL Mongo driver

Install PEAR:

cd /usr/lib/php
sudo php install-pear-nozlib.phar

Then add this to php.ini:

include_path = ".:/usr/lib/php/pear"

Install XCode Command Line tools with:

xcode-select --install

Next I needed to install openssl through Homebrew. This took a few steps:

sudo chown -R $(whoami):admin /usr/local
sudo chown -R _mysql:wheel /usr/local/mysql/data
brew update
brew install openssl
brew link --force openssl

Before I could build the extension I also needed this (source):

cd /usr/local/lib
sudo ln -s ../../lib/libSystem.B.dylib libgcc_s.10.5.dylib

Finally I installed the PECL Mongo driver (legacy) with:

sudo pecl install mongo

Then enable in php.ini by adding:

extension=mongo.so

And of course restart Apache again.

Haskell platform

I needed to recreate symlinks to Haskell platform programs inside /usr/local/bin.
This Stack Overflow answer explains how I did that.

Edit: After doing the above, GHC worked but whenever I tried to install anything in cabal I would get the error /usr/bin/ar: permission denied. After a lot of messing about, I had to clear everything Haskell-related and start over:

rm -rf ~/.cabal
rm -rf ~/Library/Haskell
sudo /Library/Haskell/bin/uninstall-hs all --remove
brew uninstall ghc cabal-install

And remove /Users/john/.cabal/bin from my path.
Then I installed GHC 7.10.2 and cabal from Homebrew and that seemed to work:

brew install ghc cabal-install

And add /Users/john/.cabal/bin back to my path.

Turn on SIP

Finally I turned SIP back on:

  1. Reboot into recovery mode again
  2. Run the following in a terminal: csrutil enable; reboot

21 October, 2014

Fix Apache & PHP after upgrading to OSX Yosemite

After waiting all night for OSX Yosemite to install, I finally booted into the new version of the OS… to find that Apache and PHP were no longer configured. Great. I remember a similar thing from the Mavericks update, so here is a list of the steps I followed to get things working again. Your results may very, but this may at least help.

  1. First you need to sort out the Apache config file /etc/apache2/httpd.conf, which has been reset to some default. Your old config file will be in the same directory, with some suffi like ~previous or .pre-update. In my case, I re-un-commented these lines:
    LoadModule rewrite_module libexec/apache2/mod_rewrite.so
    LoadModule php5_module libexec/apache2/libphp5.so

    I also needed to change AllowOverride None to AllowOverride Any in the <Directory "/Library/WebServer/Documents"> section.

  2. Then turn on Apache:
    sudo apachectl restart
  3. PHP’s config file has also disappeared, but again your old ones will be in /etc/ with some suffixes as above. In my case I started fresh with:
    sudo cp -a /etc/php.ini.default /etc/php.ini

    The only thing I added was:

    date.timezone = "Europe/Stockholm"

    Restart Apache again.

  4. Now I need to install PEAR. Clear anything named pear in your home directory, then:
    cd /usr/lib/php
    sudo php install-pear-nozlib.phar

    Then add the path where PEAR installed to php.ini:

    include_path = ".:/usr/lib/php/pear"
  5. I wanted to install the Mongo PECL package, which apparently requires the Command Line Tools, so:
    xcode-select --install

    And then finally I can install it:

    sudo pecl install mongo

    Add the following line to /etc/php.ini:

    extension="mongo.so"

    Then restart Apache one more time.

29 July, 2011

jQuery Clear-on-Focus Plugin

A small jQuery plugin I wrote which I thought I would make public. Instead of using <label> elements for each of your form’s fields, use the input’s value attribute to set the label. Clear-on-focus will then take care of clearing the value when a user clicks or focuses the field. If they leave the field blank, the original message is reset back. Also works correctly for password fields. Example usage:

<input type="text" name="username" value="Enter username" class="clear-on-focus" />
<input type="text" name="password" value="Enter password" class="clear-on-focus password" />

Link: github repository

16 December, 2010

jQuery Tiler Plugin

A new plugin I’m in the process of creating, for neatly tiling boxes of different dimensions into a grid.

If you have ever created tiled a layout by floating a bunch of boxes together, you may have noticed that when these boxes have different dimensions ( heights/widths) you end up with a lot of space and an altogther un-neat layout (Figure A):

Figure A: Floating of different-sized blocks leaves a lot of white space.

Figure B: By using the jquery-tiler plugin our boxes are now neatly stacked

The tiler plugin fixes this by greedily inserting each box into the column which is “shortest”, resulting in something like that in Figure B.

Note how the order of the boxes has changed. To me this is acceptable, but more importantly it is somewhat unavoidable (as someone wise used to tell me, “you have to break eggs if you want to make an omelette”).

Note that in this scenario all boxes are forced into fixed column widths. There is also some support for varying widths (i.e. preserving the width of each box) however it is far from complete. Will implement this when I have some more time (and a few more brain waves).

Anyway if you want to try it out, the git repository is here: http://github.com/johnjcamilleri/jquery-tiler

6 November, 2010

Fuzzy string matching in MySQL using Levenshtein Distance stored function

Searching for fuzzy string matching methods will return various algorithms and various implementations of them.

I found this MySQL implementation of Levenshtein Distance to be adequate for my needs, and using this handy MySQL stored function makes it super as to use in queries without having to create temporary search-optimised tables or performing post-processing in another language (eg PHP).

Just install the functions in your database, and use like so:

SELECT * FROM users ORDER BY levenshtein_distance(users.name, 'john')

20 October, 2010

Symphony CMS Extension — Backend Language Switcher

Just published my first extension for Symphony CMS: Backend Language Switcher

It’s basically a small backend utility to allow users to switch the language in which they view the backend. This is especially useful when used together with the Multilingual Field extension.

Check out the official extension thread and the GitHub repository.

28 September, 2010

jQuery Autoscale Plugin

This simple plugin basically takes a source and a target element (could be the same element) and shrinks the font-size in the target when the length of the content in the source increases.

Demo

Download

jQuery Spincrement Plugin

This is my first jQuery plugin!

It basically takes an element (divtd etc) containing a number and increments up or down to that value.

Demo

Download

A new project – Old Antonians Network

A project I’ve been working on the past few months is finally online, although there are plenty more features to come in the near future. It’s a niche social network for alumni of my old secondary school San Anton (in Malta) — or Old Antonians — hence the Old Antonians Network. It’s based loosely on LinkedIn, ie promoting professional networking rather than sharing photos and harvesing virtual crops, and it’s the first project of mine using the CakePHP framework. It’s a closed network so you won’t really be able to see any of it, but I wanted to link to it to perhaps bump it up on Google!

3 September, 2010

Goodbye GoDaddy, hello VPS.NET

So, I have finally made the move off GoDaddy shared hosting. While their stuff works and is admittedly cheap, I knew the perofmance was a bit crappy and in general just grew tired of the company. Their management panel is horrible, even though I’d gotten used to it after all these years. In addition I always found their advertising a bit offensive (I don’t need sexy women to convince me to buy their stuff) and in general too American. Using them just makes me feel cheap.

So I searched a while for a good-looking VPS solution, and found VPS.NET. Their focus on scalabilty is super, you can start out with minimal resources and then add as you go, without having to reprovision anything. I’d also read really good things about their customer service, and decided to take the plunge.

It’s still very early days, but so far I’m loving them. Everything was very fast to set up (minutes), support was very prompt and I have all the flexibiltiy I want and a really good price. As time goes by we’ll see if things remain this good.. well, just the fact that I’m already off GoDaddy is a huge relief!

Newer Posts »