-
-
Save marinalohova/ec5d77ffd9d8e8acce2c to your computer and use it in GitHub Desktop.
Install PHP PGSQL extensions on Mac OS X Yosemite (change PHP_VER with your PHP version)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PHP_VER="5.5.20" | |
brew install wget | |
# Check if extension exists first | |
php -m | grep pgsql | |
# Update brew and install requirements | |
brew update | |
brew install autoconf | |
# Download PHP source and extract | |
mkdir -p ~/php-src; cd ~/php-src | |
wget -c http://br1.php.net/distributions/php-$PHP_VER.tar.bz2 | |
tar -xjf php-$PHP_VER.tar.bz2 | |
# Go to extension dir and phpize | |
cd php-$PHP_VER/ext/pdo_pgsql/ | |
phpize | |
# Configure for Postgress.app | |
./configure --with-pdo-pgsql="/Applications/Postgres.app/Contents/Versions/9.4" | |
# Use just "./configure" for brew version | |
# ./configure --with-pdo-pgsql="/Library/PostgreSQL/9.3/" | |
make | |
sudo make install | |
# If you don't have php.ini and the script throws an error, uncomment this line | |
#sudo cp /etc/php.ini.default /etc/php.ini | |
#If changing php.ini throws 'Permission denied' make sure the permissions are set for your user. | |
#sudo chown <username> /etc/php.ini | |
# Add extension to php.ini | |
sudo echo "extension=pdo_pgsql.so" >> /etc/php.ini | |
# Go to extension dir and phpize | |
cd ../pgsql/ | |
phpize | |
# Configure for Postgress.app | |
./configure --with-pgsql="/Applications/Postgres.app/Contents/Versions/9.4" | |
# Use just "./configure" for brew version | |
# ./configure --with-pgsql="/Library/PostgreSQL/9.3/" | |
make | |
sudo make install | |
# Add extension to php.ini | |
sudo echo "extension=pgsql.so" >> /etc/php.ini | |
# Check if extension exists, again | |
php -m | grep pgsql | |
sudo apachectl restart | |
pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment