Installing HipHop Virtual Machine

HipHop Virtual Machine

I recently read an article about how you can install HipHp Virtual Machine (HHVM) for a 2x+ speed boost on your site.  The newest version of WordPress works 100% with HHVM, but unfortunately some of the plugins out there don’t. I decided the pros out weighed the cons and decided to install HHVM on my development server.  Outlined below are the steps for installing it on your own.

wget -O - | sudo apt-key add -
echo deb saucy main | sudo tee /etc/apt/sources.list.d/hhvm.list
sudo apt-get update
sudo apt-get install hhvm
sudo /usr/share/hhvm/
sudo update-rc.d hhvm defaults
sudo /etc/init.d/hhvm restart
sudo /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60

Read More

APC on a WHM/CPanel Server

One of my clients needed APC installed for their application, so I initially tried to install it via WHM module installer …. this failed.   Here are the steps that I took to get it working via CLI
First download the newest stable release of APC and then run the following commands.

tar -xzf APC-3.1.6.tgz
cd APC-3.1.6
which php

If you do not have pcre installed the make install will fail.  So make sure to run the following yum command to install it with the development packages for safe measure.

Read More

Adding users from a CSV file to a MySQL database

I recently was hit with an issue where I had to import about 500 employees into a database and having each one added to multiple departments. With the use of an array, I was able to write up some pretty simple code to import a CSV file that simply contained “username, real name” into the database. Thought I would post it in case anyone ever needed to do something along these lines.

$departments = array("department1", "department2", "department3", "department4");
mysql_connect("$dbhost", "$dbuser", "$dbpass") or die(mysql_error());
mysql_select_db("$dbase") or die(mysql_error());
$handle = fopen("employees.csv", "r");
while (($data = fgetcsv($handle, 5000, ",")) !== FALSE) {
    foreach ($departments as &$value) {
        $query = "INSERT INTO employees (`id`, `name`, `realname`, `tickets`, `dept`) VALUES (NULL, '$data[0]', '$data[1]', '0', '$value')";
        $result = mysql_query($query) or die(mysql_error());
        echo $data[1] . ' successfully added to ' . $value . ' department<br>';