Skip to content
Thierry Lam edited this page Nov 17, 2017 · 9 revisions

Setting up PostgreSQL on a Mac

PHP 5.3.8 is installed by default on the Mac, PHP 5.3.6 source will be used to build pgsql.so and pdo_pgsql.so because of a build issue with 5.3.8.

pgsql

  1. Download PHP 5.3.6
  2. Go to php-5.3.6/ext/pgsql
  3. phpize
  4. ./configure --with-pgsql=/Library/PostgreSQL/9.1
  5. make
  6. sudo make install

pdo_pgsql

  1. Download PHP 5.3.6
  2. Go to php-5.3.6/ext/pdo_pgsql
  3. phpize
  4. ./configure --with-pdo_pgsql=/Library/PostgreSQL/9.1
  5. make
  6. sudo make install

The above libraries will be copied to /usr/lib/php/extensions/no-debug-non-zts-20090626

According to phpinfo(), the default php.ini on my mac is at /private/etc/php.ini. Copy over /private/etc/php.ini.default to /private/etc/php.ini if it does not exist. Add the following lines to php.ini:

extension=pgsql.so
extension=pdo_pgsql.so

Setting up Cake PHP with PostgreSQL on a Mac

Cake PHP depends on pdo_pgsql.so, make sure the above were installed successfully.

Ensure your app/Config/database.php has:

public $default = array(
    'datasource' => 'Database/Postgres',
    'persistent' => false,
    'host' => 'localhost',
    'port' => '5432',
    'login' => 'postgres',
    'password' => 'postgres',
    'database' => 'gateau',
    'prefix' => '',
);

Setting up Cake PHP with PostgreSQL on a Mac

On the mac, mysql.sock is located at /tmp. In /private/etc/php.ini

pdo_mysql.default_socket=/tmp/mysql.sock


public $default = array(
    'datasource' => 'Database/Mysql',
    'persistent' => false,
    'host' => 'localhost',
    'login' => 'mysql',
    'password' => 'mysql',
    'database' => 'gateau',
    'prefix' => '',
);

Yii

  1. Copy the key

     xclip -sel clip < ~/.ssh/id_rsa.pub
    
  2. DB Config

     common/config/main-local.php
    
  3. PHP Extensions

     sudo apt-get install php7.0-mbstring
     sudo apt-get install php-xml
     sudo apt-get install php-curl
    
  4. Run yii

     php yii serve
    
Clone this wiki locally