Stuff…

I know I will forget.

Stuff… header image 1

PCI compliance for Plesk 9.x; medium strength SSL ciphers

March 5th, 2010 · No Comments

Lots of articles online talk about how to get Plesk to pass PCI compliance, especially the TCP port 8443 which Plesk listens on.

From Plesk 8.x (which most of the articles are written for) to Plesk 9.x Parallels changed to another webserver (away from apache), so,  adding the /usr/local/psa/admin/conf/httpsd.custom.include file and restarting psa does NOT help.

The main problem was that PCI was complaining about:

‘port 8443 pcsync-https with medium strength SSL ciphers’

In Plesk 9 for Linux to update this you will need to edit this file: /etc/sw-cp-server/applications.d/plesk.conf

And add the following ssl.cipher-list line between the inlcude_shell and index-file.names statements:

ssl.cipher-list = “TLSv1+HIGH !SSLv2 RC4+MEDIUM !aNULL !eNULL !3DES @STRENGTH”

It will probably work anywhere in the file, however, that’s where I put it.

URLs:

→ No CommentsTags: Control Panels · Linux · Operating System

MySQL tuning script

March 4th, 2010 · No Comments

This looks like a useful mysql tuning script:

Otherwise the mysql.com pages are good for tuning:

→ No CommentsTags: Coding · MySQL

PHP HTML email to Exchange server not displaying in Outlook

March 2nd, 2010 · No Comments

Was using Free PHP Formmail Generator : http://phpfmg.sourceforge.net to send the contents of a form and when sending to most mail servers/mail clients it would work great.  When sending to a Microsoft Exchange server the HTML contents of the email was displayed as text (not marked up).

Tried this with PHP4 and PHP5 and had the same problem.

The mail server on the webserver was qmail.  Testing the site on another PHP5 server with postfix the forms worked fine.

It turns out that qmail wasn’t liking the \r\n… it worked fine when changing to \n.

Updated the form.lib.php to look like:

#define( ‘PHPFMG_LNCR’, “\x0d\x0a” );
define( ‘PHPFMG_LNCR’, “\n” );

The test html email worked fine when received on exchange and viewed via Outlook.

http://php.net/manual/en/function.mail.php Anonymous (17-Aug-2009 06:29) said :

QMail seems to have problems with the “\r\n” in the header section. I found it helpful to replace them with “\n”….

$header = 'MIME-Version: 1.0' . "\n" .
'Content-type: text/plain; charset=UTF-8'. "\n" .
'From: Yourname <' . $from . ">\n";

→ No CommentsTags: Linux · Networking · Operating System · Protocols · SMTP

Magento database error

March 1st, 2010 · No Comments

Had a problem with Magento stores not loading and the following errors were being presented when going to the site.

Error:

SQLSTATE[HY000]: General error: 145 Table ‘./magento/log_visitor_info’ is marked as crashed and should be repaired
Trace:
#0 /var/www/vhosts/magento/httpdocs/lib/Zend/Db/Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array)
#1 /var/www/vhosts/magento/httpdocs/lib/Zend/Db/Adapter/Abstract.php(457): Zend_Db_Statement->execute(Array)
#2 /var/www/vhosts/magento/httpdocs/lib/Zend/Db/Adapter/Pdo/Abstract.php(230): Zend_Db_Adapter_Abstract->query(‘INSERT INTO `lo…’, Array)
#3 /var/www/vhosts/magento/httpdocs/lib/Varien/Db/Adapter/Pdo/Mysql.php(281): Zend_Db_Adapter_Pdo_Abstract->query(‘INSERT INTO `lo…’, Array)
#4 /var/www/vhosts/magento/httpdocs/lib/Zend/Db/Adapter/Abstract.php(535): Varien_Db_Adapter_Pdo_Mysql->query(‘INSERT INTO `lo…’, Array)
#5 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Log/Model/Mysql4/Visitor.php(125): Zend_Db_Adapter_Abstract->insert(‘log_visitor_inf…’, Array)
#6 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Log/Model/Mysql4/Visitor.php(79): Mage_Log_Model_Mysql4_Visitor->_saveVisitorInfo(Object(Mage_Log_Model_Visitor))
#7 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(373): Mage_Log_Model_Mysql4_Visitor->_afterSave(Object(Mage_Log_Model_Visitor))
#8 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Model/Abstract.php(251): Mage_Core_Model_Mysql4_Abstract->save(Object(Mage_Log_Model_Visitor))
#9 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Log/Model/Visitor.php(159): Mage_Core_Model_Abstract->save()
#10 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Model/App.php(1239): Mage_Log_Model_Visitor->initByRequest(Object(Varien_Event_Observer))
#11 /var/www/vhosts/magento/httpdocs/app/Mage.php(303): Mage_Core_Model_App->dispatchEvent(‘controller_acti…’, Array)
#12 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(454): Mage::dispatchEvent(‘controller_acti…’, Array)
#13 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Controller/Front/Action.php(45): Mage_Core_Controller_Varien_Action->preDispatch()
#14 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(365): Mage_Core_Controller_Front_Action->preDispatch()
#15 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch(‘index’)
#16 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#17 /var/www/vhosts/magento/httpdocs/app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#18 /var/www/vhosts/magento/httpdocs/index.php(65): Mage::run()
#19 {main}

