手动安装postgis时遇到的坑

在使用源代码安装postgis的过程中, 需要先安装proj-4.9.1,geos-3.5.0,libxml2-2.6.30, 最后再安装postgis. 以下是安装过程中遇到的坑.

1. 安装libxml需要有权限创建py脚本. 给当前用户配上权限就好。

make[5]: Entering directory `/ODM/hanxin/diamond/libxml2-2.9.4/python'
make[5]: Nothing to be done for `install-exec-am'.
 /bin/mkdir -p '/data/hanxin/diamond/app/postGIS/libxml2-2.9.4/share/doc/libxml2-python-2.9.4'
 /usr/bin/install -c -m 644 TODO '/data/hanxin/diamond/app/postGIS/libxml2-2.9.4/share/doc/libxml2-python-2.9.4'
 /bin/mkdir -p '/usr/lib/python2.6/site-packages'
 /usr/bin/install -c -m 644 drv_libxml2.py libxml2.py '/usr/lib/python2.6/site-packages'
/usr/bin/install: cannot create regular file `/usr/lib/python2.6/site-packages/drv_libxml2.py': Permission denied
/usr/bin/install: cannot create regular file `/usr/lib/python2.6/site-packages/libxml2.py': Permission denied
make[5]: *** [install-dist_pythonDATA] Error 1


2. 安装postgis后运行脚本创建各种function (psql -d postgis -f postgis.sql)

首先,因为这是一个很大的脚本, 满满一大屏幕的错误反复出现'psql:postgis.sql:6828: ERROR:  current transaction is aborted, commands ignored until end of transaction block'. 根据判断应该是上面某个sql就出错了, 需要把它揪出来. 

于是运行psql -d postgis -f postgis.sql -s, 逐个执行确认, 观察是否出错, 很快找到了出错的部分抛出异常

ERROR:  could not load library "/usr/local/pgsql/lib/postgis-2.0.so": libgeos_c.so.1: cannot open shared object file: No such file or directory

于是运行ldd postgis-2.0.so看看究竟哪些文件缺了, 发现是libgeos_c.so.1和libproj.so.9!

虽然不明白为什么安装geo和proj时会少copy这两个文件到postgis/lib下,但既然在这两个项目安装目录的lib文件下能找到这两个文件, 那就试试手动copy吧, 果然,搞定!


  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Rocky Linux 是一个新兴的 Linux 发行版,它是由 CentOS 的原始开发人员创建的,目的是成为 CentOS 8 的替代品。安装 PostGIS 可以让我们在 Rocky Linux 上使用 PostgreSQL 数据库来存储和管理地理空间数据。下面是在 Rocky Linux 上安装 PostGIS 的步骤: 1. 更新系统软件包 在安装 PostGIS 之前,最好先更新一下系统中的所有软件包,以确保系统中已经安装了最新的软件包。可以使用以下命令更新系统: ``` sudo dnf update ``` 2. 安装 PostgreSQL PostGIS 是 PostgreSQL 的扩展,因此首先需要安装 PostgreSQL。在 Rocky Linux 上,可以使用以下命令安装 PostgreSQL: ``` sudo dnf install postgresql-server postgresql-contrib ``` 安装完成后,启动 PostgreSQL 服务并设置开机自启动: ``` sudo systemctl enable postgresql.service sudo systemctl start postgresql.service ``` 3. 安装 PostGIS 安装完 PostgreSQL 后,就可以安装 PostGIS 了。可以使用以下命令安装 PostGIS: ``` sudo dnf install postgis postgis-utils ``` 4. 创建 PostGIS 扩展 安装完成后,需要在 PostgreSQL 中创建 PostGIS 扩展。可以使用以下命令登录到 PostgreSQL: ``` sudo -u postgres psql ``` 然后在 psql 提示符下输入以下命令: ``` CREATE EXTENSION postgis; ``` 这将在 PostgreSQL 中创建 PostGIS 扩展。 5. 验证 PostGIS 安装 要验证 PostGIS 是否已正确安装,请输入以下命令: ``` SELECT postgis_full_version(); ``` 如果一切正常,将显示当前安装PostGIS 版本信息。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

PatrickYung

你的打赏是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值