OSX Yosemite
开发的node项目中安装PostgreSQL
。我使用MacPorts,并尝试了这里描述的方法:https://github.com/codeforamerica/ohana-api/wiki/Installing-PostgreSQL-with-MacPorts-on-OS-X,但是在第2步中会出现错误:$ sudo gem install pg -- --with-pg-config=/opt/local/lib/postgresql93/bin/pg_config > ruby_error
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb --with-pg-config=/opt/local/lib/postgresql93/bin/pg_config
Using config values from /opt/local/lib/postgresql93/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
我曾想着既然是要使用 Node 而不是 Ruby,也许就不需要安装 pg gem,于是跳过了安装过程,进行接下来的步骤。但在第 3.3 步时遇到了错误:
$ sudo su postgres -c '/opt/local/lib/postgresql93/bin/initdb -D /opt/local/var/db/postgresql93/defaultdb'
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
could not identify current directory: Permission denied
The program "postgres" is needed by initdb but was not found in the
same directory as "initdb".
Check your installation.
检查我的 /opt/local/lib/postgresql93/bin/ 目录,我看到了 initdb
和 postgres
。我看到那些显示 "Permission denied" 的行并想知道这是怎么回事。
不确定如何继续。考虑使用 Postgres.app 如果它真的更容易,但不确定是否最好使用 MacPorts 进行安装,因为我大多数其他东西都使用 MacPorts 进行安装。感激任何关于我的问题的建议!