Thursday, March 31, 2016

HHVM Segfault since latest update (3.13.0) switch to LTS 3.12.1

Today is March 31, 2016.
Just upgrade the HHVM to latest update 3.13.0.

Then my blog start to crash, restart the HHVM service several times, No help.
Check the log and debug into No help.

HHVM's Github support also reporting similar issue:

So I switch to the latest LTS which is 3.12.1 at this moment.

First I backup my own HHVM config file:

cp /etc/hhvm/* ~/hhvm_backup/
cp /etc/init.d/hhvm ~/hhvm_backup/init_hhvm
cp -r /etc/nginx/* ~/hhvm_backup/nginx

Then clean up the 3.13.0 package:

apt-get purge hhvm
apt-get autoremove
apt-get clean all

Put new apt config file: /etc/apt/sources.list.d/hhvm.list

deb jessie-lts-3.12 main

Install the latest LTS HHVM:

apt-get update
apt-get install hhvm

Recover my backup config file:

cp server.ini /etc/hhvm/
cp hhvm.conf /etc/nginx/hhvm.conf

Start the service:

service hhvm restart
service nginx restart

And I am back.

I love hhvm, but you better stay on LTS for production level service or system.

Have a nice day!

Update April 4th, 2016:

My HHVM 3.12.1 just crash, but a restart service make it stable for next few days.

It seems there are 2 tweaks you can try:

1.Maybe usefull: When the daemon is started via systemctl it dies after some requests. It will runs if run by:
hhvm -m server -c /etc/hhvm/server.ini

2.Changing /etc/hhvm/php.ini using hhvm.log.level = Error
; hhvm specific
;hhvm.log.level = Warning
hhvm.log.level = Error


I also add these line in my /etc/hhvm/php.ini
; mysql
hhvm.mysql.socket = /var/run/mysqld/mysqld.sock
hhvm.pdo_mysql.socket = /var/run/mysqld/mysqld.sock
hhvm.mysqli.socket = /var/run/mysqld/mysqld.sock

Thursday, March 24, 2016

How to simulate POST request by Chrome apps Postman

I'm testing on Windows, trying to simulate POST requests (with different form variables) for load testing. I have tried all kinds of load testing software but failed to get it working.

For GET requests, I know I can just put parameters behind the url

But how do I simulate a POST request?

I have a chrome REST Client but I do not know what to put in the headers and data.

Here's what I've tried so far:

Wednesday, March 23, 2016

etckeeper Debian Jessie howto

etckeeper is another great tool for keep a recorder of /etc configuration files changes on your Linux box.

First install etckeeper, it is simple on Debian Jessie:
# apt-get install etckeeper

Generate the key for git server:
root@milliondollarserver:~# ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/
The key fingerprint is:
f2:20:f2:20:f2:20:f2:20:f2:20:f2:20:f2:20:f2:20 root@milliondollarserver
The key's randomart image is:
+---[RSA 2048]----+
|                 |
|                 |
|                 |
|        o        |
|       oSo E     |
|        +.... .. |
|       .....o .+=|
|         ..o +.**|
|           .o.=.B|

Setup Git:
root@milliondollarserver:~# git config --global
root@milliondollarserver:~# git config --global root@milliondollarserver
root@milliondollarserver:~# cd /etc/
root@milliondollarserver:/etc# etckeeper init
root@milliondollarserver:/etc# git commit -m "initial checkin"
[master 7c33032] initial checkin
 4 files changed, 14 insertions(+), 4 deletions(-)
 delete mode 100644 check_mk/mysql.cfg
 create mode 100644 python/debian_config
 create mode 100644 python2.7/

Hook it up with my Git server:
cd /etc
git remote rm origin
git remote add origin

Add auto push:
cd /etc/etckeeper/commit.d
(echo ‘#!/bin/sh’ ; echo ‘git push origin’) > 60git-push
chmod +x 60git-push

Try to push:
cd /etc
git add .
git commit -m “automatically push commits to backup repository”
/etc# git push

You will got warning:
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

Run these 2 command to push:
:/etc# git config --global push.default simple
:/etc# git push --set-upstream origin master

You should have output like this:
The authenticity of host ' (' can't be established.
ECDSA key fingerprint is f2:20:f2:20:f2:20:f2:20:f2:20:f2:20:f2:20:f2:20.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ',' (ECDSA) to the list of known hosts.
Counting objects: 1080, done.
Compressing objects: 100% (717/717), done.
Writing objects: 100% (1080/1080), 498.42 KiB | 0 bytes/s, done.
Total 1080 (delta 109), reused 0 (delta 0)
 * [new branch]      master -> master
Branch master set up to track remote branch master from origin.

Debian Jessie install latest stable HAproxy

Debian did a great job to keep update the latest update from software like HAproxy.

To set up the latest stable HAproxy on Debian Jessie, just head to


And follow the Instructions below.
It's safe and clean.

Instructions for latest release

You need to enable the backports repository :

# echo deb jessie-backports main | \
sed 's/\(.*\)-sloppy \(.*\)/&@\1 \2/' | tr @ '\n' | \
tee /etc/apt/sources.list.d/backports.list

Then, use the following commands:
# apt-get update
# apt-get install haproxy -t jessie-backports

You will get the latest release of HAProxy 1.6.

Redmine 3.2.1 bare server running on Debian Jessie

Need Upgrade Redmine to the latest stable 3.2.1.

Download the latest stable package:
cd /var/www
tar xzvf redmine-3.2.1.tar.gz
chown -R root:root redmine-3.2.1/

Copy the configure file and SQLite database file:
cp /var/www/redmine-3.2.0/config/configuration.yml /var/www/redmine-3.2.1/config/configuration.yml
cp /var/www/redmine-3.2.0/config/database.yml /var/www/redmine-3.2.1/config/database.yml
cp /var/www/redmine-3.2.0/db/redmine.sqlite3 /var/www/redmine-3.2.1/db/redmine.sqlite3

Perform upgrade:
cd /var/www/redmine-3.2.1
bundle install --without development test rmagick
bundle exec rake generate_secret_token
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake tmp:cache:clear tmp:sessions:clear RAILS_ENV=production

Testing Run:
ruby /var/www/redmine-3.2.1/bin/rails server webrick -e production -b -p 80

And to start Redmine automatic on boot:

My latest service script /etc/init.d/redmine:
# Provides: redmine
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: redmine webrick
# Description: redmine webrick server autostart-script

DESC="redmine webrick daemon"

. /lib/lsb/init-functions

# Modify it to your configuration

# Start Redmine in daemon mode.
cd $DIR
ruby /var/www/redmine-3.2.1/bin/rails server webrick -e production -b -p 80 > /var/log/redmine.log

# Stop Redmine daemon
RUBYPID=`ps aux | grep "ruby /var/www/redmine-3.2.1/bin/rails server webrick" | grep -v grep | awk '{print $2}'`
if [ "x$RUBYPID" != "x" ]; then
kill -2 $RUBYPID

# Check if Redmine is running
RUBYPID=`ps aux | grep "ruby /var/www/redmine-3.2.1/bin/rails server webrick" | grep -v grep | awk '{print $2}'`
if [ "x$RUBYPID" = "x" ]; then
echo "* Redmine is not running"
echo "* Redmine is running"

case "$1" in




echo "Usage: $0 {start|stop|restart|force-reload|status}"
exit 1


Don't forgot active the service in Debian Jessie:
update-rc.d redmine defaults
systemctl daemon-reload
service redmine start
service redmine status

Please notice my local Redmine server IP is: [].
You will replace it with your own IP address.

check_mk OMD apt plugin

Thanks for the great work from [Karsten Schoeke, Stefan Schlesinger]

This plugin can check for available updates via apt-get on Debian or Ubuntu.
$ wget
# su - milliondollarserver_monitor
$ check_mk -P install /tmp/apt-2.7.mkp

$ check_mk -vP list
Name Title            Files
---- ---------------- -----
apt  apt Update check 4

It won't pull the apt data automaticly, to do so.
I add a cron job to apt-get update to trigger the new data every day:
(echo '#!/bin/sh' ; echo '/usr/bin/apt-get update') > /etc/cron.daily/apt-get-update
chmod +x /etc/cron.hourly/apt-get-update


Please notice [milliondollarserver_monitor] is my local OMD project, you will have to replace it by your own project name.

Wednesday, March 9, 2016

Debian Jessie PHP access SQL Server Database

Use FreeTDS and unixODBC for this task.

  1. Installation of the freetds packages with apt-get

  2. apt-get install freetds-common freetds-bin unixodbc php5-sybase
    service apache2 restart

  3. Add configuration into /etc/freetds/freetds.conf

  4. # Kinamo SQL Server
    host =
    port = 1433
    tds version = 8.0

Debian Jessie turn off IPv6

Append ipv6.disable=1 to the GRUB_CMDLINE_LINUX variable in /etc/default/grub.


Run update-grub and reboot.
or better,

edit /etc/sysctl.conf and add those parameters to kernel. Also be sure to add extra lines for other network interfaces you want to disable IPv6.

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1

After editing sysctl.conf, you should run sysctl -p to activate changes or reboot system.


Debian Jessie PHP access Oracle Database

Need Setup a PHP Web Server can access to Oracle Database.

      Configuring PHP with OCI8
    1. First Install Apache and PHP

apt-get install php5-mysql apache2 libapache2-mod-php5 php-pear unzip libaio1

    1. Then download 2 packages from Oracle:

Oracle Instant Client Downloads for Linux x86-64
Instant Client Package - Basic Lite: Smaller version of the Basic package, with only English error messages and Unicode, ASCII, and Western European character set support
Download (31,302,454 bytes) (cksum - 3592144768)

Instant Client Package - SDK: Additional header files and an example makefile for developing Oracle applications with Instant Client
Download (667,174 bytes) (cksum - 1047596065)



    1. Upload these 2 packages to server, uncompress them put it under same folder:

mkdir -p /usr/lib/oracle/12.1/client64/lib
mv instantclient_12_1/* /usr/lib/oracle/12.1/client64/lib/

cd /usr/lib/oracle/12.1/client64/lib/
ln -s

Make sure the sdk/ folder and files also under same directory:

ls -alt /usr/lib/oracle/12.1/client64/lib/
lrwxrwxrwx 1 root root       17 Mar  9 11:43 ->
drwxr-xr-x 3 root root 4096 Mar 9 11:33 ..
drwxrwxr-x 5 root root 4096 Jul 7 2014 sdk
-rwxrwxr-x 1 root root 6990875 Jul 7 2014
-rwxrwxr-x 1 root root 58793741 Jul 7 2014
-r-xr-xr-x 1 root root 1768370 Jul 7 2014
-r-xr-xr-x 1 root root 544150 Jul 7 2014
-rwxrwxr-x 1 root root 2576030 Jul 7 2014
-r-xr-xr-x 1 root root 156353 Jul 7 2014
-r--r--r-- 1 root root 3692096 Jul 7 2014 ojdbc6.jar
-r--r--r-- 1 root root 3698857 Jul 7 2014 ojdbc7.jar
-rw-rw-r-- 1 root root 71202 Jul 7 2014 xstreams.jar
-rwxrwxr-x 1 root root 29404 Jul 7 2014 adrci
-rw-rw-r-- 1 root root 450 Jul 7 2014 BASIC_LITE_README
-rwxrwxr-x 1 root root 43944 Jul 7 2014 genezi
-r-xr-xr-x 1 root root 6213011 Jul 7 2014
-rwxrwxr-x 1 root root 6005681 Jul 7 2014
-r-xr-xr-x 1 root root 337137 Jul 7 2014
-rwxrwxr-x 1 root root 118491 Jul 7 2014
-rwxrwxr-x 1 root root 227410 Jul 7 2014 uidrvci

Optional add it into LD_LIBRARY by create file: /etc/
# Oracle Instant Client

run ldconfig to apply the changes.
# ldconfig

    1. Installing OCI8 from PECL

Use the OCI8 extension to access Oracle Database. PHP OCI8 2.1 builds with PHP 7.
Use 'pecl install oci8-2.0.10' to install OCI8 for PHP 5.2 - PHP 5.6.
Use 'pecl install oci8-1.4.10' to install PHP OCI8 1.4 for PHP 4.3.9 - PHP 5.1.

Debian Jessi comes with PHP 5.6, when it ask the path for library give it the directory where the library located:
# pecl install oci8-2.0.10
downloading oci8-2.0.10.tgz ...
Starting to download oci8-2.0.10.tgz (Unknown size)
running: phpize
Configuring for:
Please provide the path to the ORACLE_HOME directory.
Use 'instantclient,/path/to/instant/client/lib' if you're compiling with Oracle Instant Client [autodetect] :


Build process completed successfully
Installing '/usr/lib/php5/20131226/'
install ok: channel://
configuration option "php_ini" is not set to php.ini location
You should add "" to php.ini

Create oci8.ini file for php: /etc/php5/mods-available/oci8.ini

cd /etc/php5/cli/conf.d/
ln -s ../../mods-available/oci8.ini
cd /etc/php5/apache2/conf.d/
ln -s ../../mods-available/oci8.ini

service apache2 restart


In case you got error message when start Apache:

# cat error.log
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20131226/' - cannot open shared object file: No such file or directory in Unknown on line 0
[Mon Oct 17 16:06:28.407599 2016] [mpm_prefork:notice] [pid 21276] AH00163: Apache/2.4.10 (Debian) configured -- resuming normal operations
[Mon Oct 17 16:06:28.407640 2016] [core:notice] [pid 21276] AH00094: Command line: '/usr/sbin/apache2'

Make sure the file exist:
# ls /usr/lib/php5/20131226/

And Install the Libaio:
# apt-get install libaio1

Tuesday, March 8, 2016

Intel H97 motherboard can find SATA hard drive under VMware vSphere ESXi 6

I am building an new EXSi server at home by using Asus H97I-Pulus ITX motherboard.

I loaded the ESXi 6 on USB and boot from it, then choice install into another SanDisk Fit USB drive.

I noticed there is no SATA Hard Drive during the installation.

After reboot login in ESXi client still could not found my 2 STAT hard disk:

  1. M.2 Samsung 128 GB SSD

  2. SATA WesterDigital Red 2 TB

After ssh login to ESXi host, I did more looking up:
[root@localhost:~] df -h
Filesystem Size Used Available Use% Mounted on
vfat 249.7M 8.0K 249.7M 0% /vmfs/volumes/e0d29ee9-64a81569-d3da-f0f 0ee514154
vfat 249.7M 162.0M 87.7M 65% /vmfs/volumes/624445eb-9b9e283b-cc41-f48 3d0112608
vfat 285.8M 201.6M 84.2M 71% /vmfs/volumes/56ddaf15-87a6f9a4-9fb2-782 4af3ca264

Looking up the PCI device:

[root@localhost:~] lspci -v
0000:00:00.0 Host bridge Bridge: Intel Corporation 4th Gen Core Processor DRAM Controller
Class 0600: 8086:0c00

0000:00:01.0 PCI bridge Bridge: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor PCI Express x16 Controller [PCIe RP[0000:00:01.0]]
Class 0604: 8086:0c01

0000:00:02.0 VGA compatible controller Display controller: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller
Class 0300: 8086:0402

0000:00:03.0 Audio device Multimedia controller: Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor HD Audio Controller
Class 0403: 8086:0c0c

0000:00:14.0 USB controller Serial bus controller: Intel Corporation 9 Series Chipset Family USB xHCI Controller
Class 0c03: 8086:8cb1

0000:00:16.0 Communication controller Communication controller: Intel Corporation 9 Series Chipset Family ME Interface #1
Class 0780: 8086:8cba

0000:00:19.0 Ethernet controller Network controller: Intel Corporation Ethernet Connection (2) I218-V [vmnic0]
Class 0200: 8086:15a1

0000:00:1a.0 USB controller Serial bus controller: Intel Corporation 9 Series Chipset Family USB EHCI Controller #2
Class 0c03: 8086:8cad

0000:00:1b.0 Audio device Multimedia controller: Intel Corporation 9 Series Chipset Family HD Audio Controller
Class 0403: 8086:8ca0

0000:00:1d.0 USB controller Serial bus controller: Intel Corporation 9 Series Chipset Family USB EHCI Controller #1
Class 0c03: 8086:8ca6

0000:00:1f.0 ISA bridge Bridge: Intel Corporation 9 Series Chipset Family H97 Controller
Class 0601: 8086:8cc6

0000:00:1f.2 SATA controller Mass storage controller: Intel Corporation 9 Series Chipset Family SATA Controller [AHCI Mode]
Class 0106: 8086:8c82

0000:00:1f.3 SMBus Serial bus controller: Intel Corporation 9 Series Chipset Family SMBus Controller
Class 0c05: 8086:8ca2

Specific the SATA Controller:

[root@localhost:~] lspci -v|grep "Class 0106"
Class 0106: 8086:8c82
[root@localhost:~] lspci -v|grep "Class 0106" -B 1
0000:00:1f.2 SATA controller Mass storage controller: Intel Corporation 9 Series Chipset Family SATA Controller [AHCI Mode]
Class 0106: 8086:8c82

Install sata-xahci vib package:

[root@localhost:~] esxcli software acceptance set --level=CommunitySupported
Host acceptance level changed to 'CommunitySupported'.
[root@localhost:~] esxcli network firewall ruleset set -e true -r httpClient
[root@localhost:~] esxcli software vib install -d -n sata-xahci

Please notice this will took several minutes to install.

Installation Result
Message: The update completed successfully, but the system needs to be rebooted for the changes to be effective.
Reboot Required: true
VIBs Installed: VFrontDe_bootbank_sata-xahci_1.34-1
VIBs Removed:
VIBs Skipped:

You have to reboot to apply the changes.

After reboot, all the SATA storage device is back, and you can create new Datastores now.

This packages also works on almost all the SATA Controllers ESXi does not support out of box.

Great works from VMware Front Experience!

For references: