手动安装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吧, 果然,搞定!

转载自:https://blog.csdn.net/u011170540/article/details/52248751

You may also like...