Monthly Archives: May 2011

MySQL & PHP Upgrade CentOS server

I now appear to have a new Linux VPS running with CentOS and Plesk. I wont go into the stupid details of why this has taken 2 weeks to provision, or another 2 days for me to ‘fix’ the ip addresses etc, only to find that CentOS has an older version of PHP at 5.1 and MySQL needing to be upgraded to match with PHP 5.3 when I tried to upgrade.

I referenced Christian Montoya’s blog for the update for PHP but found that I had a couple of issues.

The first was that when I ran the yum command for the PHP upgrade it complained about the MySQL support / version.

yum update php

was changed to include MySQL

yum update php mysql

Which did what I needed.

Running the

php -v

Advised that the updated 5.3 version was installed but I then found that MySQL was not running.

A quick wade around discovered that /var/log/mysqld.log that there was another error preventing MySQL from starting. This was the message:

[ERROR] /usr/libexec/mysqld: unknown option '--skip-bdb'

Editing the /etc/my.cnf file to comment out this option in both the main section and the mysql_safe section of the file fixed this issue and allowed MySQL to start.

Next I had in the mysql log messages like:

[ERROR] Column count of mysql.proc is wrong. Expected 20, found 16. 
Created with MySQL 50077, now running 50156. 
Please use mysql_upgrade to fix this error.

So trying to use mysql_upgrade as a command by itself fails for user root@local host

]# mysql_upgrade
Looking for 'mysql' as: mysql
Looking for 'mysqlcheck' as: mysqlcheck
Running 'mysqlcheck with default connection arguments
mysqlcheck: Got error: 1045: Access denied for user 'root'@'localhost' (using password: NO) when 
trying to connect
FATAL ERROR: Upgrade failed

Using the correct username is as simple as

#mysqlupgrade -u username -p  [Enter]

Which will prompt you for the password and then run the upgrade with the authenticated username.

And that, I hope, completes the backend upgrade so I can run SugarCRM on this server.

Gallery 3 and WordPress 3 plugins and problems

Gallery 3 is a photo gallery while WordPress provides for blogs and pages to be made. WordPress handles media but not as nicely as Gallery and as I already have (currently) 800+ photos in Gallery I did not want to go manually migrating. Hence a link between Gallery and WordPress would be good.

A number of plugins for WordPress exist and a number of extensions to Gallery exist. However to get them working is not a simple task.

The ones I have tried and the issues that I had to modify on my SME Server 8 to get them running is detailed here.

Gallery3 Client (G3Client) WordPress plugin

The first issue I had to resolve was that after install I kept getting an error

Could not connect to Gallery3: failed to connect to Gallery3 (http status code: 0)

The http status of 0 was odd and it took me a while to work it out. Which I did while looking at the next plugin. I documented the fix which was related to cURL and not having my DNS set correctly on the server.

Once that was resolved, I then had a similar error

Could not connect to Gallery3: failed to connect to Gallery3 (http status code: 302)

I documented the fix for this open_basedir restriction in effect in Apache in another post.

Gallery 3 Picker is the other plugin for WordPress that I tried.

I experienced the same errors with cURL as with the first plugin.

At first the Gallery3 Picker would just this message.

Detected REST tree support, will use this.

I was not sure what this meant as there was no ‘Ok’ message to indicate that it is working.
If I tried to add media from the gallery in WP, the title of my Gallery appears ok but the page states

Module not configured
Sorry, but your Gallery3 module configuration doesn’t seem to work:
there is an error possibly with CURL. No mod rewrite.
Please go here to configure

Which lead me back to the plugin configure page.

In the end I worked through the code for the picker.php file and established the issues with cURL and SME Server as noted above. I made a suggestion on handling the cURL error in the Gallery forum.

I now have both of these WordPress plugins working as designed and they appear very good.

cURL returns 0 due to DNS error on SME Server

In my trials of getting Gallery and WordPress to interact on SME Server I discovered that I had not configured my DNS settings correctly.

If you use one SME Server then this will not be an issue. It will only arise in a multiple SME Server network and only if you are a bit slack, as I was, with setting the various hostnames.

In a single SME Server all the host names are setup automatically and you can add additional aliases for your server. This will never impact on cURL as when it is used the localhost DNS responds correctly.

In my case I have a second SME Server that is set up for my dev sites and is imaginatively called devsites as an alias. I set this up in the primary server hostnames for the same IP address as my dev sites server and as that worked for all the workstations in my network I promptly forgot about it.

As I worked with Gallery and WordPress plugins I found that cURL was not responding correctly and it took me a while to finally try using cURL at the command line on the server to establish the issue.

Testing cURL at the command line made it obvious.
[php]# curl -v http://devsites.mydomain/mysite/gallery/index.php[/php]
results in
[php]* getaddrinfo(3) failed for devsites.mydomain:80
* Couldn’t resolve host ‘devsites.mydomain’
* Closing connection #0
curl: (6) Couldn’t resolve host ‘devsites.mydomain’
[/php]

Obviously if cURL cannot resolve the host, the plugin will never work.

Adding the alias to the local machine meant that it would now resolve the DNS entry and cURL could do its lookup.

The specific gallery / wordpress plugin is Gallery3 Media Picker and I documented the specifics of what I did in the picker.php to provide support if cURL is not working in the appropriate thread in the Gallery 3 Forums.

SME Server and open_basedir restriction affects cURL

This is another little item that I wanted to document before I forget what was done and why.

Using SME Server 8.0beta6 for my web development server. I like the ibay options for quickly setting up new sites for testing and knowing that it will be consistent with any other ibay and therefore comparison of software app versions is easy.

That said I had an issue with using / linking Gallery 3 and WordPress 3 on my server.

I posted to the forums for each of the applications but figured I’d note the details here as well.

The title of this blog entry is relating to cURL and the open_basedir restriction in Apache on SME Server and this is one of the issues I came across. It may equally apply for anyone using a piece of software that uses cURL features.

In the server or php log (/var/log/messages on SME Server) I kept getting this message:

PHP Warning:  curl_setopt() [function.curl-setopt]: CURLOPT_FOLLOWLOCATION cannot be activated when in safe_mode or an open_basedir is set in /home/e-smith/files/ibays/mysite/html/wp-content/plugins/g3client/client.php on line 72

On SME Server for a permanent adjustment you will need to modify one of the httpd.conf template files.
I documented the basic format for this file in another entry ‘SME Server httpd.conf open_basedir path to include /tmp‘. If you have not done this before you’ll need to start with that part of the process then do the following.

On your SME Server go to

# cd /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/

Edit the existing template snippet file 95AddType00PHP2ibays (with your preferred editor)
Find the line with the php_admin_value setting

$OUT .= ” php_admin_value open_basedir $basedir:/tmp:/usr/share/pear:/usr/share/pear-addonsn”;

and insert the if statement immediately above the line with the php_admin_value as shown

if ($ibay->key eq ‘insert_your_ibay_name_here‘) {
$OUT .= “#openbase_dir disabled for this ibayn”;
$OUT .= “#”;
}
$OUT .= ”    php_admin_value open_basedir $basedir:/tmp:/usr/share/pear:/usr/share/pear-addonsn”;

This will comment out ‘#’ the open_basedir line for the specified ibay and cURL will now work as required.

If your SME Server is public facing then this may introduce a security risk so use with caution.

In my case the server is private and only risks being messed up by me.