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

27 October, 2016

Fixing Apache, PHP and Homebrew after upgrading to macOS Sierra

Apache

As usual, the OSX/macOS update will delete your move your old config file.
I start with the new one and make the changes I want.
In /etc/apache2/httpd.conf, uncomment the following:

LoadModule rewrite_module libexec/apache2/mod_rewrite.so

And set AllowOverride All for <Directory "/Library/WebServer/Documents">

Homebrew

To avoid the PEAR/PECL nightmare from last time, I want to use the Mongo PHP driver from Homebrew.

First, update to XCode 8 from App Store (4GB+ download!)
Then do this to read and agree to the license:

xcode-select --install
sudo xcodebuild -license

Homebrew then gives me a warning about the permissions of /usr/local, which are fixed with this:

sudo chown -R $(whoami) /usr/local

BUT this is slightly desctructive. We need this for MySQL:

sudo chown -R _mysql:wheel /usr/local/mysql/data

Using Homebrew’s PHP and PHP-Mongo extension

We’re going to use Homebrew’s PHP rather than the system one.

brew install homebrew/php/php56 --with-apache

This apparently installed httpd24, but I want to use the system’s Apache, so:

brew unlink httpd24

Then tell the system Apache use the Homebrew PHP. In /etc/apache2/httpd.conf:

LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so

Some minor configuration for our Homebrew PHP.
In /usr/local/etc/php/5.6/php.ini:

date.timezone = "Europe/Stockholm"

Then we install the Mongo driver (note I want the old mongo, not the newer mongodb) with:

brew install homebrew/php/php56-mongo

Finally restart Apache:

sudo apachectl restart

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.

5 April, 2013

The sad unreliability of Ubuntu One

I started using Ubuntu One more or less when it was first released. Admittedly it was pretty slow in the beginning, but they seemed to improve their speeds a lot and eventually I began to pay for extra space and use Ubuntu One exclusively for all my cloud syncing – some 3000 files from my entire Documents folder, and around 1,500 pictures. I used two Ubuntu machines and I thought U1 worked pretty well in making sure that I always had the most recent versions of everything on both machines.

I first noticed a problem with the syncing when by accident I noticed a that a folder which showed up on the U1 web interface was not on my computer. I tried various things to get this to work, trying all the command line options to u1sdtool, restarting, stopping/starting syncing etc. Eventually I wrote about it on Ask Ubuntu, and ended up getting in touch with U1 support. Their solution was to essentially clear all the cached syncing info on my machine and start again. Admittedly, this worked (although it did require that U1 scan and compare every single file again). I got the missing folder to sync, and everything seemed OK.

Things seemed OK for a few months. The a few weeks ago I got a new machine, a MacBook Pro. I still use Ubuntu at work, and since there is a U1 client for OSX I thought there should be no problem in continuing to use Ubuntu one for my syncing. This is when things really started going downhill. The initial sync on my Mac worked fine – I mean essentially it’s just downloading everything, pretty straightforward. But then I began to notice that some changes made would not get noticed by U1. Say I would delete a file from my Mac, but it would still appear in the web interface even though the U1 client would tell me that everything was up-to-date. This is really when I began to stop trusting it. Again I would try all the command line options for refreshing the sync folders, nothing. When I contacted U1 support again, they just had exactly the same solution – delete the caching data and re-sync. I did, it took it’s time to re-check every single file, and again things seemed OK again. But then I would add/delete some other file and notice that again that Ubuntu One would fail to notice them. There are things you can do to force it to notice the changes, like restarting the computer or un-checking and re-checking the “Sync locally” checkbox inside the client. But that defeats the whole purpose.

To make things worse, I’m also starting to notice this same erratic syncing behaviour from my Ubuntu machine too. And now I have absolutely no idea if there even exists a single complete version of all my files, anywhere. It feels like every computer I used U1 has some copy of my files, but is never 100% complete/updated. It’s a mess. There’s just too many files to check manually. I have backups, and I hope that when I look for a file and find that Ubuntu One has lost it, I can find it by digging into these backups. But that’s hardly a solution.  I absolutely cannot trust Ubuntu One anymore.

But I still want a cross-platform syncing solution. iCloud doesn’t have an Ubuntu client (and I haven’t heard good things about it anyway). Neither does Google Drive, although they keep promising one “soon”. Dropbox has clients for both and is starting to look like a real viable alternative now. I guess it’s popularity compared to U1 will mean it’s more reliable. But it’s going to take some work to move everything over, and I really want to avoid switching.