I am trying to configure PHP-informix environment on ubuntu 11.10.I am installed PDO and pdo_sqlite and soap but i can not install pdo_informix.I dont know what is the next step.
I got this screenshot when i check it on openadmin tool.i am stuck with this step.
I struggled for few days too but I eventually got it right. I used the below steps to create the connection to informix DB:
Make the PDO directory under root user.
Extract the informix_pdo file in the directory.
Enter the PDO Directory: cd PDO_INFORMIX-1.3.1/.
Set your INFORMIXDIR: $ export INFORMIXDIR=/myifx/csdk.
Execute phpize: $ phpize
Execute the configure: $ ./configure.
Compile the PDO: $ make.
Install the PDO : $ make install.
Activate the PDO at PHP :
$ cd /etc/php5/conf.d
$ echo "extension=pdo_informix.so" > pdo_informix.ini
Restart apache.
Check the phpinfo to see if the informix_pdo extension is loaded.
One likely problem is that the environment is not set correctly to find the Informix libraries that PDO_Informix uses. You would normally need LD_LIBRARY_PATH to include $INFORMIXDIR/lib and $INFORMIXDIR/lib/esql. As an alternative, you could use or edit the ld.so.conf file, perhaps.
You may find you need to set $INFORMIXDIR itself, and $INFORMIXSERVER too (or maybe instead).
Related
I have to create PHP web service with Firebird db. This is the first time I configure connection with this db and I cant get it right.
I followed every instructions from php manual site, copied neccesry dll files to win/syste32 folder etc. and it's not working.
I dont understand this part:
Use --with-pdo-firebird[=DIR]
to install the PDO Firebird extension, where the optional [=DIR] is the Firebird base install directory.
$ ./configure --with-pdo-firebird
Where should I run this?
These instructions only apply to building PHP from source.
On Windows, you should find that a php_pdo_firebird.dll file is included in the installation package in the ext directory, all that is required is to uncomment/add the following line in php.ini:
extension=php_pdo_firebird.dll
You can then check that the driver is enabled in phpinfo(), php -i or with PDO::getAvailableDrivers().
I am starting to use laravel 4 and I am trying to start using unit tests so I can make my live easier. Well as all of you will guess my development hasn't become easier after trying phpunit tests. The simple tests are well, easy but when the things start to get a bit more complicated they does not go as I though they will.
The problem is I have conducted simple tests but I get some strange error PDOException: could not find driver. I have read a few articles and post on this topic but nothing solved my problem. I have installed php5-mysql and when I call php -m it says that I have both PDO and pdo_mysql. The actual command I use is php -m |grep -i "pdo" and the output is:
PDO
pdo_mysql
Well I've tried to actualy test PDOException class in the browser. For that purpose I have change the mysql user password to incorrect one and tested what will happen in artisan server (called with command php artisan serve ---> http://localhost:8000/). In the browser everything works as a charm but when I try to call ``phpunit` in the console the result is not the same.
I have tried to see if webserver and cli have different configuration files but it turnout that the files are identical. The configuration files that I have compared are:
for the web server
/etc/php5/apache2/conf.d/20-pdo_mysql.ini
/etc/php5/apache2/conf.d/05-opcache.ini
/etc/php5/apache2/conf.d/20-json.ini
/etc/php5/apache2/conf.d/20-mysql.ini
/etc/php5/apache2/conf.d/20-mysqli.ini
/etc/php5/apache2/conf.d/10-pdo.ini
/etc/php5/apache2/conf.d/20-mcrypt.ini
/etc/php5/apache2/conf.d/20-curl.ini
/etc/php5/apache2/php.ini
for command line
/etc/php5/cli/conf.d/20-pdo_mysql.ini
/etc/php5/cli/conf.d/05-opcache.ini
/etc/php5/cli/conf.d/20-json.ini
/etc/php5/cli/conf.d/20-mysql.ini
/etc/php5/cli/conf.d/20-mysqli.ini
/etc/php5/cli/conf.d/10-pdo.ini
/etc/php5/cli/conf.d/20-mcrypt.ini
/etc/php5/cli/conf.d/20-curl.ini
/etc/php5/cli/php.ini
to compare them I user the diff command like so diff -s /path/to/file1 /path/to/file2.
The errors look like this:
1) ExampleTest::testBasicExample
PDOException: could not find driver
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:47
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Database/Connectors/SQLiteConnector.php:22
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:59
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Database/Connectors/ConnectionFactory.php:47
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:127
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Database/DatabaseManager.php:63
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php:167
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Database/Migrations/DatabaseMigrationRepository.php:135
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Database/Migrations/Migrator.php:366
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:93
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Database/Console/Migrations/MigrateCommand.php:56
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Console/Command.php:108
/var/www/smlsspd/vendor/symfony/console/Symfony/Component/Console/Command/Command.php:241
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Console/Command.php:96
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Console/Application.php:96
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Foundation/Artisan.php:57
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:208
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:208
/var/www/smlsspd/app/tests/TestCase.php:70
/var/www/smlsspd/app/tests/TestCase.php:70
/var/www/smlsspd/app/tests/TestCase.php:46
phar:///var/www/smlsspd/phpunit.phar/phpunit/TextUI/Command.php:179
phar:///var/www/smlsspd/phpunit.phar/phpunit/TextUI/Command.php:132
Can you give me a hint or solution to this problem?
Thank you for your time :)
It seems Laravel using SQLite as database for testing. See the backtrace at line 2:
/var/www/smlsspd/vendor/laravel/framework/src/Illuminate/Database/Connectors/SQLiteConnector.php:22
But this seems not installed on your system. So I think you need to install the SQLite driver.
If you are using sqlite for testing you will need php sqlite drivers
For Ubuntu 14.04
sudo apt-get install php5-sqlite
sudo service apache2 restart
In ubuntu 16.04 there is no php5-sqlite
sudo apt-get install php7.0-sqlite
sudo service apache2 restart
If you are occupying SqLite you have to enter php.init and uncomment this line.
;extension = pdo_sqlite
On Windows i had to activate extension=php_pdo_sqlite.dll in php.ini.
For those using Laravel Homestead, make sure you're running phpunit from within Homestead and not on your local machine! You can SSH into it with vagrant ssh.
As others have mentioned, it requires SQLite and thus running it within your virtual machine ensures that's available to your test.
php7.0-sqlite no longer works use php7.1-sqlite
sudo apt-get install php7.1-sqlite3
sudo service apache2 restart
first, install SQLite for PHP with
sudo apt-get install php-sqlite3
then check your php.ini and make sure the below line is uncommented
;extension = pdo_sqlite
then if you are using apache
sudo service apache2 restart
or if you are using Nginx
sudo service nginx restart
note: if you don't know where is your php.ini path use php -i |grep php.ini command
In Laravel, in phpunit.xml file, just set "DB_CONNECTION" and "DB_DATABASE" values. Since I was using mysql (not sqlite), I changed them like this:
<server name="DB_CONNECTION" value="mysql"/>
<server name="DB_DATABASE" value="db_name"/>
If using mysql, add this line in phpunit.xml:
<server name="DB_CONNECTION" value="mysql"/>
Then install the mysql package in php
$ apt-get install php-mysql
Try again :)
I'll make this quick.
I installed Oracle 11g (with appropriate database, users, etc), Apache 2.4.6, and PHP 5.5.4 on a Fedora 19 system.
I wanted to connect PHP to Oracle. What I really wanted to do was to download MDB2_Driver_oci8, which I thought would be easy, but before I can do such a thing, PHP needs to have that plug-in enabled, so here's what I did:
Tried to install oci8 via the following: pecl install oci8
When that didn't exactly work the first few times, I figured out I, for some reason, needed "Development tools" - via yum groupinstall "Development Tools"
Then I figured out later that PHP actually doesn't do oci8 - it's PHP Devel. So, I had to install that too, via yum install php-devel.
And then, I finally got to install oci8. It asked for the Oracle Directory, and that was that. But it said the following:
Configuration option 'php_ini' is not set to php.ini location
You should add 'extensions=oci8.so' to php.ini
First, I did a locate oci8.so - found it in /usr/lib64/php/modules/
Second, I added what it told me to, to the php.ini file.
Third, I checked the usual php_info() test page - no mention of OCI8. Uh-oh.
Fourth, running both php -i and php -m listed oci8 as one of the modules. Weird.
In desperation, I went ahead and downloaded the MDB2_Driver_oci8. Maybe that will fix things. Nope.
When I loaded my PHP Webpage, it returned the following:
Error message: extension oci8 is not compiled into PHP
As well as: MDB2 error: not found
Strange. And then I decided to check the error logs:
PHP Startup - unable to load dynamic library '/usr/lib64/php/modules/oci8.so' - libclntsh.so.11.1: cannot open shared object file: No such file or directory in Unknown on line 0
And now I'm stuck. I tried going into the php.ini, and found that the extension_dir was commented out. I put it back in, which only seemed to break stuff.
Things of note:
I followed this (link) guide on how to configure PHP and install oci8.
./configure --with-oci8 doesn't work. Fedora says no such directory.
As both the webpage files and the actual server reside on the same PC, I did not install the Oracle Client files.
The extension_dir is commented out by default in the php.ini.
This is just one of my problems in a long line of problems concerning the replication of an already existing and working, but dying, setup. It seems whenever I want to solve a problem, I have to do X first. And by doing X, I uncover another problem, which I have to solve by doing Y, which has its own problems, etc, etc.
Any help would be much appreciated. Thanks.
I know this question is a bit old - but I'm writing this here incase others come looking for the solution.
PHP Extensions Directory
To get your PHP extensions directory, run this command
php-config --extension-dir
ORACLE configuration
When you run the config command for oracle, you need to provide it with your Oracle Home directory (this assumes you have installed ORACLE XE):
./configure -with-oci8=shared,$ORACLE_HOME/xe
SELinux policy
You need to adapt your SELinux policy to support what you are trying to achieve. Disabling it completely is not recommended.
On your Fedora system, try running:
which audit2allow
If you receive an error that indicates it cannot find audit2allow then you need to install this package:
yum install policycoreutils-python
Once you have this package, you can pipe your audit log files into audit2allow to have it create your policy file:
grep httpd /var/log/audit/audit.log | audit2allow -m httpd > http.te
This will create the file http.te that is human readable for you to review what the policy additions are that it will make to your SELinux configuration. If you are OK with the modifications, then run these commands (note the capital M in the following command vs. the lowercase m previously)
grep httpd /var/log/audit/audit.log | audit2allow -M httpd
semodule -i httpd.pp
This may take a few seconds to run - you can verify the policy has been installed by running:
semodule -l | grep httpd
You will need to restart httpd so that it can try to load the oci8.so plugin
service httpd restart
HTH
After reading a lot on the internet, I found this page, that indicates I should disable SELinux, and reboot.
That did the trick.
This question already has answers here:
Fatal error: Uncaught Error: Call to undefined function mysql_connect()
(9 answers)
Closed 3 months ago.
I have ran aptitude install php5-mysql (and restarted MySQL/Apache 2), but I am still getting this error:
Fatal error: Call to undefined function mysql_connect() in /home/validate.php on line 21
phpinfo() says the /etc/php5/apache2/conf.d/pdo_mysql.ini file has been parsed.
In case, you are using PHP7 already, the formerly deprecated functions mysql_* were removed entirely, so you should update your code using the PDO-functions or mysqli_* functions instead.
If that's not possible, as a workaround, I created a small PHP include file, that recreates the old mysql_* functions with mysqli_*()-functions: fix_mysql.inc.php
I see that you tagged this with Ubuntu. Most likely the MySQL driver (and possibly MySQL) is not installed. Assuming you have SSH or terminal access and sudo permissions, log into the server and run this:
sudo apt-get install mysql-server mysql-client php5-mysql
If the MySQL packages or the php5-mysql package are already installed, this will update them.
UPDATE
Since this answer still gets the occasional click I am going to update it to include PHP 7. PHP 7 requires a different package for MySQL so you will want to use a different argument for the apt-get command.
# Replace 7.4 with your version of PHP
sudo apt-get install mysql-server mysql-common php7.4 php7.4-mysql
And importantly, mysql_connect() has been deprecated since PHP v5.5.0. Refer the official documentation here: PHP: mysql_connect()
Well, this is your chance! It looks like PDO is ready; use that instead.
Try checking to see if the PHP MySQL extension module is being loaded:
<?php
phpinfo();
?>
If it's not there, add the following to the php.ini file:
extension=php_mysql.dll
If someone came here with the problem of docker php official images, type below command inside the docker container.
$ docker-php-ext-install mysql mysqli pdo pdo_mysql
For more information, please refer to the link above How to install more PHP extensions section(But it's a bit difficult for me...).
Or this doc may help you.
https://docs.docker.com/samples/library/php/
I was also stuck with the same problem of undefined MySQL_connect().I tried to make changes in PHP.ini file but it was giving me the same error.
Then I came to this solution where I changed my code from depreciated php functions to new functions.
$con=mysqli_connect($host,$user,$password);
mysqli_select_db($con,dbname);
//To select the database
session_start(); //To start the session
$query=mysqli_query($con,your query);
//made query after establishing connection with database.
I hope this will help you .
This solution is correctly working for me .
EDIT:
If you upgrade form old php you need to apt-get install php7.0-mysql
Try:
<?php
phpinfo();
?>
Run the page and search for mysql. If not found, run the following in the shell and restart the Apache server:
sudo apt-get install mysql-server mysql-client php5-mysql
Also make sure you have all the following lines uncommented somewhere in your apache2.conf (or in your conf.d/php.ini) file, from
;extension=php_mysql.so
to
extension=php_mysql.so
In php.ini file
change this
;extension=php_mysql.dll
into
extension=php_mysql.dll
My guess is your PHP installation wasn't compiled with MySQL support.
Check your configure command (php -i | grep mysql). You should see something like '--with-mysql=shared,/usr'.
You can check for complete instructions at http://php.net/manual/en/mysql.installation.php. Although, I would rather go with the solution proposed by #wanovak.
Still, I think you need MySQL support in order to use PDO.
The question is tagged with ubuntu, but the solution of un-commenting the extension=mysqli.dll is specific to windows. I am confused here?!, anyways, first thing run <? php phpinfo ?> and search for mysql* under Configuration heading. If you don't see such a thing implies you have not installed or enabled php-mysql. So first install php-mysql
sudo apt get install php-mysql
This command will install php-mysql depending on the php you have already installed, so no worries about the version!!.
Then comes the unix specific solution, in the php.ini file un-comment the line
extension=msql.so
verify that msql.so is present in /usr/lib/php/<timestamp_folder>,
ELSE
extension=path/to/msql.so
Then finally restart the apache and mysql services, and you should now see the mysql section under Configrations heading in phpinfo page
I was getting this error because the project I was working on was developed on php 5.6 and after install, the project was unable to run on php7.1.
Just for anyone that uses Vagrant with ubuntu/nginx, in the nginx directory(/etc/nginx/), there is a directory named "sites-available" which contains a file named like the url configured for the vagrant maschine. In my case was homestead.app. Within this file there is a line that says something like
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
There you can change the php version to the desired for that particular site.
Googled this but wasnt really able to find a simple answer that said where to look and what to change.
Hope that this helps anyone.
Thanks.
If you are getting the error as
Fatal error: Call to undefined function mysql_connect()
Kindly login to the cPanel >> Click on Select Php version >> select the extension MYSQL
For CentOS 7.8 & PHP 7.3
yum install rh-php73-php-mysqlnd
And then restart apache/php.
(Windows mysql config)
Step 1 : Go To Apache Control Panel > Apache > Config > PHP.ini
Step 2 : Search in Notepad (Ctrl+F) For: ;extension_dir = "" (could be commented with a ;). Replace this line with: extension_dir = "C:\php\ext" (please do not you need to remove the ; on the beginning of the sentence).
Step 3 : Search For: extension=php_mysql.dll and remove the ; in the beginning.
Step 4 : Save and Restart You Apache HTTP Server. (On Windows this usually done via a UI)
That's it :)
If you get errors about missing php_mysql.dll you'll probably need to download this file from either the php.net site or the pecl.php.net. (Please be causius about where you get it from)
More info on PHP: Installation of extensions on Windows - Manual
There must be some syntax error. Copy/paste this code and see if it works:
<?php
$link = mysql_connect('localhost', 'root', '');
if (!$link) {
die('Could not connect:' . mysql_error());
}
echo 'Connected successfully';
?
I had the same error message. It turns out I was using the msql_connect() function instead of mysql_connect().
I am using MAMP and would like to use mongo with PHP. I am stuck because the version of MAMP I'm using is the latest version I can find, and it's running PHP 5.2.11. The only Mongo PHP install I can find for OSX is for PHP 5.3.
Is there any way to get mongo working with PHP using MAMP?
For MAMP 2.1.2 and PHP 5.4.10
Download MongoDB php driver .
copy mongo.so to
/Applications/MAMP/bin/php/php5.4.10/lib/php/extensions/no-debug-non-zts-20100525/
and using temrinal
cd /Applications/MAMP/bin/php/php5.4.10/lib/php/extensions/no-debug-non-zts-20100525/ && wget https://github.com/downloads/stennie/mongo-php-driver/mongo.so
open
/Applications/MAMP/bin/php/php5.4.10/conf/php.ini
Find ; Extensions
add
extension=mongo.so
Restart MAMP.
Above steps will install MongoDB driver 1.2.10.
To install latest Mongodb driver using PECL
install autoconf using homebrew or Mac Ports
brew install autoconf
Download php 5.4.10 source from php.net.
rename uncompressed php source folder from php-5.4.10 to php and paste it in this folder
/Applications/MAMP/bin/php/php5.4.10/include/
using the terminal open php folder and run ./configure
cd /Applications/MAMP/bin/php/php5.4.10/include/php/ && ./configure
Add MAMP bin to your ~/.bash_profile
echo "export PATH=/Applications/MAMP/bin/php/php5.4.10/bin:$PATH" >> ~/.bash_profile
source ~/.bash_profile
install latest mongo
pecl install mongo
restart MAMP server :).
Here's a tutorial how to do it: http://www.davidgolding.net/mongodb/installing-mongodb-on-mamp-1-9-5.html
Post was removed so here's the tutorial:
Appsolute launched MAMP version 1.9.5 today, so I thought it’d be a great time to add MongoDB to it and improve my NoSQL skills.
Prepare MAMP for MongoDB files
Create a new folder at Applications/MAMP/db/mongo with three additional subfolders named bin, data, and tmp. Provide these folders with chmod 0755 access permissions. These folders will be the main runtime location for Mongo once MAMP gets it running.
Download MongoDB
Grab the latest Mac OS install package of MongoDB. My server setup called for OS X 64-bit, version 1.6.5. It’ll have a directory named bin. Drop the files from this folder into the /Applications/MAMP/db/mongo/bin folder you already created.
Download Mongo Driver for PHP
I’m running PHP 5.3 (why use MongoDB with any earlier version of PHP?), so I’ll need the mongo.so extension to get PHP and Mongo working together. This is available at the MongoDB GitHub repository, under the PHP 5.3 for Mac binary. After unpacking the downloaded file, place the mongo.so extension file in the /Applications/MAMP/bin/php5.3/lib/php/extensions folder.
Update: An alternative is to place the mongo.so file in the /Applications/MAMP/bin/php5.3/lib/php/extensions/no-debug-non-zts-20090626 folder and avoid having to edit the php.ini file. It appears that MAMP 1.9.5 already has the extension=mongo.so line in the extensions block of the php.ini file, even though version 1.9.5 doesn’t come bundled with Mongo.
4. Create Startup Routines for MAMP
Lastly, you’ll need to create the startup routines so that MAMP will launch Mongo along with MySQL and Apache. Create a new file at /Applications/MAMP/bin/startMongo.sh and place in it the following code:
# /bin/sh
/Applications/MAMP/db/mongo/bin/mongod --dbpath /Applications/MAMP/db/mongo/data --logpath /Applications/MAMP/db/mongo/mongodb.log --pidfilepath /Applications/MAMP/db/mongo/tmp/mongo.pid --fork --logappend
When called, this script will launch Mongo using the MAMP-relative paths rather than Mongo’s system defaults.
Create another file at /Applications/MAMP/bin/stopMongo.sh and place the shutdown method:
# /bin/sh
/bin/kill `cat /Applications/MAMP/db/mongo/tmp/mongo.pid`
This works like the previous script, except it kills the mongo.pid process, effectively shutting down Mongo.
To have MAMP automatically call these Mongo startup scripts, open the /Applications/MAMP/bin/start.sh and /Applications/MAMP/bin/stop.sh files, and insert the following lines above the startMysql.sh lines, respectively:
1
/Applications/MAMP/bin/startMongo.sh
1
/Applications/MAMP/bin/stopMongo.sh
Now MAMP will automatically launch Mongo upon startup.
The only thing left to do is tell PHP to run the mongo.so extension. If you’re running MAMP Pro, edit the php.ini file by selecting File > Edit Template > PHP 5.3 php.ini, otherwise you’ll need to lookup the path the php.ini file from the MAMP startup screen, under “phpInfo” and “Loaded Configuration File.”
Insert the following line in the php.ini file/template, save the file, then restart MAMP.
1
extension="/Applications/MAMP/bin/php5.3/lib/php/extensions/mongo.so"
Mongo should now run in the background on MAMP, which you can connect with from PHP using the main connection routines listed on the PHP site. Welcome to NoSQL on MAMP!
MAMP is now at version 2.2, which comes with PHP v 5.5.3. I managed to get Mongodb working had to jump through a few hoops to get there.
Start with a clean install of MAMP 2.2, make sure that's working.
1. I made this the system version of PHP, (not sure if necessary at this stage).
Find out the default version of php you are using, with the terminal command
$ which php
/usr/bin/php
Then back this up
$ sudo mv /usr/bin/php /usr/bin/php.bak
Then create a symlink to the MAMP latest version of php
$ sudo ln -s /Applications/MAMP/bin/php/php5.5.3/bin/php /usr/bin/php
Check this has been updated
$ which php
/Applications/MAMP/bin/php/php5.5.3/bin/php
2. Installing Mongo
$ cd /Applications/MAMP/db
$ curl http://downloads.mongodb.org/osx/mongodb-osx-x86_64-2.4.6.tgz > mongodb.tgz
$ tar -zxvf mongodb.tgz
$ rm mongodb.tgz
$ mv mongodb* mongo
$ mkdir mongo/data/db
Test to make sure mongo is working
$ ./mongo/bin/mongod --dbpath /Applications/MAMP/db/mongo/data/db
Should output some code, ending in 'waiting for connections on port 27017' press Ctrl + C to quit for now.
3. Now we can create a script to start/stop mongod automatically from the MAMP GUI. This inspiration came from a previous answer, by Alexandru Rada, but didn't quite work how he explained - I think this is to do with being a newer MAMP version.
In /Applications/MAMP/bin create a file called startMongo.sh and insert the following
# /bin/sh
/Applications/MAMP/db/mongo/bin/mongod --dbpath /Applications/MAMP/db/mongo/data/db --logpath /Applications/MAMP/logs/mongodb.log --pidfilepath /Applications/MAMP/tmp/mongo/mongo.pid --fork --logappend
I also created the mongo tmp folder at /Applications/MAMP/tmp/mongo
In the same bin directory create a file called stopMongo.sh and insert the following:
# /bin/sh
/bin/kill `cat /Applications/MAMP/tmp/mongo/mongo.pid`
Make these files executable
$ chmod 775 /Applications/MAMP/bin/startMongo.sh /Applications/MAMP/bin/stopMongo.sh
Now update the startApache.sh and stopApache.sh scripts to include our new files respectively.
Use the Activity Monitor in /Applications/Utilities and search for mongod. When you now start MAMP you should see the process mongod is started. When you stop or quit MAMP you should see this process is automatically killed.
4. We still need to install the mongo-php driver, which is also a pain. To do this I added the MAMP bin directory to my bash $PATH variable. To do this I had to edit the hidden file ~/.profile - but be aware that your $PATH might be loaded from somewhere else.
export PATH=$PATH:/Applications/MAMP/bin/php/php5.5.3/bin:/Applications/MAMP/db/mongo/bin
Note that each element is separated by a :. Quit terminal and re-open, then $ echo $PATH to check your new directories have been added to the path. You could also try $ which pecl or $ which mongod.
We still need some extras from PHP php.net download the same php stable version and unzip it. Create the folder 'include' at /Applications/MAMP/bin/php/php5.5.3/include . Drag the unzipped stable version of php to the include folder, and rename it to just 'php'.
$ cd /Applications/MAMP/bin/php/php5.5.3/include/php
$ ./configure
Now at last, we can hopefully run
$ sudo pecl install mongo
5. Now we just need to update our php config file to add the mongo.so extension.
Open /Applications/MAMP/bin/php/php5.5.3/conf/php.ini in a text editor, under the 'extensions' section, add in
extension=mongo.so
Quit and re-open MAMP!
Mac OS X 10.6 Snow Leopard (with the newest updates) has PHP 5.3 installed along with Apache.
You can enable the installed Apache in System Preferences, Sharing, Web Sharing (there is a help icon (?) which shows you details on using the system's web server).
See also this StackOverflow question:
Easiest way to activate PHP and MySQL on Mac OS 10.6 (Snow Leopard)?
Here's the way I did it and it was fairly simple.
First, read what Mongo says # http://www.mongodb.org/display/DOCS/PHP+Language+Center
When you run sudo pecl install mongo it's going to install it for the standard OSX PHP installation to use, so if for some reason you're using the built-in Apache installation.
Like you, I like using MAMP. I didn't want to go through figuring how to download Mongo into MAMP, so I just creating a symbolic link in the MAMP PHP Extensions folder and put the extension line in the MAMP php.ini. Restarted MAMP Apache and everything worked beautifully!
A couple things to note, after installing Mongo, note the extensions folder it installed it into then check MAMP php.ini to see where it has its extensions set to be. You'll notice the ending is very similar.
For MAMP PRO 2.0.5
You may compile your own mongo.so (http://m-schmidt.eu/2011/11/06/develop-mongodb-web-apps-with-mamp-under-mac-os-x/) or download compiled (http://www.davidgolding.net/mongodb/installing-mongodb-on-mamp-1-9-5.html).
I'd like compile.
After steps mongo.so don't include to php configuration, because in MAMP PRO php.ini placed in
/Applications/MAMP PRO/MAMP PRO.app/Contents/Resources
I using php5.3.6.ini file for my configuration.