Archive for the ‘Tech’ Category

MaxClients (150) is not an integer multiple

Wednesday, January 23rd, 2013 | Life, Tech

Starting Apache on Gentoo, you may get warnings similar to the following.

chris@server ~/lime $ sudo /etc/init.d/apache2 stop
Password: 
 * Stopping apache2 ...
WARNING: MaxClients (150) is not an integer multiple
 of ThreadsPerChild (35), lowering MaxClients to 140
 for a maximum of 4 child processes,
WARNING: MaxClients (25) must be at least as large
 as ThreadsPerChild (35). Automatically
 increasing MaxClients to 35.                                                                                    [ ok ]
chris@server ~/lime $ sudo /etc/init.d/apache2 start
 * Starting apache2 ...
WARNING: MaxClients (150) is not an integer multiple
 of ThreadsPerChild (35), lowering MaxClients to 140
 for a maximum of 4 child processes,
WARNING: MaxClients (25) must be at least as large
 as ThreadsPerChild (35). Automatically
 increasing MaxClients to 35.

You can resolve these warnings by editing your mpm file and changing ThreadsPerChild so that MaxClients becomes a multiple of it. In this case, setting it to 25 should do the trick.

sudo vim /etc/apache2/modules.d/00_mpm.conf

Change the values and save the file. Now restart Apache and it should stop the warnings.

You could also change MaxClients, but this would only resolve the first warning, and not the second.

Imagick not loading on MAMP for Mac

Thursday, January 17th, 2013 | Life, Tech

If you’re running MAMP and you’ve finally managed to get the Imagick extension to add ImageMagick support compiled, the battle may not be over yet. There are more things you need to do. You might get an error similar to the following.

Firstly, imagick.so was probably installed into the sytem’s PHP extension directory. So you might need to copy this into MAMP’s directory. Don’t just copy and paste the code below as you need to check the paths are correct for your system.

php -i | grep extension_dir
cp /usr/lib/php/extensions/no-debug-non-zts-20090626/imagick.so
/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/

Secondly, some of the libraries are out of date. You might get an error like the following.

[01-Jun-2012 08:46:22] PHP Warning:  PHP Startup: Unable to load dynamic library 
'/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/imagick.so'
 - dlopen(/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/imagick.so, 9): Library not loaded: /opt/local/lib/libjpeg.8.dylib
  Referenced from: /Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/imagick.so
  Reason: Incompatible library version: imagick.so requires version 13.0.0 or later,
but libjpeg.8.dylib provides version 12.0.0 in Unknown on line 0
[01-Jun-2012 08:51:54] PHP Warning:  PHP Startup: Unable to load dynamic library '/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/yaml.so' - dlopen(/Applications/MAMP/bin/php/php5.3.6/lib/php/extensions/no-debug-non-zts-20090626/yaml.so, 9):
image not found in Unknown on line 0

We can solve this by editing a configuration file.

sudo vim /Applications/MAMP/Library/bin/envvars

Comment out the first two lines below and add the last one.

#DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#export DYLD_LIBRARY_PATH
export PATH="$PATH:/opt/local/bin"

This should override out of date libraries such as libjpeg. If you’re still having problems, you can manually copy in the freetype library too.

cp /opt/local/lib/libfreetype.6.dylib /Applications/MAMP/Library/lib/

Though in theory this step should not be required. Restart Apache and you should see Imagick appear on the phpinfo() output.

The mobile stack

Sunday, January 13th, 2013 | Tech, Thoughts

These days, its trendy for companies to control the entire mobile stack – Apple, Blackberry, Nokia (until recently) and several other companies all make their own hardware and mobile OS, claiming that it provides a better user experience.

However, I have to wonder if this is always the case. As mobile becomes the dominant form for computer use (in many sectors, mobile use already exceeds desktop use, in others it is rapidly catching up), it may well be that the market matures in the same way that the PC market did.

Think back to before you knew what a computer was (I originally said before you were born, but we’re probably getting too old for that now). All the PC manufacturers produced their own operating system and shipped it with the computer. It was a nightmare, nothing worked with anything else and there was no consistency – you switched hardware, you had to switch software too.

Then a young man came along, named Bill Gates (and Paul Allen of course). He had the idea of an operating system that would work across everything. Thanks to that, today, you can buy whatever hardware you want, load Windows onto it and you have a consistent experience across all hardware configurations, and all your software works on it.

It can be argued that mobile is currently in a similar fragmentation at the moment. A recent report suggested that there were now 4,000 Android devices – and that was published in May and they’ve been growing since then. Add this to the number of Windows phones, iOS devices and many other smaller operating systems (Nokia still have a huge market share in the developer world, RIM are still in there too, Samsung have their own operating system, the list goes on) – that is a huge range of devices to support.

