MongoDB on Laravel Homestead with PHP 7

Hi, folks!
Because I had some troubles with installing and enabling MongoDB driver on Laravel Homestead with PHP 7 version installed on it, I will explain here how I have solved them.

Install MongoDB package

Import public key:

 sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 

Creating a List File:

 echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list 

Update packages list:

 sudo apt-get update 

Install MongoDB package:

sudo apt-get install -y mongodb-org

Make connection with PHP

Firstly, I have installed PHP MongoDB driver:

sudo pecl install mongodb

Secondly, I have added in

/etc/php/7.0/fpm/php.ini

and in

/etc/php/7.0/cli/php.ini

the following code

extension=mongodb.so 

Finally, we need to save the changes:

sudo service php7.0-fpm restart && sudo service nginx restart



Silviu Stroe

Silviu is a full stack developer and entrepreneur. He is the founder of one of the first VPN services in Romania, RoTunneling and is part of Yahoo - Wall of Fame. He also loves bleeding edge technologies and new challenges.

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *