Category Archives: Apache

Moving Moodle to a Plesk environment

I am migrating a moodle install from an older system into a new hosted environment with Plesk in the background.

The setup of the Plesk account is straight forward. While the transfer was simple enough using SFTP via FileZilla out of one Linux system to my workstation and off to the new server.

The first obvious task was to modify the config.php file for moodle with its new information.

The less obvious task was the error accessing the moodledata directory which for preference sits outside the Plesk default httpdocs directory.

If you are getting an error about the $CFG->dataroot being invalid or similar it will be the open_basedir setting.

Check the logs for Apache errors

[bash]
#/var/www/vhosts/your_domain_name/statistics/logs/error_log
[/bash]

to modify the default Apache settings in a Plesk world create a file called vhost.conf in the conf directory I use mcedit as my favourite Linux command line editor (apt-get install mc) (Midnight Commander tools)

[bash]

#mcedit /var/www/vhosts/your_domain_name/conf/vhost.conf

[/bash]

and create an entry like

[xml]
<Directory /var/www/vhosts/your_domain_name/httpdocs/>
php_admin_value open_basedir "/var/www/vhosts/your_domain_name/httpdocs:/var/www/vhosts/your_domain_name/moodledata"
</Directory>
[/xml]

I referenced Aaron Gadberry’s blog for the above but stumbled when it came to restarting the Apache service

[bash]

#/usr/local/psa/admin/bin/websrvmng -a

[/bash]

is no longer valid. Given that Aaron wrote his info in 2006  and 5 years later Plesk is version 10 for my server it is not surprising there is a change. The correct command for restarting / reconfiguring a single vhost is

[bash]

#/usr/local/psa/admin/bin/httpdmng –reconfigure-domain your_domain_name

[/bash]

The final part of this conversion was to modify the Moodle MySQL database to a UTF8 format.

I have used phpmyadmin for years and most Linux servers including Plesk offer it for mySQL admin.

It’s a simple thing to change the database. Just select the database in phpmyadmin and select the Operations tab. Down the bottom is the current collation in a select list. Change the selection to utf8_unicode_ci which is at the very bottom of the list and click on Go.

Plesk 10.2.0 and SSL Certificates

One of the servers I manage has a Plesk control panel. I am not familiar with it having used cpanel/whm for the last 11 years since I first got a hosted server.

I was setting up what I thought would be an easy SSL certificate install. I’ve started this post because I am now delving into the core of the server <supposition>as the damn GUI hates me.</supposition>

Before you even start, if you want to have an SSL certificate on a sub-domain site, forget it unless you a) make it a wildcard certificate or b) are prepared to have the only ip address attached to that certificate.

Plesk 10.x only allows one IP address per subscription and that is set for all the sub-domains as well as the domain attached to the subscription.

So to apply a certificate that works for the subscription it must be a wildcard certificate. i.e.

[code]
subscription_domain.tld
[/code]
sub-domains exist for
[code]
site1.subscription_domain.tld
site2.subscription_domain.tld
[/code]
certificate is for
[code]
subscription_domain.tld
[/code]
it will be applied to all the domains
[code]
https://subscription_domain.tld
https://site1.subscription_domain.tld
https://site2.subscription_domain.tld
[/code]

While the option to have a specific SSL for
[code]
site1.subscription_domain.tld
and
site2.subscription_domain.tld
[/code]
as it is not possible to split the IP addresses to isolate the SSL per IP address.

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.

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.