ubuntu源码安装postgresql(问题解决)转载

整个安装过程google无数遍,最后终于搭建完了。 
具体步骤,以及遇到error解决方案。 

1、wgethttp://ftp.postgresql.org/pub/source/v9.1.4/postgresql-9.1.4.tar.gzmkdir/usr/local/pgsql 


tar -zxvfpostgresql-9.1.4.tar.gz 



./configure -prefix=/usr/local/pgsql--without-readline 


make 
make install 




2、mkdir /usr/local/geos 
wgethttp://download.osgeo.org/geos/geos-3.3.5.tar.bz2 


tar jxf geos-3.3.5.tar.bz2 

cd geos-3.3.5 

./configure-prefix=/usr/local/geos 

make 

make install 



error: 

source='IndexedPointInAreaLocator.cpp'object='IndexedPointInAreaLocator.lo' libtool=yes\ 

    DEPDIR=.deps depmode=none /bin/bash ../../../depcomp\ 

    /bin/bash ../../../libtool--tag=CXX   --mode=compile g++-DHAVE_CONFIG_H -I. -I../../../include -I../../../include/geos-I../../../include   -DGEOS_INLINE  -pedantic -Wall -ansi-Wno-long-long  -ffloat-store  -c-o IndexedPointInAreaLocator.loIndexedPointInAreaLocator.cpp 

libtool: compile:  g++ -DHAVE_CONFIG_H -I.-I../../../include -I../../../include/geos -I../../../include-DGEOS_INLINE -pedantic -Wall -ansi -Wno-long-long -ffloat-store -cIndexedPointInAreaLocator.cpp  -o.libs/IndexedPointInAreaLocator.o 

../../../libtool: line 990: g++: command notfound 

make[4]: *** [IndexedPointInAreaLocator.lo] Error1 

make[4]: Leaving directory`/root/software/geos-3.3.5/src/algorithm/locate' 

make[3]: *** [all-recursive] Error1 

make[3]: Leaving directory`/root/software/geos-3.3.5/src/algorithm/locate' 

make[2]: *** [all-recursive] Error1 

make[2]: Leaving directory`/root/software/geos-3.3.5/src/algorithm' 

make[1]: *** [all-recursive] Error1 

make[1]: Leaving directory`/root/software/geos-3.3.5/src' 

make: *** [all-recursive] Error1 



解决: 

apt-get install g++ 

重新configure 

make 

make install 



3、mkdir /usr/local/proj4 

wgethttp://download.osgeo.org/proj/proj-4.8.0.tar.gz 


tar zxf proj-4.8.0.tar.gz 


cd proj-4.8.0 

./configure–prefix=/usr/local/proj4 
make 
make install 


4、mkdir /usr/local/postgis 
wgethttp://postgis.refractions.net/download/postgis-2.0.1.tar.gz 


tar zxf postgis-2.0.1.tar.gz 

cd postgis-2.0.1 

./configure -prefix=/usr/local/postgis--with-pgsql=/usr/local/pgsql/bin/pg_config--with-proj=/usr/local/proj4--with-geos=/usr/local/geos/bin/geos-config 



error: 
configure: error: could not find pg_config within the current path.You may need to try re-running configure with a --with-pgconfigparameter. 




解决: 

./configure -prefix=/usr/local/postgis--with-pgsql=/usr/local/pgsql/bin/pg_config--with-pgconfig=/usr/local/pgsql/bin/pg_config--with-proj=/usr/local/proj4--with-geos=/usr/local/geos/bin/geos-config 



configure: error: could not find xml2-config from libxml2 withinthe current path. You may need to try re-running configure with a--with-xml2config parameter. 



解决: 

apt-get install libxml2 

apt-get install libxml2-dev 



./configure -prefix=/usr/local/postgis--with-pgsql=/usr/local/pgsql/bin/pg_config--with-pgconfig=/usr/local/pgsql/bin/pg_config--with-proj=/usr/local/proj4--with-geos=/usr/local/geos/bin/geos-config 



error: 

configure: error: could not find geos-config within the currentpath. You may need to try re-running configure with a--with-geosconfig parameter. 



解决: 

./configure -prefix=/usr/local/postgis--with-pgsql=/usr/local/pgsql/bin/pg_config--with-pgconfig=/usr/local/pgsql/bin/pg_config--with-proj=/usr/local/proj4--with-geos=/usr/local/geos/bin/geos-config--with-geosconfig=/usr/local/geos/bin/geos-config 



error: 

configure: error: could not find proj_api.h - you may need tospecify the directory of a PROJ.4 installation using--with-projdir 



解决 : 

./configure -prefix=/usr/local/postgis--with-pgsql=/usr/local/pgsql/bin/pg_config--with-pgconfig=/usr/local/pgsql/bin/pg_config--with-proj=/usr/local/proj4--with-geos=/usr/local/geos/bin/geos-config--with-geosconfig=/usr/local/geos/bin/geos-config--with-projdir=/usr/local/proj4 



error: 

configure: error: gdal-config not found. Use --without-raster ortry --with-gdalconfig= 



解决: 

apt-cache search GDAL 

apt-get install libgdal1-dev 







configure: WARNING: unrecognized options: --with-pgsql,--with-proj, --with-geos 





