Tuesday, 27 November 2012

Building PHP

Most of yesterday and today I have just been trying to get PHP installed. I was getting a build error, but didn't know what was causing it. No-one else seemed to know either.

(The problem was that it was trying to load /lib/libgcrypt.la, which doesn't exist on my system. It did this even when I told it to look in the folder (not /lib/) where I had installed a copy of libgcrypt.

So I had to keep running configure followed by make, using a slightly different set of configure options each time, until I found the configure option that was causing the make to fail.

Eventually I found that PHP would build okay without --with-xsl=$HOME/apps/libxslt. Sure enough, if I check $HOME/apps/libxslt/lib/libexslt.la, I have the following line:

# Libraries that this one depends upon.

dependency_libs=' /lib/libgcrypt.la /home/djeyewater/apps/libxslt/lib/libxslt.la -L/home/djeyewater/apps/libxml2/lib /home/djeyewater/apps/libxml2/lib/libxml2.la -ldl -lz -lm'

My guess is that when I built libxslt, Ubuntu included /lib/libgcrypt.la. But in an update this file must have been removed.

While I was trying to figure out what was causing this error, I also came across another PHP build error:

libcurl.so: undefined reference to `ldap_parse_result@OPENLDAP_2.4_2'

Some research revealed that this is likely due to conflicting ldap libs. I rebuilt curl with the option --with-ldap-lib=$HOME/apps/openldap/lib, and this seemed to solve the issue.

The strange thing is though, that after configuring CURL, it said something like "with ldap (--enable-ldap / --with-ldap-lib / --with-lber-lib) no". It seems strange that:

  1. It said ldap was not enabled even though I did use the --with-ldap-lib option
  2. That the version of CURL I already had installed contained a reference to ldap, since I would not have configured it with ldap enabled.

I had problems building icu4c as well (needed for internationalization). When I tried to build the latest version (1.5) on Ubuntu, I got the following errors:

   gcc  ...  umutex.c
umutex.c:211:1: error: conflicting types for ‘umtx_lock_50’
umutex.h:208:1: note: previous declaration of ‘umtx_lock_50’ was here
umutex.c: In function ‘umtx_lock_50’:
umutex.c:223:9: warning: implicit declaration of function ‘umtx_init’ [-Wimplicit-function-declaration]
umutex.c: At top level:
umutex.c:248:1: error: conflicting types for ‘umtx_unlock_50’
umutex.h:214:1: note: previous declaration of ‘umtx_unlock_50’ was here
umutex.c:314:1: warning: no previous prototype for ‘umtx_init’ [-Wmissing-prototypes]
umutex.c:314:1: warning: conflicting types for ‘umtx_init’ [enabled by default]
umutex.c:223:9: note: previous implicit declaration of ‘umtx_init’ was here
umutex.c:359:1: warning: no previous prototype for ‘umtx_destroy’ [-Wmissing-prototypes]
*** Failed compilation command follows: ----------------------------------------------------------
gcc -D_REENTRANT -I. -DDEFAULT_ICU_PLUGINS="/home/djeyewater/apps/icu4c-50.1/lib/icu"  -DU_ATTRIBUTE_DEPRECATED= -DU_COMMON_IMPLEMENTATION -O2 -Wall -std=c99 -pedantic -Wshadow -Wpointer-arith -Wmissing-prototypes -Wwrite-strings -c -DPIC -fPIC -o umutex.o umutex.c
--- ( rebuild with "make VERBOSE=1 all" to show all parameters ) --------
make[1]: *** [umutex.o] Error 1
make[1]: Leaving directory `/home/djeyewater/tarballs/icu/source/common'
make: *** [all-recursive] Error 2

So I went back to 1.4.9.2, which I had previously built successfully (and rebuilt it okay just to check). But when I tried to install it on the webserver (which runs CentOS), I got a few errors about undefined references to __sync_fetch_and_add_4 and __sync_val_compare_and_swap_4, and the build failed.

After some research, and trying various different things, I found that you needed to add CFLAGS="-march=i486" to the configure line, then it would build okay.

The other thing I was doing yesterday and today (while waiting for PHP configures / builds to process) was writing and taking photos for an article for my photo tips website.

Saturday, 24 November 2012

Greeeeeeeeeee

Today I was mostly trying to finish updating my website to HTML, and then getting it working on the webserver. I had quite a few issues, but it seems to be okay now.

In the evening I also processed some of the photos I took on my afternoon walk yesterday:

Friday, 23 November 2012

Being

Most of yesterday I was trying to update wordpress on the dev version of my photo website. The problem was that I was getting strict standards errors because the WP_Widget class has bothe PHP4 and PHP5 style constructors.

Researching this, it seems that an error should be thrown, and this is a bug in PHP. I tried rebuilding PHP a few times, but still got the same error I did last time about libgcrypt.la not being found.

So I decided to just turn off strict error reporting for the blog for the moment. But this didn't work, and I still got strict standards errors. I thought that the [PATH] and [HOST] directives in my php.ini must not be taking any effect. Looking in the PHP manual, I found a comment by someone else to a similar effect:

This doesn't seem to work with php-fpm.

The values defined under PATH or HOST will become the new master value for all the processes (as if they were redefined).

So, I looked for a different way that I could use different error reporting levels for my different sites. One solution mentioned on a few websites was .user.ini files. But I found these have no effect under php-fpm.

Next I found that you can set PHP_VALUE flags from the php-fpm config. But this can only be set per pool. So you would need to set up a different pool listening on a different socket for each website. This would create too many php processes and use up to much memory to work for me.

Then I found that you can actually set PHP_VALUE flags from nginx:

set $php_value "pcre.backtrack_limit=424242";
set $php_value "$php_value \n pcre.recursion_limit=99999";
fastcgi_param  PHP_VALUE $php_value;

fastcgi_param  PHP_ADMIN_VALUE "open_basedir=/var/www/htdocs";

However, when I tried this I found that the error_reporting level sent by Nginx seemed to be overridden by the error_reporting level set in php.ini.

I then found that you can use variables within php.ini. But the lack of nestable variables makes that not quite so useful.

I thought that in theory I should be able to have a default value in nginx.conf, like

set $php_value "error_reporting=E_ALL|E_STRICT";
and then override it in the website config, like
set $php_value "error_reporting=E_ALL";
And in php.ini remove all error_reporting directives so that the PHP_VALUE is not overridden.

But then I read that the PHP constants are not available outside of PHP, e.g. in httpd.conf. Instead you need to use the bitmask values.

So this morning I ran a test, using different numbers for [PATH] and [HOST] sections in php.ini and location sections in my site's nginx config. Result:

  • PHP_VALUE in nginx config is always overridden by php.ini value.
  • PHP_VALUE for location /path/ does not affect sub folders of /path/ (value set for location / is used for /path/subfolder)
  • Both [HOST] and [PATH] settings in php.ini do work, and don't seem to be overridden by previous or later settings for different [HOST] and [PATH] blocks

So, why was my blog still showing strict errors when I had E_ALL|E_STRICT set for the host, but E_ALL&~E_DEPRECATED set for the blog's path? In the end it turned out to be very simple - From PHP 5.4.0 E_STRICT has been included within E_ALL. I did read this earlier, but it didn't really sink in, and I didn't think to check my PHP version.

So a lot of work for nothing really, though I did learn some new things (can set PHP_VALUEs from nginx, can use variables in php.ini).

In the afternoon I went out and took some photos.

In the evening I listened to Will Challoner (AKA Wilson Channeller AKA Wilbert AKA Wilmington) with Billy while I worked on my kodak jr. bellows camera bit.

Wednesday, 21 November 2012

Diddling

This morning I started up my IE7 VM that had had loads of errors and taken hours to shutdown before finally crashing yesterday. But it still had delayed write failed error messages today, so it seems all my waiting for it to shutdown properly yesterday was in vain. I should have just force shut it down - it wouldn't have mattered if windows had become corrupted due to shutting down since it was unusable anyway.

So I deleted the VM files, and restored by backup copy. Thankfully the backup seems to be fine, and it is currently installing the Windows updates as I write this.

I spent quite a bit of the day waiting for the IE7 and IE8 VMs to update. Then I did a bit of work on my website, and found a very strange IE7 (or jquery in IE7) bug. I had an element like <dd>Some text</dd>. When I retrieved the value like ('dd').text(), the result would be 'Some text ', with an extra space added onto the end. This messed up my site as I was doing a comparison with the value, obviously expecting the returned value to be 'Some text'. I ended up just applying a trim to the result to remove the extra space in IE.

In the evening I played on Mario Land with Billy for a bit, and bought some custom design T-shirts.

Tuesday, 20 November 2012

Clicking OK on error messages

Today it seems that I mostly clicking 'OK' on error messages. That didn't really take up most of my day, but it seemed like it did.

I wanted to do some more work in moving my website over to HTML5. As part of this, I need to check the changes I'm making don't break the website in different web browsers, such as IE6 and IE7. To check these, I fired up my Windows Virtual Machines that have IE6 and IE7 on them.

Since I hadn't used the VMs for quite a while, they had a load of Windows Updates that needed to be installed. On the IE7 machine though I kept getting "Delayed Write Failed" error messages. Eventually I thought it best to just shut the (virtual) machine down, and try starting it again. But I made the mistake of clicking "Shut down and install updates" instead of "Shut down without installing updates".

It then took several hours for the machine to shut down, during which it regularly spat out "Delayed Write Failed" error messages that had to be dismissed. I didn't want to do a forced shutdown, as the message on the screen said that it may become corrupted if you don't wait for the updates to finish installing.

And when it finally finished the process, it just crashed.

Other things I did today was posting a photo to various websites. I wrote up a recipe and posted it on my recipe blog. I played Super Mario Land on the Super Game Boy on the Super NES with Billy. I sorted through some insect photos and did descriptions for one, then uploaded it.

Monday, 19 November 2012

Researching

Today I finally managed to post an update on my photo website blog. Most of the day was spent researching a couple of photos so I could write descriptions for them.

Saturday, 17 November 2012

exposure fusing

The last few days I have just being doing some work on the CTH website, and also trying to process a photo. I have been trying various fusion programs and also photomatix in an attempt to blend two exposures. Unfortunately I haven't been able really to get any to keep good detail in the sky while making the building in the image keep a good level of brightness. They all seem to make the building too dark for my tastes.

The exposure fusion programs I tried seem to offer very little control over how the final image turns out. Moving the sliders from one extreme to another only results in a subtle change to the image at best. Another problem was that there didn't seem to be any way to remove ghosts with these programs.