WebFaction
Community site: login faq

Php docs say to $ sudo pecl install mongo but I can't sudo and pecl won't run without sudo.

$ pecl install mongo
pecl.php.net is using a unsupported protocal - This should never happen.
install failed

asked 04 Dec '11, 14:00

courierjurich
3223
accept rate: 0%


Hi,

You can do the install as follows:

# Procedure for installing Mongo for PHP5.3 on a PHP+CGI server
# Create an install directory
mkdir ~/pecl_install
cd ~/pecl_install
# Download the last version of Mongo (as seen at http://pecl.php.net/package/mongo)
wget http://pecl.php.net/get/mongo-1.2.6.tgz
# Unpack and get inside the extracted dir
tar xzvf mongo-1.2.6.tgz
cd mongo-1.2.6
# Generate the configuration script
phpize53
# Configure for php53 and make
./configure --with-php-config=/usr/local/bin/php53-config
make
# Create a folder where the custom PHP extensions would live
mkdir ~/php53-exts
# Copy the compiled extension to the custom folder
cp modules/mongo.so ~/php53-exts/
# (Optional) Link the default server extensions inside the new folder, so they are still accessible
ln -s /usr/local/lib/php53/extensions/no-debug-non-zts-20090626/* ~/php53-exts/

# Customize the php.ini file of the desired web application, so that it loads the new extension
# MAKE SURE to replace 'htdocs' with the specific application you are enabling this for
echo "extension_dir = $HOME/php53-exts" >> ~/webapps/htdocs/php.ini
echo "extension = mongo.so" >> ~/webapps/htdocs/php.ini
permanent link

answered 04 Dec '11, 19:17

neeravk
1.5k3412
accept rate: 41%

edited 04 Dec '11, 21:44

Terrific. My script is now confirming mongodb installed. Thanks!

(05 Dec '11, 16:36) courierjurich

I followed the instructions and everything worked fine, but phpinfo() doesn't show that mongo loaded. Do I have to ask you to restart apache to do so?

(14 Apr '12, 17:29) mjsarfatti

No, since this is loaded dynamically with .htaccess ,restarting apache is not needed. Something else may be the issue. You may submit a support ticket if you would like us to investigate.

(14 Apr '12, 17:36) johns ♦♦

Found it: I phpizeid it for php53 but used php54 for the rest of the commands. I redid every step from the start with php54 and it's working now!

(14 Apr '12, 18:16) mjsarfatti

Glad to hear you found the issue.

(14 Apr '12, 19:41) johns ♦♦

Many thanks to neeravk. I've followed your guidelines. It's OK until last step. When I try to update php.ini, it says that :

-bash: /home/dongnd/webapps/htdocs/php.ini: No such file or directory

How I can do to resolve this problem?

(02 Oct '13, 22:13) ndaidong

This means that the file specified doesn't exist. You may need to change the path for that command if your app isn't named "htdocs".

(02 Oct '13, 22:16) waynek

Hello neeravak,

I followed your answer, seems I have problem. .

  1. http://genghis.iniyaval.com/moadmin.php is not working, Saying Mongo Extensions are not installed
  2. Here is the content of my '/home/iniyaval/php53-exts' folder

    ioncube_loader_lin_5.2.so -> /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ioncube_loader_lin_5.2.so

    mailparse.so -> /usr/local/lib/php/extensions/no-debug-non-zts-20060613/mailparse.so

    memcache.so -> /usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcache.so

    mongo.so

    ploadprogress.so -> /usr/local/lib/php/extensions/no-debug-non-zts-20060613/uploadprogress.so

3: Here is the content of my php.ini file

[iniyaval@web322 genghis]$ cat /home/iniyaval/webapps/genghis/php.ini
extension_dir = /home/iniyaval/php53-exts
extension = mongo.so

4: My php.ini extention_dir query says as below [iniyaval@web322 genghis]$ php -i | grep extension_dir extension_dir => /usr/local/lib/php/extensions/no-debug-non-zts-20060613 => /usr/local/lib/php/extensions/no-debug-non-zts-20060613

Now I am confused without further steps to fix this. Any help will be much appreciated.

(16 Apr '14, 13:04) nehemiah
1

The problem is that your genghis.iniyaval.com application uses PHP 5.5, while the example above is for PHP 5.3. If you're using a different version of PHP, then you need to modify the steps for that version.

Here's a procedure that should work for PHP 5.5:

# Procedure for installing Mongo for PHP5.5 on a PHP+CGI server
# Create an install directory
mkdir ~/pecl_install
cd ~/pecl_install
# Download the last version of Mongo (as seen at http://pecl.php.net/package/mongo)
wget http://pecl.php.net/get/mongo-1.2.6.tgz
# Unpack and get inside the extracted dir
tar xzvf mongo-1.2.6.tgz
cd mongo-1.2.6
# Generate the configuration script
phpize55
# Configure for php55 and make
./configure --with-php-config=/usr/local/bin/php55-config
make
# Create a folder where the custom PHP extensions would live
mkdir ~/php55-exts
# Copy the compiled extension to the custom folder
cp modules/mongo.so ~/php55-exts/
# (Optional) Link the default server extensions inside the new folder, so they are still accessible
ln -s /usr/local/lib/php55/extensions/no-debug-non-zts-20121212/* ~/php55-exts/

# Customize the php.ini file of the desired web application, so that it loads the new extension
# MAKE SURE to replace 'htdocs' with the specific application you are enabling this for
echo "extension_dir = $HOME/php55-exts" >> ~/webapps/htdocs/php.ini
echo "extension = mongo.so" >> ~/webapps/htdocs/php.ini

Also, when running PHP at the command line, be sure to include the version, ie php55, and not simply php.

(16 Apr '14, 18:29) seanf
showing 5 of 9 show 4 more comments

Hello,

I followed the answer by neeravak exactly, Sees I am still in issues.

  1. http://genghis.iniyaval.com/moadmin.php is not working, Saying Mongo Extensions are not installed
  2. Here is the content of my '/home/iniyaval/php53-exts' folder

    ioncube_loader_lin_5.2.so -> /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ioncube_loader_lin_5.2.so

    mailparse.so -> /usr/local/lib/php/extensions/no-debug-non-zts-20060613/mailparse.so

    memcache.so -> /usr/local/lib/php/extensions/no-debug-non-zts-20060613/memcache.so

    mongo.so

    ploadprogress.so -> /usr/local/lib/php/extensions/no-debug-non-zts-20060613/uploadprogress.so

3: Here is the content of my php.ini file

[iniyaval@web322 genghis]$ cat /home/iniyaval/webapps/genghis/php.ini
extension_dir = /home/iniyaval/php53-exts
extension = mongo.so

4: My php.ini extention_dir query says as below [iniyaval@web322 genghis]$ php -i | grep extension_dir extension_dir => /usr/local/lib/php/extensions/no-debug-non-zts-20060613 => /usr/local/lib/php/extensions/no-debug-non-zts-20060613

Now I am confused without further steps to fix this. Any help will be much appreciated.

permanent link

answered 16 Apr '14, 13:01

nehemiah
325
accept rate: 0%

edited 16 Apr '14, 13:01

For those using PHP 7.X please see these updated install instructions (using PHP 7.0 as an example and ' https://secure.php.net/manual/en/mongodb.installation.manual.php' as the base),

mkdir -p $HOME/tmp
export TEMPDIR=$HOME/tmp
mkdir ~/pecl_install
cd ~/pecl_install
git clone https://github.com/mongodb/mongo-php-driver.git
cd mongo-php-driver
git submodule update --init
phpize70
./configure --with-php-config=/usr/local/bin/php70-config --prefix=$HOME
make all
cp modules/mongodb.so ~/php70-exts/
ln -s /usr/local/lib/php70/extensions/no-debug-non-zts-20151012/* .

Then proceed to update your php.ini file accordingly.

(27 Jun, 02:02) NickR ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×262
×28
×10

question asked: 04 Dec '11, 14:00

question was seen: 12,417 times

last updated: 27 Jun, 02:04

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2016 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM