Symfony2: Installation

The official installation doc is

As a best practice, don’t install symfony in MAC or Windows, install in Linux and use Linux for development because you will be using Linux for hosting.

For consistency in development, develop in virtual machine. The spec of the virtual machine should be the same as the production server. The best way to do it is to use vagrant.

In this example, we will create a ficticious project called SongBird. First of all, we need to create a portable and consistent development environment so that we speak the same language. This is also important if you decide to outsource the development in the future. Next we need a tool like puppet to configure automate software configuration.

To get started, let’s get this symfony repo –

git clone
vagrant up

This will take a long time… most of the alerts you see in the screen is harmless. this is a once off setup. Enter root password when prompted.

According to the doc, you can choose a number of ways to install symfony, most people chose the composer method. Don’t use composer or manually download, install the symfony command line instead.

vagrant ssh
# you are now in the virtual machine
sudo curl -LsS -o /usr/local/bin/symfony
sudo chmod a+x /usr/local/bin/symfony

To create a new project call “songbird” using the long term support version,

cd /vagrant
symfony new songbird lts
cd songbird
sed "s/''/'',''/g" -i web/app_dev.php
# check that all requirements met
php app/check.php
# you should see that the config has passed

In your parent host, we need to add get to be pointing to the vm. add this to your host file.

In your parent, Test your site by going to

If you see the word “Homepage”, everything is good.

Now let us commit everything before we proceed.

git init .
git add .
git commit -m"init commit"

Speeding up vagrant virtualbox disk access

Virtualbox driver is very slow. You can google about this all over the internet.

There are 2 ways to speed up vagrant disk access using nfs, one way is to use vagrant-bindfs plugin and another way is the traditional way to change permissions in vm. This method outlines the later.

shutdown vagrant using “vagrant halt”
In puphpet folder, update config.yaml
synced_type: nfs
then “vagrant up”
If you are seeing mount nfs error, check your /etc/hosts file. make sure points to localhost

sudo -s, CHANGE THE ROOT PASSWD first so that you can log in again if things break.
change the permission for the /var/www (vagrant folder) so that they are the user_id and grp_id of the user in mac, for example,
IN your mac,
the user id is 502 and group id in 20
IN your vm,
vagrant id is 1000 and www-data id is 33
edit etc/passwd and /etc/group and change the id of 1000 to 502 and /etc/group so that the id of www-data is 20
change the own dir to that permission as well, ie /var/www and their files.
change the session dir, ie /var/lib/php/session
exit and do a “vagrant halt” and “vagrant up” again to test.

Installing phpmyadmin in hhvm

when installing phpmyadmin under hhvm and nginx especially, you might get an error like so:

“Error during session start; please check your PHP and/or webserver log file and configure your PHP installation properly”

this is due to hhvm settings, got /etc/hhvm/php.ini and comment out all the php options like so:

; php options
;session.save_handler = files
;session.save_path = /var/lib/php5
;session.gc_maxlifetime = 1440

restart hhvm and it should work.

bitbucket post hook sample json

Like github, bitbucket sends a useful json post data to a url specified by you if you add a post hook in a the bitbucket repo. The post json can be useful if you want to determine the file changes of the branch that has the change. example json is

[payload] => {"repository": {"website": "", "fork": false, "name": "repo_name", "scm": "git", "owner": "your_group", "absolute_url": "/your_group/your_repo/", "slug": "your_repo", "is_private": true}, "truncated": false, "commits": [{"node": "727a3b3c6b37", "files": [{"type": "modified", "file": "code/yourfile.php"}, {"type": "modified", "file": "code/yourfile.php"}], "raw_author": "your name <bernard@youremail>", "utctimestamp": "2014-11-26 04:13:10+00:00", "author": "yourname", "timestamp": "2014-11-26 05:13:10", "raw_node": "727a3b3c6b37f0b9c03fde57943f3f463a12f9e5", "parents": ["2405db2a7a94"], "branch": "develop", "message": "update deploy scripts\n", "revision": null, "size": -1}], "canon_url": "", "user": "yourname"}

ssl installation in whm/cpanel

To create new ssl for a domain,

login to whm, then goto ssl/tls -> generate ssl certificate and signing request. For wildcard domains, use * You should get a private key and a sign request. Then go to the ssl provider and give them the signing request. They should give you a CA cert.

now go to ssl/tls -> install an ssl cert on a domain, browser the cert and paste in the key. If there are api or permission errors, go to /home/user/ssl and chown user:user -R *.

now go to https://www.yoursite.xx or https://yoursite.xx and it should work.

to install ssl for the whole cpanel or whm or other services, login to whm -> service configuration -> service manager -> manage service ssl certificates. browse a cert and install.

Enforcing IE8 mode with IE8 browsers

IE8 browers will default to IE7 document mode if the headers are not enforced.

Add the DOC type before the html tag

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

and the meta tag in the header section
<meta http-equiv="x-ua-compatible" content="IE=8" >

IT will make life a lot easier but newer browsers will also view in IE8.

Creating Dev Environment

The idea is to have a production-like system within your system.

1. Download virtualbox.

2. Download a ready-to-go vm instance.

3. Expand the vm instance to desired size.

4. In instance, create a user and setup samba share.

5. In virtualbox host, create 2 network adapter, one “NAT” and one  “host only”, that way the centos instance can only share files to the host machine. Using vboxsf sharing option is way TOO SLOWWW.

6. Set up LAMP or any other web server in the vm instance. To access the sites in the vm instance, configure the host file in the host to point to the instance. To access the files in the vm instance, just connect to the vm via samba.

7. Now, there is a flexibility of development in host machine or vm (Up to the developer). The vm instance can run the httpd server while changes to the files can be done in any OS.

Best Dedicated or Cloud Server for Startups

If you are a small business or a startup and are unsure of investing in server hardware, the best strategy is to go for cloud server hosting. In cloud hosting, you can manage your own server and scale up when the need arises.

I’ve been looking around and I think the best option out there is digital ocean. The cheap upfront cost and dead easy GUI makes them the best value for money among their competitors.