Rocky Linux 9正式版发布已有一段时间了,它属于稳定的Linux发行版,有的海外主机已陆续提供该系统支持。PostgreSQL是款功能强大的开源关系型数据库,本文将介绍下如何在Rocky Linux 9上安装PostgreSQL和PostGIS。
首先,使用SSH工具登录到Rocky Linux服务器,然后运行下面命令来安装EPEL和PostgreSQL数据库。
dnf -y install epel-release
dnf -y install https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
启用Code Ready Builder(CRB)。
dnf -y config-manager –set-enabled crb
禁用PostgreSQL模块。
dnf -qy module disable postgresql
开始安装PostgreSQL和PostGIS。例如,运行下面命令安装PostgreSQL 14服务器。
dnf -y install postgis32_14
初始化群集。
/usr/pgsql-14/bin/postgresql-14-setup initdb
启动PostgreSQL服务。
systemctl enable –now postgresql-14
切换到postgres用户。
su – postgres
创建数据库:
createdb my_gis_db