search
HomeDatabaseMysql TutorialLiunx环境下源码安装PostgreSQL+PostGIS

Liunx环境下源码安装PostgreSQL+PostGIS,检查功能的函数,如Touches(), Contains(), Disjoint() 还有一些空间操作函数,如Inter

生产环境中安装postgreSQL + postGIS

生产环境如下:

操作系统:

CentOS release 5.5 (Final)

需要安装:

postgresql 地址:

postgis 地址:

proj 地址:

geos 地址:

安装步骤:

postgre的安装 版本为9.1.3

  • wget
  • tar -jxvf postgresql-9.1.3.tar.bz2
  • cd postgresql-9.1.3
  • ./configure
  • gmake --> All of PostgreSQL successfully made. Ready to install.
  • gmake install --> PostgreSQL installation complete.
  • vim INSTALL 可以查看其官方安装步骤:

  • ./configure
  • gmake
  • su
  • gmake install 安装软件到指定的配置阶段prefix指定的目录下
  • adduser postgres 添加postgres用户,postgreSQL的默认超级管理员
  • mkdir /usr/local/pgsql/data 创建存放数据的目录
  • chown postgres /usr/local/pgsql/data 改变文件拥有者
  • su - postgres 切换到postgres用户
  • /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data 初始化磁盘上的数据库的存储区间
  • -- 成功后会提醒 /usr/local/pgsql/bin/postgres -D /data/pgsql or /usr/local/pgsql/bin/pg_ctl -D /data/pgsql -l logfile start
  • /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data >logfile 2>&1 & 指定数据目录启动数据库服务器(输出重定向到logfile,并且运行在后台,也可以用pg_ctl来启动)
  • /usr/local/pgsql/bin/createdb test 创建测试数据库,确认安装顺利完成
  • ...

    配置一下环境变量:

    LD_LIBRARY_PATH=/usr/local/pgsql/lib 动态连接库的所在目录

    PATH=/usr/local/pgsql/bin:$PATH 为了方便使用,添加命令的搜索路径

    输入pg_config 查看

  • BINDIR = /usr/local/pgsql/bin
  • DOCDIR = /usr/local/pgsql/share/doc
  • HTMLDIR = /usr/local/pgsql/share/doc
  • INCLUDEDIR = /usr/local/pgsql/include
  • PKGINCLUDEDIR = /usr/local/pgsql/include
  • INCLUDEDIR-SERVER = /usr/local/pgsql/include/server
  • LIBDIR = /usr/local/pgsql/lib
  • PKGLIBDIR = /usr/local/pgsql/lib
  • LOCALEDIR = /usr/local/pgsql/share/locale
  • MANDIR = /usr/local/pgsql/share/man
  • SHAREDIR = /usr/local/pgsql/share
  • SYSCONFDIR = /usr/local/pgsql/etc
  • PGXS = /usr/local/pgsql/lib/pgxs/src/makefiles/pgxs.mk
  • CONFIGURE =
  • CC = gcc
  • CPPFLAGS = -D_GNU_SOURCE
  • CFLAGS = -O2 -Wall -Wmissing-prototypes -Wpointer-arith -Wdeclaration-after-statement -Wendif-labels -Wformat-security -fno-strict-aliasing -fwrapv
  • CFLAGS_SL = -fpic
  • LDFLAGS = -Wl,-rpath,'/usr/local/pgsql/lib',--enable-new-dtags
  • LDFLAGS_EX =
  • LDFLAGS_SL =
  • LIBS = -lpgport -lz -lreadline -ltermcap -lcrypt -ldl -lm
  • VERSION = PostgreSQL 9.1.3
  • postgreSQL 安装完毕。

    注意事项:安装postgres 时

    readline库(默认),命令行编辑功能,这个库虽然不是必须的(可以在配置阶段通过 --without-readline选项来取消),但是强烈建议安装readline,

    使用psql时,可以使用方向键来选择和编辑前面键入的命令

    查看是否安装过 rpm -qa | grep readline

    zlib库(默认),主要用于pg_dump和pg_restore两个操作的数据压缩功能,这个库也不是必须的(可以在配置阶段通过--without-zlib选项来取消),

    查看是否安装过 rpm -qa | grep zlib

    在编译程序前必须要安装这些包,否则无法通过编译,此外,还有在配置阶段还有很多可选包,可以通过./configure --help查看

    选项 描述

    – prefix = prefix安装到prefix指向的目录;默认为/usr/local/pgsql

    – bindir = dir安装应用程序到dir;默认为prefix/bin

    – with-d ocdir= dir安装文档到dir;默认为prefix/doc

    – with-p gport= port设置默认的服务器端网络连接服务TCP端口号

    – with-t cl为服务端提供Tcl存储过程支持

    – with-p erl为服务端提供Perl存储过程支持

    – with-p ython为服务端提供Python存储过程支持

    PostGIS 的安装 版本为 PostGIS 1.5.4 Release

    首先下载源码包 proj-4.8.0,geos-3.3.3,libxml2-2.6.26,虽然这三个库不是安装postgis强制的,但是,没有这三个包,

    postgis一定程度上失去了空间数据库的意义。因为Proj4提供了投影的相关操作,如postgis中的transform()函数,,geos则为postgis提供了很多拓扑

    linux

    Statement
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

    MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

    MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

    ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

    MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

    ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

    MySQL: String Data Types and ENUMs?MySQL: String Data Types and ENUMs?May 13, 2025 am 12:05 AM

    MySQloffersechar, Varchar, text, Anddenumforstringdata.usecharforfixed-Lengthstrings, VarcharerForvariable-Length, text forlarger text, AndenumforenforcingdataAntegritywithaetofvalues.

    MySQL BLOB: how to optimize BLOBs requestsMySQL BLOB: how to optimize BLOBs requestsMay 13, 2025 am 12:03 AM

    Optimizing MySQLBLOB requests can be done through the following strategies: 1. Reduce the frequency of BLOB query, use independent requests or delay loading; 2. Select the appropriate BLOB type (such as TINYBLOB); 3. Separate the BLOB data into separate tables; 4. Compress the BLOB data at the application layer; 5. Index the BLOB metadata. These methods can effectively improve performance by combining monitoring, caching and data sharding in actual applications.

    Adding Users to MySQL: The Complete TutorialAdding Users to MySQL: The Complete TutorialMay 12, 2025 am 12:14 AM

    Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

    Mastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMay 12, 2025 am 12:12 AM

    ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

    MySQL: String Data Types and Indexing: Best PracticesMySQL: String Data Types and Indexing: Best PracticesMay 12, 2025 am 12:11 AM

    Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.

    See all articles

    Hot AI Tools

    Undresser.AI Undress

    Undresser.AI Undress

    AI-powered app for creating realistic nude photos

    AI Clothes Remover

    AI Clothes Remover

    Online AI tool for removing clothes from photos.

    Undress AI Tool

    Undress AI Tool

    Undress images for free

    Clothoff.io

    Clothoff.io

    AI clothes remover

    Video Face Swap

    Video Face Swap

    Swap faces in any video effortlessly with our completely free AI face swap tool!

    Hot Article

    Hot Tools

    VSCode Windows 64-bit Download

    VSCode Windows 64-bit Download

    A free and powerful IDE editor launched by Microsoft

    WebStorm Mac version

    WebStorm Mac version

    Useful JavaScript development tools

    mPDF

    mPDF

    mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

    SAP NetWeaver Server Adapter for Eclipse

    SAP NetWeaver Server Adapter for Eclipse

    Integrate Eclipse with SAP NetWeaver application server.

    Notepad++7.3.1

    Notepad++7.3.1

    Easy-to-use and free code editor