When running a project, many people have a headache in setting up some configuration files and related application extensions. For example, I have successfully installed PHP link mongodb extension files through Baidu today, so let’s share.
First you need to determine your VERSION of PHP and use the command PHP -v to check
My own project requires a VERSION of PHP5.6 and is a Laravel project running in an integrated environment at HomesteadCopy the code
Download the corresponding mongo extension file to use the command according to your PHP version
Wget (this extension is applicable to php5.6 http://pecl.php.net/get/mongo-1.6.16.tgz download path is/var/bin download (download path can define your own)Copy the code
Decompress the downloaded package
Sudo tar -zxvf mongo-1.6.16.tgz sudo tar -zxvf mongo-1.6.16.tgzCopy the code
The decompressed directory is displayed
CD mongo - 1.6.16Copy the code
Run the phpize file on your system
Sudo /usr/bin/phpize5.6 If you do not know the location of your phpize file, you can run the find / -name phpize command to find / -name phpizeCopy the code
Continue writing configuration files using commands in the mongo-1.6.16 directory
/configure --with-php-config=/usr/bin/php-config5.6 sudo./configure --with-php-config=/usr/bin/php-config5.6Copy the code
Start the installation after the configuration file is written
Sudo make or sudo make installCopy the code
At this point, if there are no errors, the extension file has been installed successfully. Simply modify the PHP configuration file php.ini
Switch to the PHP configuration file
CD /etc/php.5.6/fpm/(the PHP installation path in my environment, which can be changed according to my installation location)Copy the code
To edit the php.ini file
sudo vim php.ini
Copy the code
After entering the file, add it at the bottom of the file
Extension = "mongo.so"Copy the code
Note that since my environment is Homestead, I need to change two PHP configuration files and one in /etc/php.5.6/cli and then edit them accordingly.
After adding, you need to restart the phP-fpm communication file with the server using the command
Sudo service php5.6- FPM restart sudo service php5.6- FPM restartCopy the code