Run Mongo as a service – detaching from terminal

You might start mongo demon as


but, as you close the terminal this will terminate your session.

So, to start it as a service so that it would continue running

mongod --fork --logpath /path/to/log/file

You can specify the log file as you wish

, ,

Leave a comment

error = MongoId not found in symfony application

I got the MongoId not found error on the the application I recently moved to remote server.
The app is working fine locally and the problem appears to happen on the remote one only.
The problem seems obvious, and I checked the mongo version I have locally vs the version I have on the remote – they are different

I have newer version of mongo installed on the remote server. And the doctrine orm handling my mongo objects was also older.
I updated my doctrie orm on composer as

 "doctrine/orm": "2.4.6",

This took care of the problem – at least for now ;)

, , , , ,

Leave a comment

Deploying Symfony app on micro instance of aws – Amazon EC2

The major issue you would face is memory. Yeah, the instance comes with small memory allocation and anything memory intensive task might not work there. Your composer install command might not do anything as well.

The major one would be Composer install just hangs and even aborts the process
When you are issuing

composer install

It will eat a bit of memory and doing it on the instance might not work as expected.

Here are the methods I used to overcome it.

1. Incremental install
On you composer.json file, you can try to list only one or two packages at a time and issue composer update vendor/package and if your individual packages are small enough you might get away with it. In my case this didn’t work

2. Ship your vendor from your local machine to the instance
yeah, just have all your composer install where you will be comforted by memory in Gigabytes and just zip and ship it to your instance.
On your local machine

tar -cf vendor.tar.gz /path/to/vendor/folder

Once you have the tar or zip of any of your favorite compressed file

scp -i /path/to/your/pem/file vendor.tar.gz ec2-user@ec2-domain-goes-here:/path/on/instance

This is assuming this will transfer your vendor file to instance.
Then log into your instance and just uncompress the file and put it on the root directory of your application.
This would be just the half of the work.
Then you will need to generate the bootstrap cache file

composer run-script post-update-cmd

yeah.. this will take care of creating the cache file of the bootstrap along with other stuffs that you put on your composer.json post-update-cmd part.
Sometimes you might want to give the write access to the app/cache and app/logs folders as well


, , , , , ,

Leave a comment

Configuring PHP + MySQL + Apache on Amazon EC2 Step by Step

Log in to
Click on EC2 virtual servers in the cloud

From the left menu, under Network and Security, select Key Pairs
Create on by hitting “Create Key Pair”. Mind you, aws will give you only one chance to save the pem file you will be using for logging. So make sure you download and save it.

From your select Elastic Beanstalk and follow the wizard to create an instance per your need.
in the wizard, there is a step you will be asked to use the pem file you downloaded.

Now from the left menu, click on the instances.
And click on the instance on the right pane and you will see another pane with description will be opened on the lower part. On that pane, search for security group and click the link
You will be transferred to the security group associated with that instance. Click on the “in bound” tab and check if SSH is listed there, if not, hit the ‘Edit’ button and add a new rule of SSH with the source of anywhere if you would like to ssh into your box from anywhere or you can specify particular ip address.

log to your instance from terminal as

ssh -i /your/downloaded/pem/file ec2-user@public-domain-goes-here

you will get your public domain on the instance you selected.

If you are using Elastic Beanstalk, it will come with installed apache server for as your webserver. Just restart it

sudo service httpd restart

MySQL shell would be there as well but not the mysql server so install that

sudo yum install -y mysql-server

And restart the demon

sudo service mysqld restart

I have checked if git is installed, if you are using any DCVS, which you should and it is installed already to verify do

git --version

Next would be the creation of your public and private keys for secure communication with the other servers.

ssh-agent -t rsa -b 4096 "your_email@domain.tld"

The above command will provide you with the public and private key that you would use. The default path for it would be on ~/.ssh/id_rsa and ~/.ssh/

If you are using github or bitbucket, you would need the content of the for logging to the server without password.

If you are going to use mongo just use the very information on the following links

This will get you started with your aws instance

, , , , ,

Leave a comment

Loaded Configuration File => (none) Apache not reading php.ini

php.ini is a core file to handle the behavior of PHP and sometimes apache might not pick it and php might not be using and it will create problem.

To resolve this, just see the output of phpinfo first.
Just add the following code snippet in the php file and run it through your server


Then look of configuration file (php.ini) path, by default it would be /etc
If you don’t have the file php.ini in that mentioned directory, just look for related ones like php.ini.default or something and just copy that as php.ini and restart your apache.

, , , , , , ,

Leave a comment

do you postfix?

Recently I was engaged on setting up mail client on the new redhat (rhel6) server for one of my clients. The server was on its default setup of sendmail. Since it is a bit outdated, I decided to use postfix relaying on gmail SMTP.

First thing first, make sure sendmail is not running by running this command

sudo service sendmail stop

Make sure if there are any lingering processes out there by issuing proper process listing commands on your server and kill those if you have to

Then check if you have postfix installed your machine

sudo service postfix start

If you got any complaint like service not found or something along that line, just install the postfix

sudo yum install postfix

Ok now lets go to the juicy part of integrating the postfix with gmail SMTP.
Lets assume your username is and password is #nomoresendmail

Now lets proceed to the configuration part of the postfix.
go to postfix config folder

cd /etc/postfix

Here you will see a couple of files. Our interest would be on the file
First, before you start messing with the file, create a copy of it

sudo cp mail.cp main.cp.bak

Just go to the end of file and add the following snippet in there

smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/pki/tls/certs/self.pem
relayhost = []:587    

That last line right there would tell the postfix it has to relay the SMTP to other server.

Now lets create the sasl_passwd file

sudo touch sasl_passwd
echo "[]:587" > sasl_passwd

The above command would add the content to the sasl_passwd file.

Then to obscure the password information you placed on in the sasl_passwd file,

sudo postmap /etc/postfix/sasl_passwd

The other point would be creating a self certificate you would be using for your secure communication. If you have a certificate you are using already, then just point it to the right place and you should be fine

cd /etc/pki/tls/certs/
make self.pem

The above command would give you interactive wizard that you will follow and create the certificate.

After this, you need to tell the postfix to pick the changes you have been ramming. For that just restart postfix

sudo service postfix restart

Then open your logger to see if there are anything that are suspicious going or if mail is not working, you can tail it as

tail /var/log/maillog

Common Errors
1. Google might be sending some kind of error saying you have to log into the web browser bla bla bla.. then do the following
Go to and login with your google account and turn it on

, , , ,

Leave a comment

Mount to NSF Server timed out on Vagrant

I had a bit rough weekend :( after successful update of some packages and successful breakage of my guest machine aka vagrant.
The thing is my symfony app is running on vagrant and all of a sudden I can’t ssh or after halt I can’t vagrant up – it is giving me the mount to NFS server timed out

This has something to do, unfortunately, with the firewall setting. After the guest and the host are two, at least technically, machines and firewall decided to block the packets for some of the host machine applications.

You can comb those needed for it by looking from the list of the firewall..
On Mac => go to System Preferences and click on Security and Privacy and Turn off the firewall to make sure the issue is associated with it and then you can turn it back with applications related to virtual host to accept all the incoming traffic.

t h a t i s IT

, ,

Leave a comment


Get every new post delivered to your Inbox.