Category Archives: WordPress

All things WordPress on Linux. I don’t do WP on Windows as there is no point. If you have a licenced Windows server install Hyoer-V and run up a virtual linux system for apps like WordPress. Its a much more robust process than trying to make Windows do things it was never designed to do.

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.

WordPress SME Server 8 iBay .htaccess resolved

This WordPress site is hosted in a WordPress Network setup, i.e. the equivalent of the old MU setup.

I have had this working fine on the live site (where you are now) but had issues with the wp-admin failing with a 404 error in my development server based on SME Server version 8 beta6.

As it turns out the hours of messing around I did came down to a very simple fix.

The .htaccess file has to be adapted for operation within an SME Server iBay.

The WordPress recommended configuration assumes that WordPress is in the root of the site:

[code]
# BEGIN WordPress
RewriteEngine On
RewriteBase /
[/code]

while an SME Server iBay is in fact a Rewrite process as well.

[code]
# BEGIN WordPress
RewriteEngine On
RewriteBase /ibayname
[/code]

This will allow the Rewrite’ing of the wp-admin to work with the Network settings for the virtualised sub-directories for the sub-blogs.

My Reference: Apache 2 Rewrite Documentation

My post at contribs.org the home of SME Server.