반응형

PostgreSQL에  PostGIS 3.4 설치

Rocky Linux 9

 

PostGIS 3.4 기준 아래의 링크를 확인하면, 

PostgreSQL 12 ~ 16  버전의 경우 필수 패키지 버전 확인이 가능하다.

https://postgis.net/docs/manual-3.4/postgis_installation.html

 

Chapter 2. PostGIS Installation

2.2. Compiling and Install from Source Many OS systems now include pre-built packages for PostgreSQL/PostGIS. In many cases compilation is only necessary if you want the most bleeding edge versions or you are a package maintainer. This section includes ge

postgis.net

 

필수 패키지 버전을 참고하여, 아래의 링크에서 다운로드

proj 6.1 이상 https://proj.org/ (proj-9.4.0)
GEOS 3.6 이상 https://libgeos.org (geos-3.12.1)
GDAL 3 https://gdal.org/download.html (gdal-3.4.3)
JSON-C 0.9이상 https://github.com/json-c/json-c/releases/ (json-c-0.15)
LibXML2 2.5 이상  https://gitlab.gnome.org/GNOME/libxml2/-/releases (2.12.1)

#아래의 패키지는 필수라고 나와있으나, 설치 링크 연결도 안되고 없어도 설치가 되는 것 확인
PostgreSQL+JIT, LLVM 6이상 https://trac.osgeo.org/postgis/ticket/4125 (설치 안함 - 링크 연결안됨)

 

 

 

- SQLite 버전 업데이트 (PROJ9.4 설치시 sqlite 3.11 버전 이상 필요)

SQLite 버전이 3.11보다 높은경우 다음 단계로 넘어가도록 하자

#SQLite 버전 확인 명령어
sqlite3 --version

 