No wonder so many companies fail to provide a consistent mobile experience, or end up saying “we’re only going to support iOS.” It would help if everyone implemented web standards to the letter, but what we really need is a Windows equivalent for the mobile world.

Installing ImageMagick and Imagick on Mac OS X

Friday, January 11th, 2013 | Life, Tech

Trying to get ImageMagick and it’s PHP extension working on OS X Lion is a frustrating process. It will often fail and even if you try to configure it manually you may get an error like the following.

checking ImageMagick MagickWand API configuration program...
configure: error: not found. Please provide a path to MagickWand-config or Wand-config program.

First of all, install ImageMagick via MacPorts.

sudo port install ImageMagick

Now install the imagick PECL module.

sudo pecl install imagick

Very importantly however, make sure you specify the path when prompted, to be /opt/local, do not let it auto detect! Once this is done it should compile successfully and you will be prompted to add imagick.so to your php.ini file.

Using whereis on Mac OS X Lion

Saturday, January 5th, 2013 | Life, Tech

Linux has a great tool called whereis that allows you to find the location of an executable. For example, if you want to know what PHP binary you are using, you could use the following command.

$ whereis php
/usr/local/php

However, if you run this on Mac it will often return you a black result, even though you know the command works!

$ whereis convert

The solution is to use which instead, which does the the same thing, but actually returns results.

$ which convert
/opt/local/bin/convert

Great for finding those extra mysterious programmes.

Updating phpMyAdmin on MAMP Pro

Sunday, December 30th, 2012 | Life, Tech

The phpMyAdmin that ships with MAMP Pro is now seriously out of date, so you’ll probably want to upgrade to the latest version. You can do this in a couple of easy steps. Firstly, download and uncompress the latest version of phpMyAdmin. I did it to my Desktop. Then, open up Terminal and enter the MAMP Pro folder and rename (best to rename rather than delete) the current phpMyAdmin.

cd /Library/Application\ Support/MAMP\ Pro/
mv phpMyAdmin phpMyAdminBackup

Next, copy in the new version of phpMyAdmin.

cp /Users/you/Desktop/phpMyAdmin-x.x-all-languages ./phpMyAdmin

Finally, you need to set up the configuration for the new phpMyAdmin.

cd phpMyAdmin
cp config.sample.inc.php config.inc.php
vim config.inc.php

Change the authentication type and add a username and password entry to the file.

$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['password'] = 'root';

If you’ve changed the MySQL root password on your MAMP Pro, you’ll need to enter the new password instead.

Once done, save the file and you’re done.

Navigating VIM on Mac keyboards

Monday, December 24th, 2012 | Life, Tech

If you’re trying to get around documents in VIM using a Mac keyboard, you may feel fairly stumped without a page up and page down button. But you need not be!

VIM has an extensive set of commands, including moving backwards and forwards through a document a page at a time. They are logically named too – Ctrl+F will go forward a page and Ctrl+B will go back a page.

Installing PECL YAML on Mac OSX Lion

Sunday, December 16th, 2012 | Programming, Tech

If you are trying to install YAML via PECL on Lion, you may get an error such as the following.

configure: error: Please install libyaml
ERROR: `/private/tmp/pear/install/yaml/configure --with-yaml' failed

Some solutions on the internet suggest installing it via a package manager.

rvm pkg install libyaml

However, although this process will claim to work, when you come to run the command again, it will fail at the same point. Instead, you need to download libyaml, which you can do here, then extract it, cd into the directory and run the following commands.

./configure
make
make install

You don’t need to sudo. You should now be able to run the install command again.

sudo pecl install --ignore-errors yaml

This time it should be successful.

Conflict error on PECL YAML

Monday, December 10th, 2012 | Programming, Tech

If you are trying to install PECL YAML on Mac OS X Lion, you may find you get a conflict with an error message similar to the following.

WARNING: pecl.php.net/yaml: conflicting files found:
yaml/LICENSE (pear.symfony-project.com/yaml)

This error is documented on GitHub and as it is not critical, can be overcome by turning off errors.

pecl install --ignore-errors yaml

On running that command, it should no longer stop at that point.

Start services automatically on boot in Gentoo

Tuesday, December 4th, 2012 | Life, Tech

If you want a service to start automatically when Gentoo boots up, you need to tell Gentoo to start it. Gentoo looks at /etc/runlevels/boot to see what it needs to run, so all you need to do is add a symlink in here to your init.d script. In this example, I’ll use exim.

cd /etc/runlevels/boot
ln -s /etc/init.d/exim exim

Next time Gentoo boots, it will see exim in the boot directory and run the script. This isn’t just limited to boot either – /etc/runlevels also has directories for shutdown and system initialisation.