我正在尝试在配备 M2 处理器的 Mac 上安装 PostgreSQL 和 Postgis 扩展。
我尝试遵循各种在线说明,但到目前为止还没有成功。
以下是我的安装步骤:
我已使用 https://www.postgresql.org/download/macosx/ 中的安装程序安装了 PostgreSQL 16。 PostgreSQL的安装路径为:/Library/PostgreSQL/16/
然后我使用“brew install postgis”来安装postgis扩展。它安装在:/opt/homebrew/Cellar/postgis/3.3.4_1。
执行“创建扩展 postgis;”在 PostgreSQL 中并收到:详细信息:无法打开扩展控制文件“/Library/PostgreSQL/16/share/postgresql/extension/postgis.control”:没有这样的文件或目录。
postgis 似乎安装到了 PostgreSQL 无法找到的brew 位置。想知道是否有人可以告诉我我是否错过了安装中的任何明显步骤。
我也尝试过:
将“shared_preload_libraries = 'postgis'”添加到 PostgreSQL 配置文件中。但由于 PostgreSQL 无法在 /Library/PostgreSQL/16/share/postgresql/extension/ 中找到 postgis。更改配置后服务器将无法启动。
一些在线链接建议通过 Stack Builder 安装 postgis。该选项在最新版本中不可用。
看来我应该为 PostgreSQL 16 安装 postgis 3.4.0。出于某种原因,Brew 似乎默认为我安装 3.3.4。想知道这是否是我的问题的原因。
目前,brew postgis公式链接到PostgreSQL 14,但您可以在Mac M2上手动编译PostGIS for PostgreSQL 16。
brew install postgresql@16
brew install postgis
# or install required libs/packages manually (brew install geos gdal libxml2 sfcgal ...)
sudo ln -s /opt/homebrew/Cellar/postgresql@16/16.0/bin/postgres /usr/local/bin/postgres
wget https://download.osgeo.org/postgis/source/postgis-3.4.0.tar.gz
tar -xvzf postgis-3.4.0.tar.gz
rm postgis-3.4.0.tar.gz
cd postgis-3.4.0
./configure --with-projdir=/opt/homebrew/opt/proj --with-protobufdir=/opt/homebrew/opt/protobuf-c --with-pgconfig=/opt/homebrew/opt/postgresql@16/bin/pg_config --with-jsondir=/opt/homebrew/opt/json-c --with-sfcgal=/opt/homebrew/opt/sfcgal/bin/sfcgal-config --with-pcredir=/opt/homebrew/opt/pcre "LDFLAGS=$LDFLAGS -L/opt/homebrew/Cellar/gettext/0.22.2/lib" "CFLAGS=-I/opt/homebrew/Cellar/gettext/0.22.2/include"
make
make install
仍然遇到这个问题。尝试了一切..看看我的问题... 由于缺少标头和配置文件,在 macOS 上编译 PostGIS 时出现问题,特别是 PostgreSQL 16