-- sqlite tar 압축해제 및 설치 (https://www.sqlite.org/download.html)

tar -xvf sqlite-autoconf-3450300.tar.gz
cd ./sqlite-autoconf-3450300
./configure 
make
make install
sqlite3 --version

 

-- 환경변수 설정(버전확인시 기존 설치 버전으로 나오기때문에 필요)

vi /etc/profile

export LD_LIBRARY_PATH=/usr/local/lib

source /etc/profile

 

-- SQLite 버전 확인하여 아래와 같은 버전으로 나오면 완료

sqlite3 --version
3.45.3 2024-04-15 13:34:05

 

 

 

 

- CMake 설치 (PROJ9.4 설치시 cmake 명령어 필요)

CMake가 설치되어 있다면, 다음 단계로 넘어가도록 하자

#cmake 버전 확인 명령어
cmake --version

 

-- cmake tar 압축해제 및 설치 (https://cmake.org/download/)

tar -xvf cmake-3.29.3.tar.gz
cd ./cmake-3.29.3
./bootstrap --prefix=/usr/local
make
make install

cmake --version

 

 

- PROJ 설치

-- proj tar 압축해제 및 설치 (https://proj.org/en/9.4/download.html)(https://proj.org/en/9.4/install.html)

tar -xvf proj-9.4.0.tar.gz
cd ./proj-9.4.0
mkdir ./build
cd ./build
#외부인터넷이 안되는 환경이므로 BUILD_TESTING=OFF 옵션 적용 
cmake -DBUILD_TESTING=OFF -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ ..
cmake --build .
cmake --build . --target install
#삭제 방법 cmake --build . --target uninstall

 

PROJ 설치 실패로 인한 추가 설치, 아래명령어로 확인후 버전에 맞게 설치

rpm -qa|grep libtiff 
rpm -qa|grep libcurl

 

 

- GEOS 설치

--geos tar 압축해제 및 설치 (https://libgeos.org/usage/download/)

tar -xvf geos-3.12.1.tar.bz2
cd ./geos-3.12.1
mkdir ./_build
cd ./_build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ ..
make
ctest
make install

 

 

- GDAL 설치

-- gdal tar 압축해제 및 설치 (https://gdal.org/download.html / https://gdal.org/development/building_from_source.html)

tar -xvf gdal-3.4.3.tar.gz
cd ./gdal-3.4.3
./configure --with-sqlite3=/usr/local/bin/sqlite3
make
make install

gdalinfo --version

 

 

- JSON-C 설치

-- json-c tar 압축해제 및 설치 (https://s3.amazonaws.com/json-c_releases/releases/index.html)

tar -xvf json-c-0.15.tar.gz
cd ./json-c-0.15
mkdir ./build
cd ./build
cmake -DCMAKE_INSTALL_PREFIX=/usr/local ..
make
make install

 

 

- LibXML2 설치

-- libxml2가 이미 설치되어있어서, libxml2-devel만 버전에 맞게 설치 

rpm -qa|grep libxml2

 

 

- POSTGIS 설치 

-- postgis  tar -xvzf postgis-3.4.2.tar.gz (https://postgis.net/development/source_code/)

tar -xvzf postgis-3.4.2.tar.gz
cd ./postgis-3.4.2
./configure --with-pgconfig=/home/postgres/pgsql/bin/pg_config --with-raster --without-protobuf --with-jsondir=/usr/local

make
make install

(pg_config 파일은 postgresql 설치 경로에 위치)
(protobuf를 사용하지 않으므로  ' --without-protobuf ' 옵션 사용)

(위에서 json-c 수동 설치 했을경우, ' -DCMAKE_INSTALL_PREFIX=/usr/local ' 옵션을 사용했기때문에

' --with-jsondir=/usr/local '  옵션으로 경로로 잡아줘야 json-c 위치를 찾음)

 

- Extensions 추가 설치

-- POSTGIS

cd extensions/postgis
make clean
make && make install
cd ..

 

-- POSTGIS_TOPOLOGY

cd postgis_topology
make clean
make && make install
반응형
반응형

외부 네트워크가 불가능한 상황에서 Apache를 설치하는 방법

Rocky Linux 9

 

- Apache Source 파일 다운로드

아래의 URL을 접속하여, tar파일을 다운로드

https://httpd.apache.org/download.cgi

 

Download - The Apache HTTP Server Project

Downloading the Apache HTTP Server Use the links below to download the Apache HTTP Server from our download servers. You must verify the integrity of the downloaded files using signatures downloaded from our main distribution directory. The signatures can

httpd.apache.org

 

- 필수 패키지 확인 및 설치
이 부분이 가장 시간이 많이  소요되며, 외부 인터넷이 안되는 불편함을 느끼는 부분

apr
apr-util
gcc
gcc-c++
pcre
pcre-devel
expat
expat-devel
zlib-devel

openssl(ssl 적용시)

 

- 아파치 경로 생성 및 압축 해제

(/home/user 경로안에 생성)

#아파치 설치 경로 생성
cd /home/user
mkdir ./web

#httpd-2.4.54.tar.gz 파일 옮겨놓고 압축해제
cd /home/user/web
tar -zxvf httpd-2.4.54.tar.gz

#심볼릭 링크 생성
ln -s /home/user/web/httpd-2.4.54 apache

 

- apr & apr-util 압축 풀기 및 이동

( apr & apr-util 의 경우 tar파일을 받아 압축해제 후 아파치 경로의 srclib로 이동시켜줘야한다.)

아래의 경로에서 다운받을 수 있다.

https://apr.apache.org/download.cgi

 

Download - The Apache Portable Runtime Project

The currently selected mirror is https://dlcdn.apache.org/. If you encounter a problem with this mirror, please select another mirror. If all mirrors are failing, there are backup mirrors (at the end of the mirrors list) that should be available. You may a

apr.apache.org

#apr & apr-util 압축해제
tar -zxvf apr-1.7.0.tar.gz
tar -zxvf apr-util-1.6.1.tar.gz

#apr & apr-util 이동
mv apr-1.7.0 /home/user/web/apache/srclib/apr 
mv apr-util-1.6.1 /home/user/web/apache/srclib/apr-util

 

 

- gcc & gcc-c++ & pcre & pcre-devel &  expat & expat-devel & zlib-devel 

서버마다 설치되어있는 경우도 있고, OS 버전에 맞게 다운로드 받아서 수동 설치

 

 

- 아파치 설치 (ssl 미적용)

cd /dopco/web/apache
./configure --prefix=/home/user/web/apache --with-included-apr --enable-module=so --enable-mods-shared=all --enable-so --enable-deflate --enable-rewrite
make
make install

 

경우에 따라서 아래의 아파치 설치 옵션 참고

https://httpd.apache.org/docs/2.4/programs/configure.html#installationdirectories

 

configure - 소스 트리를 구성한다 - Apache HTTP Server Version 2.4

configure - 소스 트리를 구성한다 이 문서는 최신판 번역이 아닙니다. 최근에 변경된 내용은 영어 문서를 참고하세요. configure 스크립트는 특정 플래폼에서 아파치 웹서버를 컴파일하고 설치하기

httpd.apache.org

 

 

-http.conf 파일 수정

vi /home/user/web/apache/conf/http.conf

#ServerName 검색 후 주석처리 해제
ServerName localhost:80

 

 

- 아파치 실행

/home/user/web/apache/bin/apachectl start

 

---------------------- 아래의 내용은 필요한 경우 참조----------------------

 

- 80포트 방화벽 허용

(su - 통해 root 접속 필요)

firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --reload
firewall-cmd --list-ports

 

- apache 실행 권한 부여

(user로 apache 실행이 불가한 경우 su - 통해 root 접속 후 user에 실행권한 부여 필요)

chmod -Rf 755 /home/user/
cd /home/user/web/apache/bin
chown root:user httpd
chmod +s httpd
chown user:user apachectl
반응형
반응형

외부 네트워크가 불가능한 상황에서 PostgreSQL 15를 설치하는 방법

Rocky Linux 9

 

- EPEL 저장소 설치 (https://pkgs.org/download/epel-release)

OS 버전에 맞는 EPEL 을 다운받아 설치해주도록하자

rpm -ivh epel-release-9-7.el9.noarch.rpm

 

 

- PostgreSQL Source 파일 다운로드

아래의 URL을 접속하여, 원하는 버전의 tar파일을 다운로드

( 여기서는 postgresql-15.1.tar.gz  다운로드)

https://www.postgresql.org/ftp/source/

 

PostgreSQL: File Browser

 

www.postgresql.org

 

- 필수 패키지 확인 및 설치

이 부분이 가장 시간이 많이  소요되며, 외부 인터넷이 안되는 불편함을 느끼는 부분

(아래의 링크를 통해 필수 패키지 버전 확인이 가능하다.)

https://www.postgresql.org/docs/15/install-requirements.html

 

17.2. Requirements

17.2. Requirements In general, a modern Unix-compatible platform should be able to run PostgreSQL. The platforms that had received specific testing …

www.postgresql.org

 

rpm -qa|grep 명령어를 사용하여, 기존에 설치되어 있는 패키지 및 버전 확인하여 다운로드하여 설치

(추가로 필요한 패키지가 있는지 모르겠지만, 아래 정도만으로 설치 완료)

rpm -qa|grep glibc
rpm -qa|grep make
rpm -qa|grep gcc
rpm -qa|grep gcc-c++
rpm -qa|grep readline
rpm -qa|grep readline-devel
rpm -qa|grep zlib
rpm -qa|grep zlib-devel
rpm -qa|grep autoconf
rpm -qa|grep openssl
rpm -qa|grep openssl-devel
rpm -qa|grep uuid
rpm -qa|grep gettext
rpm -qa|grep gettext-devel

 

- root 접속

su -

 

- 유저 생성

groupadd postgres
useradd -g postgres -d /home/postgres postgres
passwd postgres
#유저 확인
cat /etc/passwd

#유저 디렉토리 변경
usermod -d /home/postgres postgres

 

- PATH 설정

vi /etc/profile
export PG_HOME=/home/postgres/pgsql
export PATH=$PG_HOME/bin:$PATH
export PGDATA=$PG_HOME/data
export LD_LIBRARY_PATH=$PG_HOME/lib
source /etc/profile

 

- tar 압축 해제 & 설치

https://www.postgresql.org/docs/15/install-procedure.html

 

17.4. Installation Procedure

17.4. Installation Procedure 17.4.1. configure Options 17.4.2. configure Environment Variables Configuration The first step of the installation procedure is to configure …

www.postgresql.org

 

tar -xvf postgresql-15.1.tar.gz
cd postgresql-15.1
./configure --prefix=/home/postgres/pgsql --enable-depend --enable-nls=utf-8 -with-openssl --with-ossp-uuid
make world
make check
make install-docs
make install-world

 

- PostgreSQL 초기화 (initdb)

cd /home/postgres/pgsql
mkdir ./data

cd /home/postgres/pgsql/bin
initdb -E utf-8 -D /home/postgres/pgsql/data

 

- 설정 파일 수정

postgresql.conf

vi /home/postgres/pgsql/data/postgresql.conf

#아래 내용 수정
#listen addresses ='localhost'
->
listen addresses ='*'

 

pg_hba.conf

vi /home/postgres/pgsql/data/pg_hba.conf

#아래 내용 추가
host    all             all             0.0.0.0/0               trust
host    all             all             all                     trust

 

- PostgreSQL 실행

cd /home/postgres/pgsql/bin
pg_ctl start -D /home/postgres/pgsql/data

 

- PostgreSQL 접속

cd /home/postgres/pgsql/bin
psql
\password postgres
\q
반응형

+ Recent posts