Category Archives: Linux Servers and Software

General Linux server and software information.

sugar_file_utils.php Fatal error: on migrating SugarCRM

[text]Fatal error: sugar_file_put_contents_atomic() : fatal rename failure ‘/tmp/tempI3QakJ’ -> ‘cache/modules/Employees/Employeevardefs.php’ in /home/account_name/public_html/sugarcrm/include/utils/sugar_file_utils.php on line 187
[/text]

It’s a permissions thing. Setting up a new server to migrate SugarCRM. The new install of Sugar appears ok until I update the config.php file and then it breaks.

The trigger is the permissions on the second named file

[text]
‘cache/modules/Employees/Employeevardefs.php’
[/text]

Just for clarity the line 187 that is referenced is in this function in SugarCRM

[php]
180 if (!@rename($temp, $filename))
181 {
182 @unlink($filename);
183 if (!@rename($temp, $filename))
184 {
185 // cleaning up temp file to avoid filling up temp dir
186 @unlink($temp);
187 trigger_error("sugar_file_put_contents_atomic() : fatal rename failure ‘$temp’ -> ‘$filename’", E_USER_ERROR);
188 }
189 }
[/php]

The error is triggered when line 183 fails to rename the temp file as the cache file. Permissions on the temp directory must be ok or the creation of the temp file would have triggered an earlier error. It is also unlinked (deleted) successfully which means that at line 186 the temp directory/file permissions are ok. So it must be the cache directory at issue.

In this case the cpanel server was allocating the user account as both owner and group. Sugar apparently wants to see Apache as the group, or at least the Apache account owner, ‘nobody’. So while the chmod settings for owner and group read/write were ok, the group was incorrect.

[text]
#chown -R owner:nobody sugarcrm/
[/text]

Command for the ownership change for the group to nobody.

Edit: As correctly pointed out I had used chmod when I manually typed up the instructions. Corrected the above to read chown. Thanks Derek.

WordPress FTP prompt for Upgrade or Update

There are a lot of posts around about the FTP prompt when preparing an upgrade and all (almost all) reference the same information which is to enter specific settings in the wp-config.php file for the FTP site, username, & password.

Alternatively, I prefer this option which allows the admin user with the correct permissions to avoid the FTP aspect altogether.

In the same wp-config.php file in the WordPress root, around line 10 it will look like this:

[php]
* This file is used by the wp-config.php creation script during the
* installation. You don’t have to use the web site, you can just copy this file
* to "wp-config.php" and fill in the values.
*
* @package WordPress
*/

// ** MySQL settings – You can get this info from your web host ** //
[/php]

Just insert a few lines and add the 3 DEFINE lines as per the example below:

[php]
* This file is used by the wp-config.php creation script during the
* installation. You don’t have to use the web site, you can just copy this file
* to "wp-config.php" and fill in the values.
*
* @package WordPress
*/
define(‘FS_METHOD’, ‘direct’);
define( ‘FS_CHMOD_DIR’, 0775 ); // change these settings to match your apache account
define( ‘FS_CHMOD_FILE’, 0664 ); // change these settings to match your apache account

// ** MySQL settings – You can get this info from your web host ** //
[/php]

The key is the CHMOD entries. In my case the cpanel / WHM server is configured for the apache account to act as the group controller of the files. So to upload and modify files in the Worpress directory it needs write permissions as group not owner.

osCmax 2.5 thumbnail images not showing after upload case sensitive on Linux

The issue here was that loading some images as extra’s were not appearing as thumbnails in the product display. At least some of them were not. The key was that the ones that worked had a lower case file extension and the ones that did not had upper letters. i.e. .jpg and .JPG

I tracked this to being that the Dynamic Mopics for extra product images is case sensitive. Loading an image from another system (Windows perhaps?) with an upper case .JPG extension will not display the thumbnail without specifying the upper case extension in the admin settings for Dynamic Mopics which has all lower case extensions by default.

Using the default installation admin settings. Load a main product image and an extra jpg type file image with the extension as uppercase .JPG
Using the catalog user view inspect the product and there are no thumbnails displayed.
Modify the admin setting to include JPG (as distinct from jpg) in the viewable formats and the images display.

A simple fix is to force lower case extensions for all image uploads. This is a simple change.

Edit the file catalogadminincludesmodulesproduct_image_upload.php

line 23
[text] $ext = substr(strrchr($main_image, ‘.’), 0);[/text]
becomes
[text] $ext = strtolower(substr(strrchr($main_image, ‘.’), 0));[/text]
(adding the additional function as a wrapper, do not forget the closing parenthesis)

Updating an existing database is also relatively simple in phpMyAdmin or similar select the products table and run the following:
[text]UPDATE products SET products_image = REPLACE(products_image, ‘.JPG’,’.jpg’);[/text]

if the user wants to test the impact of this first display the table with the changes with:
[text]SELECT `products_id`, REPLACE(products_image, ‘.JPG’,’.jpg’) AS ‘products_image’ FROM products;[/text]

Rsync and SSH connections

I’ve been annoyed by a message when scripting my rsync backups for some time now.

“stdin: is not a tty”

which I spent a while trying to sort out today.

Turns out that it is associated with the setup of the shell on the servers where I manage some hosted sites.

In my rsync commands I have embedded the ssh commands and adding -q(quiet) to make the messages go away makes no difference. Adding a -t for tty setting makes no difference and adding -T is ineffective as well.

Hmm, according to the SSH syntax, repeating the -t may work.  Yep, it does.

ssh -qtt will suppress the message about the tty!

Except, that I now get an error “tcgetattr: Invalid argument” which is triggered apparently by the second ‘t’.

I’ve left it. I now get my logs of the rsync transactions that I was not getting with the tty error message and the other error does not impact anything that I can see.