Wednesday, October 22, 2014

MySQL Performance LXC Container vs Host

I have a linux virtual container (LXC) and the server hosting the container running the same version of MySQL with the same database.

I tried running some select queries on both of the machines for benchmark purposes. My conclusion? MySQL read performance inside the LXC container is the exactly the same.

Tuesday, October 21, 2014

WHMCS Cronjob Error

If you get the following error while you try to run the WHMCS cronjob from the command line:
Site error: the file <b>/var/www/accounts/admin/cron.php</b> requires the ionCube PHP Loader to be installed by the website operator. If you are the website operator please use the <a href="">ionCube Loader Wizard</a> to assist with installation.

You need to add your the ioncube zend extension to the CLI php.ini too: /etc/php5/cli/php.ini

Sunday, October 19, 2014

Sendmail/STARTTLS verify=FAIL

Oct 19 14:04:34 Billing sm-mta[17583]: STARTTLS=client,, version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-RC4-SHA, bits=128/128

If you see those errors in your mail.log and your emails are failing to send, you need to add your ssl cert from apache to the sendmail config in /etc/mail/
# CA directory
O CACertPath=/etc/apache2/ssl
# CA file
O CACertFile=/etc/apache2/ssl/
# Server Cert
O ServerCertFile=/etc/apache2/ssl/example.cert
# Server private key
O ServerKeyFile=/etc/apache2/ssl/example.key

Saturday, October 18, 2014

Securing External LDAP Connections

I was getting the following error when I tried testing with openssl:
error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:s23_lib.c:177

The solution? It turns out that /etc/default/slapd needs to be configured to use /etc/ldap/ldap.conf using the following:

SLAPD_OPTIONS="-f /etc/ldap/slapd.conf"

Friday, October 17, 2014

Adding Virtualhost In Apache For Port

Say we wanted to route the <your-domain>.com:8072/misc to /var/www/misc...

Add the following to /etc/apache2/ports.conf:
NameVirtualHost *:8072
Listen 8072

Add a file that describes your site to /etc/apache2/sites-available with this:
<VirtualHost *:8072>
   ServerName <your-domain>.com
   DocumentRoot /var/www/misc/

Run this command: sudo a2ensite misc

And restart apache: sudo service apache2 restart

Thursday, October 16, 2014

Deploying Nginx + Gunicorn + Flask

Why use both Nginx and Gunicorn?:

Simple explanation:

Nginx SSL configuration:

The thing I spent the longest on was getting supervisor to work. Gunicorn kept giving me "gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>", because I was missing the "directory" parameter. I needed to tell supervisor which directory to start from.

command=/<path>/venv/prod/bin/gunicorn -w 8 main:app -b

You will need to create an upstart script to get supervisor to run when the system starts:

Tuesday, October 14, 2014

Python Excel Library Benchmark Comparison

benchmark_csv                  0.026495
benchmark_excellent            1.784107
benchmark_openpyxl             2.897072
benchmark_openpyxl_rows        7.025895
benchmark_pyexcelerate         0.550225
benchmark_xlsxcessive          1.430242
benchmark_xlsxwriter           1.611668
benchmark_xlwt                 1.275144

pyexcelerate          :  10.11
xlwt                  :  15.67
xlsxwriter (optimised):  19.70
xlsxwriter            :  23.50
openpyxl   (optimised):  95.82
openpyxl              :  95.90