Good day, everyone.
Usually I just using this Official Docs in *nix OS
But now i'm using MacOs and this instructions just doesn't work properly.
In case of pecl install cassandra I got this message:
checking for supported DataStax C/C++ driver version... awk: can't open file /include/cassandra.h
source line number 1
configure: error: not supported. Driver version 2.4.2+ required (found )
ERROR: `/private/tmp/pear/install/cassandra/configure --with-php-config=/usr/bin/php-config' failed
My logic tell me that in that case I need make DataStax C/C++ driver by my own. In folder php-driver\lib I deleting cpp-driver and using this instruction make new and fresh C/C++ driver without errors.
So in official doc it says:
Note The install.sh script will also compile and statically link into the extension a submoduled version of the DataStax C/C++ driver for Apache Cassandra. To use a version of cpp driver that you already have on your system, run phpize, ./configure and make install.
But when i trying to run ./configure from php-drive/ext I got almost the same error:
checking for supported DataStax C/C++ driver version... awk: can't open file /include/cassandra.h
source line number 1
configure: error: not supported. Driver version 2.4.2+ required (found )
Even if I continue and after that error run make install it gives me that log:
/bin/sh /Users/antvirgeo/php-driver/ext/libtool --mode=install cp ./cassandra.la /Users/antvirgeo/php-driver/ext/modules
cp ./.libs/cassandra.so /Users/antvirgeo/php-driver/ext/modules/cassandra.so
cp ./.libs/cassandra.lai /Users/antvirgeo/php-driver/ext/modules/cassandra.la
----------------------------------------------------------------------
Libraries have been installed in:
/Users/antvirgeo/php-driver/ext/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `DYLD_LIBRARY_PATH' environment variable
during execution
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Installing shared extensions: /usr/lib/php/extensions/no-debug-non-zts-20121212/
cp: /usr/lib/php/extensions/no-debug-non-zts-20121212/#INST#24727#: Operation not permitted
make: *** [install-modules] Error 1
Libraries have been installed in:
/Users/antvirgeo/php-driver/ext/modules
Even if I adding cassandra extension with that path to php.ini I still got error Class 'Cassandra\SimpleStatement' not found in my project.
php -d="extension=modules/cassandra.so" -m showing that cassandra in list of PHP Modules
What am I doing wrong?
PS: I have ubuntu OS in Parallels with this project with DataStax php driver installed with this instructions works fine.
____upd:
After all instructions of #Fero without ANY ERRORS, command /usr/local/bin/php -i | grep -A 10 "^cassandra$" showing me this:
cassandra
Cassandra support => enabled
C/C++ driver version => 2.4.2
Persistent Clusters => 0
Persistent Sessions => 0
Directive => Local Value => Master Value
cassandra.log => cassandra.log => cassandra.log
cassandra.log_level => ERROR => ERROR
And still the same error - Class 'Cassandra\SimpleStatement' not found
______________UPDATED LAST:
Aaaaand it's working! I wrote output phpinfo(); in my project and realize that apache using other php version and php.ini, where wasn't extension=cassandra.so at all.
You will need to install the DataStax C/C++ driver which is a dependency of the PHP driver. Using these instructions followed by make install after the driver has been successfully built will ensure this dependency is available when building the PHP driver. Using the PHP driver build instructions you will need to make sure that GMP and PHP dev libraries are also available before running pecl install cassandra.
EDIT:
Since you are using El Capitan you are running into issues with the System Integrity Protection and you will need to disable it in order to copy files into /usr. The better and recommended option is to install PHP using Homebrew; however you can also use MacPorts if preferred.
Below are the steps used to reproduce the installation of the PHP driver on a clean OSX El Capitan image with Xcode and Homebrew already installed:
brew install autoconf cmake libuv gmp openssl pcre homebrew/php/php55
brew link homebrew/php/php55
mkdir code
pushd code
git clone https://github.com/datastax/php-driver.git
pushd php-driver
git submodule update --init --recursive
pushd lib/cpp-driver
mkdir build
pushd build
cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl ..
make -j$(sysctl -n hw.ncpu)
sudo make install
popd
popd
mkdir build
pushd ext
/usr/local/bin/phpize
popd
pushd build
../ext/configure --with-php-config=/usr/local/bin/php-config
make -j$(sysctl -n hw.ncpu)
sudo make install
popd
popd
sudo sh -c 'echo "extension=cassandra.so" >> /usr/local/etc/php/5.5/php.ini'
You can then verify the installation using the following command:
/usr/local/bin/php -i | grep -A 10 "^cassandra$"
NOTE: PHP v5.5 is utilized above since that is the default version that comes with El Capitan; PHP v5.6 and v7.0 can also be used instead.
If you need to install the Cassandra PHP extension on MacOS, you can do this simply by installing it via PECL, without having to do anything with turning on or off System Integrity Protection. I've written a blog post with easy step-by-step instructions. It also includes a link to installing PHP from Homebrew since they removed the Homebrew/php tap back in April of this year.
It also by passes the incorrect instructions given on the DataStax website. In short ...
Install Dependencies (I run these commands one at a time to easily view any messages):
$ brew install autoconf
$ brew install cmake
$ brew install automake
$ brew install libtool
$ brew install gmp
$ brew install libuv
$ brew install openssl
Retrieve and build the C++ driver and then create a build directory inside the cpp-driver folder:
$ git clone https://github.com/datastax/cpp-driver.git --depth=1
$ mkdir cpp-driver/build
$ cd cpp-driver/build
Make and build the driver with a qualified call to OpenSSL:
$ cmake -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ -DOPENSSL_LIBRARIES=/usr/local/opt/openssl/lib ..
$ make
$ make install
Now you're good to go to install the Cassandra PHP extension libraries using PECL:
$ pecl install cassandra
Check to make sure that the Cassandra extension was added to your PHP.ini file. If not add it.
[cassandra]
extension="cassandra.so"
Restart Apache and you're off and running with Cassandra in PHP.
If you want more detail on what's happening in the above instructions, refer to my blog post here:
https://medium.com/#crmcmullen/how-to-install-the-cassandra-php-driver-on-macos-10-13-high-sierra-and-10-14-mojave-c18263831ccb
Related
I am using macOS and have successfully installed and set up XAMPP on my system. But the problem is that I want to connect to an oracle database through PHP Easy Syntax like below:
$conn = oci_connect('xx', 'xx', '123.123.xxx.x/xxxx');
if (!$conn) {
$e = oci_error();
trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);
}
But i get this error on running the page
Call to undefined function oci_connect()
After reading some article i found that i have to install oracle instant client but i really don't know the steps to download which version and then where to unzip the files in xampp folder. I am really a novice in this area.
This is what I did on macOS Mojave. I used the native installer XAMPP 7.4.9 from
xampp-osx-7.4.9-0-installer.dmg. I did a basic install with the Developer files
option selected - this was the default.
It seems like XAMPP for macOS doesn't have the OCI8 extension built. (I noticed
the XAMPP VM install from xampp-osx-7.4.9-0-vm.dmg also didn't have the OCI8
extension, but I haven't played with it yet.)
Sadly the 'obvious' method of installing OCI8 with the pecl command fails to
correctly find the right PHP version. E.g. running:
sudo /Applications/XAMPP/xamppfiles/bin/pecl install oci8
and answering:
instantclient,/Applications/XAMPP/xamppfiles/lib/instantclient-11.2.0.3.0/
fails with checking PHP version... Unknown option: n. The PECL config looked OK, but there must have been some conflict with the native PHP version.
Anyway, the slightly longer manual install of OCI8 works. The instructions are below.
I prefer to use a more recent Instant Client, so download the latest Instant
Client Basic and SDK packages from
here
and unzip them:
cd $HOME/Downloads
curl -O https://download.oracle.com/otn_software/mac/instantclient/instantclient-basic-macos.zip
curl -O https://download.oracle.com/otn_software/mac/instantclient/instantclient-sdk-macos.zip
Extract the Instant Client (substitute your download directory path):
cd /Applications/XAMPP/xamppfiles/lib
sudo unzip /Users/cjones/Downloads/instantclient-basic-macos.zip
sudo unzip /Users/cjones/Downloads/instantclient-sdk-macos.zip
You can optionally do some cleanup. Get rid of the old Instant Client:
sudo rm -rf /Applications/XAMPP/xamppfiles/lib/instantclient-11.2.0.3.0
and remove new libraries not needed by OCI8:
sudo rm -f /Applications/XAMPP/xamppfiles/lib/instantclient_19_3/{*jdbc*,*occi*,*mysql*,*jar,uidrvci,genezi,adrci}
Download the OCI8 extension from PECL and
extract it:
cd $HOME/Downloads
curl -O https://pecl.php.net/get/oci8-2.2.0.tgz
tar -xzf oci8-2.2.0.tgz
Build and install OCI8. You'll need some kind of compiler available; I have XCode installed:
cd oci8-2.2.0
/Applications/XAMPP/xamppfiles/bin/phpize
./configure --with-php-config=/Applications/XAMPP/xamppfiles/bin/php-config --with-oci8=shared,instantclient,/Applications/XAMPP/xamppfiles/lib/instantclient_19_3
make
sudo make install
Then, tell XAMPP to enable the extension:
sudo /Applications/XAMPP/xamppfiles/xampp oci8
At the prompt, enter the path to the Instant Client directory /Applications/XAMPP/xamppfiles/lib/instantclient_19_3 like:
Please enter the path to your Oracle or Instant Client installation:
[/Applications/XAMPP/xamppfiles/lib/instantclient-11.2.0.3.0] /Applications/XAMPP/xamppfiles/lib/instantclient_19_3
installing symlink...
patching php.ini...
OCI8 add-on activation likely successful.
XAMPP: Stopping Apache...ok.
XAMPP: Starting Apache...ok.
Now when you check http://localhost/dashboard/phpinfo.php you should see the OCI8 section.
You may be interested in how to 'run' an Oracle DB on macOS, which can be done in a VirtualBox VM like: https://blogs.oracle.com/opal/the-easiest-way-to-install-oracle-database-on-apple-mac-os-x. Other people use a Docker container for the same thing.
macOS Mojave 10.14.3
PHP 7.1.23
Prestashop 1.7.5.1
I tried to install PHP intl extension on my local server in order to use Prestashop.
I added extension=php_intl.so to etc/php.ini
When I try to install Prestashop I get Intl extension is not loaded.
$ php -m | grep intl
When I do $ php -m | grep intl, I get:
PHP Warning: PHP Startup: Unable to load dynamic library
'/usr/local/lib/php/pecl/20160303/php_intl.so' - d
lopen(/usr/local/lib/php/pecl/20160303/php_intl.so, 9): image not found in Unknown on line 0
Warning: PHP Startup: Unable to load dynamic library '/usr/local/lib/php/pecl/20160303/php_intl.so' - dlopen
(/usr/local/lib/php/pecl/20160303/php_intl.so, 9): image not found in Unknown on line 0
intl
It seems that the file php_intl.so doesn't exist.
$ sudo pecl install intl
I also tried $ sudo pecl install intland I get:
make: *** [php_intl.lo] Error 1
ERROR:make' failed`
$ curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1
I also tried $ curl -s http://php-osx.liip.ch/install.sh | bash -s 7.1 and it doesn't create the intl.so file.
How can I solve this problem?
Brew's PHP 7.1, 7.2 and 7.3 all have INTL enabled by default.
Most probably, you're just using your Mac OS' bundles version of PHP.
Run
ls -l $(which php)
to find out where the current PHP binary is located and whether it is symlinked to a Brew installation or not. In my case, for example:
lrwxr-xr-x 1 27 May 23 16:30 /usr/local/bin/php -> ../Cellar/php/7.3.5/bin/php
Meaning that my php is linked to Brew's 7.3.5 version.
If you are NOT using Brew's PHP, you'll see something like
-rwxr-xr-x 1 11169664 Mar 21 07:09 /usr/bin/php
Installing PHP through Brew
Find out whether you've already installed PHP:
brew list | grep php
If there is any output, and your version of PHP is present, go to step 2, or use step 1 to update PHP to the latest version.
1. Install Homebrew's PHP
brew install php#7.3
(or 7.2, 7.1). If Brew complains about not being able to find a formula, you might have messed with taps. Instead of php#7.3, you could try to supply the full path to the current php formula:
brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/php.rb
Still not working, check whether you are running a recent version of Homebrew brew --version.
Homebrew 2.1.3-31-geaf2370
Homebrew/homebrew-core (git revision fd1ef; last commit 2019-05-25)
Homebrew/homebrew-cask (git revision 16d50; last commit 2019-05-26)
2. Link Homebrew's PHP
Now, to have php 'in your path', there are two options.
a) Either homebrew's version must be linked from its install location (/usr/local/bin/Cellar/php....) to a directory in your path (e.g., /usr/local/bin). To do this, run:
brew link --force php#7.3
If you are not able to link, this is typically caused by set permissions or System Integrity Protection. In the first case, try sudo chown "$USER":admin /usr/local/bin/php.
b) Or, add the /usr/local/opt/php#7.3 directory (opt-prefix) to your $PATH variable. E.g., for Bash:
echo 'export PATH="/usr/local/opt/php#7.3/bin:/usr/local/opt/php#7.3/sbin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
3. Validate installation
ls -l $(which php)
should show that php is linked to a Homebrew PHP installation in /usr/local/bin/Cellar.
php -v
should show the recently installed version of PHP. Try to restart your terminal if that's not the case.
php -i | grep -i intl
should show some information about the current install of intl.
If you're using webservers and/or PHP FPM, this is the time to restart those services. (Or restart your system, if you don't know how to do that and cannot figure out).
Possible issues
If you still get warnings about missing extensions (Unable to load dynamic library, etc.), then your php.ini is messed up.
Find the current location of php's ini
$ php -i | grep \.ini
Configuration File (php.ini) Path => /usr/local/etc/php/7.3
Loaded Configuration File => /usr/local/etc/php/7.3/php.ini
Scan this dir for additional .ini files => /usr/local/etc/php/7.3/conf.d
Additional .ini files parsed => /usr/local/etc/php/7.3/conf.d/ext-opcache.ini
....
Edit /usr/local/etc/php/7.3/php.ini and find the offending extension load (e.g., extension="myext.so"). Comment out those that cannot be found.
Homebrew permissions
Some argue that it's a good idea to chown /usr/local.
sudo chown -R "$USER":admin /usr/local
This will make installing things here, by hand and through Homebrew, a lot easier, but also a bit less secure too, since non-root processes are now allowed to write here too.
Your web-application is using a different version of PHP.
Make sure that it doesn't... The configuration of this depends on the used webserver. A first step would be to output the current PHP configuration in your web-application with <?php phpinfo();.
This explains steps for Apache.
Another way to get a webserver + PHP stack running quicly is using Laravel Valet.
Installing additional extensions
To install additional PHP extensions, use PEAR.
pear -V
should output the current PEAR and PHP version.
PEAR Version: 1.10.9
PHP Version: 7.3.5
Zend Engine Version: 3.3.5
Now, to install an extension, for example, PHP's yaml extension:
pear install yaml
I have seen a lot of answers about this problem and anyone helped me, but the last (of course). This is for XAMPP´s use.
Xcode is needed.
Download the version of php you use in xampp from php.net.
Extract it and open the extracted folder in a terminal using cd.
Change to subfolder ext/intl.
Run these commands to build the extension:
/Applications/XAMPP/bin/phpize
./configure --enable-intl --with-php-config=/Applications/XAMPP/bin/php-config --with-icu-dir=/Applications/XAMPP/xamppfiles/
make
sudo make install (password required)
Delete all files you downloaded and also the extracted folders.
Add to php.ini file in xampp/etc folder line
extension="intl.so"
Original link: https://community.apachefriends.org/viewtopic.php?p=255061&sid=27afc55649dfe6ea7b0824cb0bb8486b
Since php 7 it's not necessary load the extension php_intl.so, what do you need to do?, edit your php.ini and delete or comment the line that is loading the extension php_intl.so, after this reload your apache and try again.
There might be an issue with brew
You could try to use this as mentioned there:
brew tap kyslik/homebrew-php
brew install kyslik/php/php71-intl
i tried all but intl not working in mac so please uninstall xampp and install mamp it will work
So, on Pecl Official site ( https://pecl.php.net/package/intl ), it's clear that Intl package is not maintained anymore and has been superseded. Since PHP 5.3.0 you don't need to use Pecl to install intl extension, it's bundled with PHP.
But, it's missing on native instalation of PHP 7.1.24 on Mac OS Mojave.
if you wanna use only native apache and php pre-installed instead of using homebrew, do this:
Download PHP 7.1 from php.net, install XCode Command Line Tools, ICU (http://site.icu-project.org/), Autoconf, reinstall the developer tools header files, and finally install Intl extension using phpize.
Important: you'll have to disable SIP.
I have successfully installed Laravel, but after running php artisan serve and going to localhost:8000 I get this error:
Use of undefined constant MCRYPT_RIJNDAEL_128 - assumed 'MCRYPT_RIJNDAEL_128'
I have checked phpinfo() on localhost:8888 and it says that mcrypt is properly installed. However the only thing I can think of is that maybe my path is wrong?
in my .bash_profile I have
PATH=/usr/local/bin:$PATH
Every time I try to run Laravel commands I have to type this in the terminal:
export PATH="~/.composer/vendor/bin:$PATH"
I am running on a Mac. Is there a simple way I can set up my bash_profile so that I can consistently change between localhost addresses and still have all the proper PHP functions working?
More simple way on ubuntu
apt-get install php5-mcrypt
mv -i /etc/php5/conf.d/mcrypt.ini /etc/php5/mods-available/
php5enmod mcrypt
service apache2 restart
Note: if you don't have "/etc/php5/conf.d" just skip that step and it will work ok
check http://php.net/manual/en/mcrypt.installation.php
This problem relative to the PHP extensions loader.
You no need to use laravel command at all after successful installation.
Laravel framework need Mcrypt Library for the security module and encrypt some of configure file.
The things that you need is theses steps.
Download Mcrypt http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
then configure make and install it.
Download php http://php.net/releases/index.php
Above 5.5.14 are suggested. (Use this path later on step 4)
then download Autoconfigure
curl -O http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
tar xvfz autoconf-latest.tar.gz
cd autoconf-2.69/
./configure
make
sudo make install
then you have to go to directory level
cd ***YOURPHPDIRECTORY***/ext/mcrypt/
and run phpize within this directory level
/usr/bin/phpize
./configure
make
sudo make install
modify your php.ini to enable the mcrypt extension by insert this into php.ini
extension=mcrypt.so
Restart web server.
For Mac users's specially - install it using Home Brew
I’ve installed an empty Laravel installation and got the following error message when navigating to http://localhost/kanban/public/:
Notice: Use of undefined constant MCRYPT_RIJNDAEL_128 – assumed ‘MCRYPT_RIJNDAEL_128′ in /Library/WebServer/Documents/xxx/config/app.php on line 83
Googling for this error message return many tutorials on how to install mcrypt on Mac OS X (whether building it from source or using Homebrew). The problem was that both the mcrypt and the php55-mcrypt packages were properly installed:
$ brew install mcrypt
Warning: mcrypt-2.6.8 already installed
$ brew install php55-mcrypt
Warning: php55-mcrypt-5.5.20 already installed
Mcrypt was also properly loaded by PHP:
$ php -m | grep mcrypt
mcrypt
$ php -i | grep mcrypt
Additional .ini files parsed => /usr/local/etc/php/5.5/conf.d/ext-mcrypt.ini,
Registered Stream Filters => zlib.*, bzip2.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, mcrypt.*, mdecrypt.*
mcrypt
mcrypt support => enabled
mcrypt_filter support => enabled
mcrypt.algorithms_dir => no value => no value
mcrypt.modes_dir => no value => no value
for more details refer this link - http://benohead.com/mac-os-x-php-notice-use-undefined-constant-mcrypt_rijndael_128/
If you are seeing this on ubuntu or other flavors of *nix , it might help to do the following:
service php5-fpm restart
I just adjusted the .bash_profile in MacOS and it worked:
export PATH="/usr/local/sbin:$PATH"
PHP_AUTOCONF="/usr/local/bin/autoconf"
source ~/.bash_aliases
I also had this problem in trying to deploy a Laravel to Apache on Mac OS Sierra. I eventually found this post that gave step-by-step instructions to resolve this issue. These instructions assume that you have Homebrew installed; if you don't have it installed, then paste the following into a Terminal window to install it:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Here is the relevant steps pasted from the post given above:
Step 1: Install autoconf and mcrypt
I used homebrew to install autoconf and mcrypt, which is as easy as:
brew install autoconf mcrypt
If this does not work for you, or you don't want to use homebrew, then check out this tutorial.
Step 2: Build the PHP extension
To build the PHP extension you will need the PHP 5.4.17 source code that is available for download here and extract it:
cd ~/Downloads
unzip PHP-5.4.17.zip
Then build the extension using the following commands:
cd php-src-PHP-5.4.17/ext/mcrypt/
/usr/bin/phpize
./configure
make
sudo make install
Step 3: Enable the extension
All that is left is to enable the extension by editing /etc/php.ini. If this file is not present, copy /etc/php.ini.default and rename it:
sudo cp /etc/php.ini.default /etc/php.ini
Edit the /etc/php.ini file and add the following:
extension=mcrypt.so
Step 4: Restart apache
Now just restart apache and you're done!
sudo apachectl restart
ADDITIONAL NOTES AND CLARIFICATION
I did encounter two issues with following these steps:
I had to match the PHP zip file that I downloaded to the version of PHP that was installed on my machine.
So I did
php -v
to determine the version number and then changed the download to match that version number. In my case the PHP version was 5.6.28 and so I needed to download the PHP source from
https://github.com/php/php-src/archive/PHP-5.6.28.zip
I got an exception at step 2 when I tried to do the sudo make install, the exception was caused by SIP, a security featured added by El Capitan. The exception is outlined in this question, and the resolution to this problem I found in this answer.
Applying the information from this answer changed the step 2 listed above and replaced the sudo make install with the following:
mkdir -p /usr/local/lib/php/extensions
sudo make EXTENSION_DIR='/usr/local/lib/php/extensions' install
Take note that because of this change, step 4 above also needs to changed to include the path to mcrypt.so. So the following must go in the php.ini:
extension=/usr/local/lib/php/extensions/mcrypt.so
I use nginx and php-fpm, and already did apt-get install php5-mcrypt, and moved the mcrypt.ini file to mods-available.
I had to do sudo service php5-fpm restart before it actually worked.
detailed instructions here https://www.php.net/manual/en/install.pecl.windows.php
make sure you choose appropriate extension version as of your PHP version
I'm having a terribly difficult time getting the command "pg_connect()" to work properly on my Mac. I'm currently writing a PHP script (to be executed from console) to read a PostgreSQL database and email a report.
I've gone into my php.ini file and added
extension=pgsql.so
But, I'm met with the following error.
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20090626/php_pgsql.so' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20090626/php_pgsql.so, 9): image not found in Unknown on line 0
PHP Fatal error: Call to undefined function pg_connect() in... (blah file here)
When running phpinfo(), I see nothing about PostgreSQL, so what is my issue here?
The PHP version that comes bundled with OS X doesn't include PostgreSQL. You'll have to compile the extension yourself. Here are some instructions:
Find your version of PHP: php -v.
Download the version of PHP that matches yours: curl -O http://us.php.net/distributions/php-5.3.3.tar.gz. (This example downloads PHP 5.3.3 but this must match your version)
Extract the archive you downloaded: tar -xzvf php-5.3.3.tar.gz
Change to the PostgreSQL's extension directory: cd php-5.3.3/ext/pgsql/
Type phpize.
Type ./configure.
Type make.
Type sudo make install.
Add the extension to you php.ini file by adding extension=pgsql.so. (You may already have done this)
Restart Apache.
Update for OS X Mountain Lion
Apple has removed autoconf from the newer versions of XCode so the procedure above will fail at #5. To solve that problem:
Type /usr/bin/ruby -e "$(/usr/bin/curl -fksSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)".
Type sudo chown -R $USER /usr/local/Cellar.
Type brew update.
Type brew install autoconf.
That should install autoconf and allow you to install the module using the instructions above.
If you use home brew, you can solve this with a command as simple as:
brew install php55-pdo-pgsql
for other php version, search with:
brew search pgsql
This worked for me with OSX 10.9.4 «Mavericks»
Install sources
Download the PHP source code. Unlike on Mountain Lion, you don’t get any headers preinstalled to link against so need to put it in /usr/include/php. Mavericks ships with PHP 5.4.17, but the latest 5.4.x source from php.net should do:
tar -jxvf php-5.4.20.tar.bz2
sudo mkdir -p /usr/include
sudo mv php-5.4.20 /usr/include/php
Configure PHP
cd /usr/include/php
./configure --without-iconv
sudo cp /etc/php.ini.default /etc/php.ini
Building a module
I needed the pdo_pgsql module - the same pattern should apply to just about any module assuming you have the necessary dependencies installed:
cd ext/pdo_pgsql
In my case I had the following error:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script. ERROR:
`phpize' failed
So I had to use this command:
brew install autoconf
Then:
phpize
After that I tried to do:
./configure
but I had the next problem:
checking for pg_config... not found configure: error: Cannot find
libpq-fe.h. Please specify correct PostgreSQL installation path
So the solution was to specify correct PostgreSQL installation path:
./configure --with-pdo-pgsql=/Library/PostgreSQL/9.3/
make
sudo make install
That copies pdo_pgsql.so to /usr/lib/php/extensions/no-debug-non-zts-20100525.
Then simply add
extension=pdo_pgsql.so to /etc/php.ini
Run php -m to confirm everything went to plan.
For those who installed php7/ngix/postgres with homebrew
You can install the PostgreSQL module with:
brew install php70-pdo-pgsql
After that, you have to restart the php service:
brew services restart php70
OS X El Capitan users can simply upgrade their version of PHP 5.6. This is a one liner that will do that.
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
For php56 via brew:
brew install php56-pdo-pgsql
PostgreSQL by default is installed in a unusual place on MAC OS X:
/Library/PostgreSQL/9.3
Given the location above you can type this:
./configure --with-pgsql=/Library/PostgreSQL/9.3
I killed the whole day trying to make it work on El Capitan after I made an upgrade yesterday and it turned out that I forgot to modify httpd.conf and change the path from the default php module (version 5.5.27) to the one I installed (version 5.6.14). This should be done in httpd.conf by modifying your default LoadModule php5_module path to LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so.
Just decided to leave it here as the potential solution for those who upgrade their OS or just the PHP version and face the same problem.
For those of you having openssl error while make here is the solution
OSX uses openssl 0.98 while installer is searching for 1.0.0
refer this link for instructions
psycopg2 installation error - Library not loaded: libssl.dylib
I downloaded PostgreSQL for Mac, and used the stack builder after installation to standup the entire EnterpriseDB Apache/PHP stack end-to-end. I mention this as a possible time saving option, probably not ideal for all situations. Should work OK if the apache and postgres shipped with Mac OS X were never started.
To keep existing apache hosted applications (i.e. pre-PostgreSQL install legacy) stable, I would just install the newer EnterpriseDB apache on port 81 (stackbuilder will prompt for new port if legacy apache instance is already running). Then, use mod_proxy in httpd.conf for the apache running on port 80 to provide seamless user experience to applications hosted on PostgreSQL.
I'm having trouble installing the "memcached" PHP extension from PECL, though I can successfully installed the "memcache" extension. (They are separate PHP extensions.)
For example, these commands work okay:
$ sudo pecl install memcache
$ sudo pecl install APC
$ sudo pecl install oauth
However, attempting to install memcached causes errors:
$ sudo pecl install memcached
...
ld: library not found for -lmemcached
collect2: ld returned 1 exit status
make: *** [memcached.la] Error 1
ERROR: `make' failed
I'm using pecl, memcached, and libmemcached from Mac Ports (macports.org) on a recent Intel Mac. The libmemcached libraries can be found in /opt/local:
/opt/local/include/libmemcached
/opt/local/include/libmemcached/libmemcached_config.h
/opt/local/lib/libmemcached.2.0.0.dylib
/opt/local/lib/libmemcached.2.dylib
/opt/local/lib/libmemcached.a
/opt/local/lib/libmemcached.dylib
/opt/local/lib/libmemcached.la
Any idea what I may be doing wrong?
Andrei Zmievski (developer of the memcached plugin) kindly answered my email request with the following instructions:
$ pecl download memcached
$ tar zxvf memcached-1.0.0.tgz (or whatever version downloads)
$ cd memcached-1.0.0
$ phpize
$ ./configure --with-libmemcached-dir=/opt/local
$ make
$ sudo make install
This worked perfectly.
same situation here. i had to do the above, but with explicit path names (i run my php etc. out of /opt/local)
/opt/local/bin/pecl download memcached
tar zxvf memcached-1.0.0.tgz
cd memcached-1.0.0
/opt/local/bin/phpize
./configure --prefix=/opt/local --with-php-config=/opt/local/bin/php-config --with-libmemcached-dir=/opt/local
make
make install
normally this kind of stuff is pretty simple on os x with macports, but there is no php5-memcached package yet (only one for the older, memcache (no "d") package). oh, an i also had to install an older version of libmemcached, since the latest version didn't compile on os x 10.5.8 for me. oy!
As you've seen, the new memcached extension, uses libmemcached to do the heavy lifting. If it were Linux, I'd say that it was possible that you don't have /opt/local/lib/ listed in ld.so.conf (and run 'ldconfig').
MaxOSX doesn't use that though. It is, however installable from 'ports' apparently. http://lsimons.wordpress.com/2008/05/01/serious-php-part-1/
Well, after many tries only this solution works for me.
Install XAMPP
Install brew (https://github.com/Homebrew/homebrew/wiki/Installation)
$ brew
install libmemcached
cd /Applications/XAMPP/xamppfiles/bin/
$ sudo ./pecl install memcached
Build process completed successfully Installing
'/Applications/XAMPP/xamppfiles/lib/php/extensions/no-debug-non-zts-20121212/memcached.so'
install ok: channel://pecl.php.net/memcached-2.2.0 configuration
option "php_ini" is not set to php.ini location You should add
"extension=memcached.so" to php.ini
VOILA !!