Java代码    收藏代码
  1. PostGIS is now configured for x86_64-unknown-linux-gnu  
  2.   
  3.   
  4.   
  5. -------------- Compiler Info -------------  
  6.   
  7.  compiler:           gcc -g -O2  
  8.   
  9.  C++ compiler:         g++ -g -O2  
  10.   
  11.  SQL preprocessor:     /usr/bin/cpp -traditional-cpp -P  
  12.   
  13. ------------- Dependencies --------------  
  14.   
  15.  GEOS config:          /usr/local/geos/bin/geos-config  
  16.   
  17.  GEOS version:         3.3.5  
  18.   
  19.  GDAL config:          /usr/bin/gdal-config  
  20.   
  21.  GDAL version:         1.6.3  
  22.   
  23.  PostgreSQL config:    /usr/local/pgsql/bin/pg_config  
  24.   
  25.  PostgreSQL version:   PostgreSQL 9.1.4  
  26.   
  27.  PROJ4 version:        48  
  28.   
  29.  Libxml2 config:       /usr/bin/xml2-config  
  30.   
  31.  Libxml2 version:      2.7.6  
  32.   
  33.  JSON-C support:       yes  
  34.   
  35.  PostGIS debug level:  0  
  36.   
  37.  Perl:                 /usr/bin/perl  
  38.   
  39.   
  40.   
  41. --------------- Extensions ---------------  
  42.   
  43.  PostGIS Raster:       enabled  
  44.   
  45.  PostGIS Topology:     enabled  
  46.   
  47.   
  48.   
  49. -------- Documentation Generation --------  
  50.   
  51.  xsltproc:              
  52.   
  53.  xsl style sheets:      
  54.   
  55.  dblatex:               
  56.   
  57.  convert:               
  58.   
  59.  mathml2.dtd:          http://www.w3.org/Math/DTD/mathml2/mathml2.dtd  








final config: 

./configure -prefix=/usr/local/postgis --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-geosconfig=/usr/local/geos/bin/geos-config--with-projdir=/usr/local/proj4 



make 

make install 



------------------------------------------------------------------------ 
Java代码    收藏代码
  1. WARNING: You have set the --prefix to '/usr/local/postgis'But we mostly     
  2.   
  3.  ignore the --prefix. For your info, using the values determined from  
  4.   
  5.  /usr/local/pgsql/bin/pg_config we will be installing:    
  6.   
  7.    postgis shared library in /usr/local/pgsql/lib  
  8.   
  9.    postgis SQL files in /usr/local/pgsql/share/contrib/postgis-2.0  
  10.   
  11.    postgis executables in /usr/local/pgsql/bin  
### Ubuntu 上编译安装 PostgreSQL 并进行调试 #### 准备工作 为了成功编译并安装 PostgreSQL,需确保系统已更新至最新状态,并安装必要的构建工具和依赖项。对于基于 Debian 的发行版如 Ubuntu,可以使用如下命令来获取所需软件包: ```bash sudo apt-get update && sudo apt-get upgrade -y sudo apt-get install build-essential libreadline-dev zlib1g-dev flex bison openssl libssl-dev ``` #### 下载源码 从官方提供的链接下载目标版本的 PostgreSQL 源代码压缩包[^2]。 ```bash wget https://ftp.postgresql.org/pub/source/v14.1/postgresql-14.1.tar.gz tar xfz postgresql-14.1.tar.gz cd postgresql-14.1/ ``` #### 构建与安装 创建一个独立于源文件夹之外的工作空间用于编译过程中的临时文件存储;接着通过 `../configure` 命令配置编译选项,再利用 Make 工具完成实际编译流程。最后一步则是将生成的应用程序及其资源部署到自定义路径下以便后续管理维护。 ```bash mkdir build && cd build ../configure --prefix=/usr/local/pgsql14.1 make world sudo make install-world DESTDIR=/home/user/path/to/installation/directory ``` 注意这里 `/usr/local/pgsql14.1` 是建议的目标位置而 `/home/user/path/to/installation/directory` 则代表最终安装目录,请根据实际情况调整这些参数设置。 #### 初始化数据库集群和服务启动 首次运行之前要初始化一个新的数据集实例,这可以通过执行 initdb 来实现。之后就可以正常开启服务端口监听等待客户端连接请求了。 ```bash /usr/local/pgsql14.1/bin/initdb -D /path/to/data_directory /usr/local/pgsql14.1/bin/pg_ctl -D /path/to/data_directory start ``` #### Eclipse 中配置 PostgreSQL 调试环境 按照《PostgreSQL 数据库内核分析》书籍指导以及 Postgres 官方 Wiki 页面上的说明,在 Eclipse IDE 内建立相应的开发项目结构,加载 PGSQL 源代码作为本地模块加入工程之中。确保所有必需插件均已正确装载完毕后,便可在图形界面里方便快捷地开展断点跟踪、变量查看等一系列高级功能操作[^1]。 ```python import os os.environ['PATH'] += ':/usr/local/pgsql14.1/bin' ``` 以上 Python 语句展示了怎样向系统的 PATH 环境变量追加 PostgreSQL 执行文件所在的位置,从而使得可以在任何地方调用 psql 或其他相关命令行工具而不必每次都指明全限定名。 #### 升级注意事项 当计划迁移到更高版本比如 PostgreSQL 16.3 版本时,只需要重新经历一遍上述提到过的编译环节,随后停止旧的服务进程并将符号链接切换成指向新的二进制集合即可迅速达成目的[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值