SQLSTATE[HY000]: General error: 145 Table ‘./magento/log_url_info’ is marked as crashed and should be repaired
Trace:
#0 /var/www/vhosts/magento/httpdocs/lib/Zend/Db/Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array)
#1 /var/www/vhosts/magento/httpdocs/lib/Zend/Db/Adapter/Abstract.php(457): Zend_Db_Statement->execute(Array)
#2 /var/www/vhosts/magento/httpdocs/lib/Zend/Db/Adapter/Pdo/Abstract.php(230): Zend_Db_Adapter_Abstract->query(‘INSERT INTO `lo…’, Array)
#3 /var/www/vhosts/magento/httpdocs/lib/Varien/Db/Adapter/Pdo/Mysql.php(281): Zend_Db_Adapter_Pdo_Abstract->query(‘INSERT INTO `lo…’, Array)
#4 /var/www/vhosts/magento/httpdocs/lib/Zend/Db/Adapter/Abstract.php(535): Varien_Db_Adapter_Pdo_Mysql->query(‘INSERT INTO `lo…’, Array)
#5 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Log/Model/Mysql4/Visitor.php(63): Zend_Db_Adapter_Abstract->insert(‘log_url_info’, Array)
#6 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Log/Model/Mysql4/Visitor.php(71): Mage_Log_Model_Mysql4_Visitor->_saveUrlInfo(Object(Mage_Log_Model_Visitor))
#7 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(349): Mage_Log_Model_Mysql4_Visitor->_beforeSave(Object(Mage_Log_Model_Visitor))
#8 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Model/Abstract.php(251): Mage_Core_Model_Mysql4_Abstract->save(Object(Mage_Log_Model_Visitor))
#9 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Log/Model/Visitor.php(179): Mage_Core_Model_Abstract->save()
#10 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Model/App.php(1239): Mage_Log_Model_Visitor->saveByRequest(Object(Varien_Event_Observer))
#11 /var/www/vhosts/magento/httpdocs/app/Mage.php(303): Mage_Core_Model_App->dispatchEvent(‘controller_acti…’, Array)
#12 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(483): Mage::dispatchEvent(‘controller_acti…’, Array)
#13 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Controller/Front/Action.php(56): Mage_Core_Controller_Varien_Action->postDispatch()
#14 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(380): Mage_Core_Controller_Front_Action->postDispatch()
#15 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch(‘index’)
#16 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#17 /var/www/vhosts/magento/httpdocs/app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#18 /var/www/vhosts/magento/httpdocs/index.php(65): Mage::run()
#19 {main}

SQLSTATE[HY000]: General error: 145 Table ‘./magento/log_url’ is marked as crashed and should be repaired
Trace:
#0 /var/www/vhosts/magento/httpdocs/lib/Zend/Db/Statement.php(283): Zend_Db_Statement_Pdo->_execute(Array)
#1 /var/www/vhosts/magento/httpdocs/lib/Zend/Db/Adapter/Abstract.php(457): Zend_Db_Statement->execute(Array)
#2 /var/www/vhosts/magento/httpdocs/lib/Zend/Db/Adapter/Pdo/Abstract.php(230): Zend_Db_Adapter_Abstract->query(‘INSERT INTO `lo…’, Array)
#3 /var/www/vhosts/magento/httpdocs/lib/Varien/Db/Adapter/Pdo/Mysql.php(281): Zend_Db_Adapter_Pdo_Abstract->query(‘INSERT INTO `lo…’, Array)
#4 /var/www/vhosts/magento/httpdocs/lib/Zend/Db/Adapter/Abstract.php(535): Varien_Db_Adapter_Pdo_Mysql->query(‘INSERT INTO `lo…’, Array)
#5 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Log/Model/Mysql4/Visitor.php(142): Zend_Db_Adapter_Abstract->insert(‘log_url’, Array)
#6 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Log/Model/Mysql4/Visitor.php(83): Mage_Log_Model_Mysql4_Visitor->_saveVisitorUrl(Object(Mage_Log_Model_Visitor))
#7 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Model/Mysql4/Abstract.php(373): Mage_Log_Model_Mysql4_Visitor->_afterSave(Object(Mage_Log_Model_Visitor))
#8 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Model/Abstract.php(251): Mage_Core_Model_Mysql4_Abstract->save(Object(Mage_Log_Model_Visitor))
#9 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Log/Model/Visitor.php(179): Mage_Core_Model_Abstract->save()
#10 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Model/App.php(1239): Mage_Log_Model_Visitor->saveByRequest(Object(Varien_Event_Observer))
#11 /var/www/vhosts/magento/httpdocs/app/Mage.php(303): Mage_Core_Model_App->dispatchEvent(‘controller_acti…’, Array)
#12 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(483): Mage::dispatchEvent(‘controller_acti…’, Array)
#13 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Controller/Front/Action.php(56): Mage_Core_Controller_Varien_Action->postDispatch()
#14 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Controller/Varien/Action.php(380): Mage_Core_Controller_Front_Action->postDispatch()
#15 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch(‘index’)
#16 /var/www/vhosts/magento/httpdocs/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#17 /var/www/vhosts/magento/httpdocs/app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#18 /var/www/vhosts/magento/httpdocs/index.php(65): Mage::run()
#19 {main}

Most likely has broken tables and they need fixing:

root@server:/var/lib/mysql/magento# myisamchk -c log_visitor_info.MYI
Checking MyISAM file: log_visitor_info.MYI
Data records:  269208   Deleted blocks:       0
myisamchk: warning: Table is marked as crashed
myisamchk: warning: 1 client is using or hasn’t closed the table properly
- check file-size
myisamchk: error: Size of indexfile is: 3863552         Should be: 3864576
myisamchk: error: Size of datafile is: 41476900          Should be: 41480516
- check record delete-chain
- check key delete-chain
- check index reference
- check data record references index: 1
myisamchk: error: Found key at page 3862528 that points to record outside datafile
- check record links
myisamchk: error: Record-count is not ok; is 269182       Should be: 269208
myisamchk: warning: Found     269182 parts                Should be: 269208 parts
MyISAM-table ‘log_visitor_info.MYI’ is corrupted
Fix it using switch “-r” or “-o”

root@server:/var/lib/mysql/magento# myisamchk -r log_visitor_info.MYI
- recovering (with sort) MyISAM-table ‘log_visitor_info.MYI’
Data records: 269208
- Fixing index 1
Data records: 269182

Same with following tables:  log_url_info.MYI, log_url.MYI

→ No CommentsTags: Linux · MySQL · Operating System

PCI expiring SSL certificates with Plesk

February 26th, 2010 · 1 Comment

PCI was failing due to expired certificates on TCP ports: smtp (25), urd (465), imaps (993) and pop3s (995)

System running Plesk 9.2 and imaps and pop3s was handled by courier.

Updated the self signed certs for courier pop3s and imaps by:

[bash]# cd /usr/share/courier-imap
[bash]# cp imapd.pem imapd.pem.old
[bash]# cp pop3d.pem pop3d.pem.old
[bash]# ./mkimapdcert
[bash]# ./mkpop3dcert
[bash]# /etc/init.d/courier-imap restart
Stopping Courier-IMAP server:
$   Stopping imap done
$   Stopping imap-ssl done
$   Stopping pop3 done
$   Stopping pop3-ssl done

Starting Courier-IMAP server:
$   Starting imapd done
$   Starting imap-ssl done
$   Starting pop3 done
$   Starting pop3-ssl done

Then, tested from a remote machine.  Used the nagios check_tcp command:

[bash]# /usr/local/nagios/libexec/check_tcp -H hostname -S -p 993 -D 1
OK – Certificate will expire on 02/26/2011 12:46.

[bash]# /usr/local/nagios/libexec/check_tcp -H hostname -S -p 995 -D 1
OK – Certificate will expire on 02/26/2011 12:01.

Looks good.

Now, port 465 TCP was urd according to one of the hosts, but, it’s smtps.  We are using qmail on this system.  The certificate could be found in /var/qmail/control.

# /usr/local/nagios/libexec/check_tcp -H hostname -S -p 465 -D 1
CRITICAL – Certificate expired on 02/09/2010 15:15.
CRITICAL – Cannot retrieve server certificate.
# cd /var/qmail/control
# cp servercert.pem servercert.pem.old
# openssl req -newkey rsa:1024 -x509 -nodes -days 3650 -out servercert.pem -keyout servercert.pem

and fill in the questions.  Restart xinetd and test again.

# /usr/local/nagios/libexec/check_tcp -H hostname -S -p 465 -D 1
OK – Certificate will expire on 02/24/2020 13:23.
TCP OK – 0.070 second response time on port 465|time=0.070008s;;;0.000000;10.000000

URLs:

→ 1 CommentTags: Control Panels · Linux · Operating System