Advertisement
shottamo

postgres private instance/postgis

Mar 4th, 2015
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.34 KB | None | 0 0
  1. Like the related PostgreSQL Install Guide, you still need to create a new Custom Application (listening on port) in the control panel called "pgport" to reserve a port. Enter it as a shell variable:
  2.  
  3. export PGPORT=35270
  4. You can run these commands individually, or you can paste them into a shell script and run it as
  5.  
  6. bash build_psql.sh | tee build_psql.log
  7. Either way, you may want to run it in a screen session.
  8.  
  9. #!/bin/bash
  10.  
  11. mkdir -p $HOME/bin $HOME/lib $HOME/src $HOME/tmp
  12.  
  13. export TMPDIR=$HOME/tmp
  14. export PATH="$HOME/bin:$PATH"
  15. export C_INCLUDE_PATH="$HOME/include:$C_INCLUDE_PATH"
  16. export LIBRARY_PATH="$HOME/lib:$LIBRARY_PATH"
  17. export LD_LIBRARY_PATH="$HOME/lib:$LD_LIBRARY_PATH"
  18.  
  19. ############################################################
  20. # CARTODB COMPLETE INSTALL - DEPENDENCIES & INSTALL PRIORITY
  21. ############################################################
  22. # PROGRAM: VERSION: NOTES:
  23. # ----------------------------------------------------------
  24. # GDAL (1.9.0) http://download.osgeo.org/gdal/gdal-1.9.0.tar.gz
  25. # GEOS (3.3.1) http://download.osgeo.org/geos/geos-3.3.1.tar.bz2
  26. # Postgres (9.1.x) http://www.postgresql.org/ftp/source/v9.1.3/
  27. # PostGIS (2.0) http://postgis.refractions.net/download
  28.  
  29. ############################################################
  30. # GDAL (1.9.0)
  31. # http://download.osgeo.org/gdal/gdal-1.9.0.tar.gz
  32. ############################################################
  33. cd ~/src
  34. wget http://download.osgeo.org/gdal/gdal-1.9.0.tar.gz
  35. tar -xzf gdal-1.9.0.tar.gz
  36. cd gdal-1.9.0
  37. ./configure --prefix=$HOME
  38. make # 15m
  39. #make check
  40. make install
  41.  
  42. ############################################################
  43. # GEOS (3.3.1)
  44. # http://download.osgeo.org/geos/geos-3.3.1.tar.bz2
  45. ############################################################
  46. cd ~/src
  47. wget http://download.osgeo.org/geos/geos-3.3.1.tar.bz2
  48. tar -xjf geos-3.3.1.tar.bz2
  49. cd geos-3.3.1
  50. CFLAGS="-m64 $CFLAGS" CPPFLAGS="-m64 $CPPFLAGS" CXXFLAGS="-m64 $CXXFLAGS" \
  51. FFLAGS="-m64 $FFLAGS" LDFLAGS="-m64 -L$HOME/lib -L/usr/lib64/ $LDFLAGS" \
  52. ./configure --prefix=$HOME
  53. make # 4m 20s
  54. #make check
  55. make install
  56.  
  57. ############################################################
  58. # Postgres (9.1.3)
  59. # http://www.postgresql.org/ftp/source/v9.1.3/
  60. ############################################################
  61. cd ~/src
  62. wget http://ftp.postgresql.org/pub/source/v9.1.3/postgresql-9.1.3.tar.gz
  63. tar -xzf postgresql-9.1.3.tar.gz
  64. cd postgresql-9.1.3
  65. CPPFLAGS="-I$HOME/include $CPPFLAGS" LDFLAGS="-L$HOME/lib -L/usr/lib64/ $LDFLAGS" \
  66. ./configure PYTHON="${PYTHON}" --prefix=$HOME --with-pgport=$PGPORT --with-python --disable-thread-safety
  67. make # 3m 30s
  68. #make check
  69. make install
  70.  
  71. ############################################################
  72. # PostGIS (1.5.3)
  73. # http://postgis.refractions.net/download
  74. ############################################################
  75. cd ~/src
  76. wget http://postgis.refractions.net/download/postgis-1.5.3.tar.gz
  77. tar -xzf postgis-1.5.3.tar.gz
  78. cd postgis-1.5.3
  79. CPPFLAGS="-I$HOME/include $CPPFLAGS" LDFLAGS="-L$HOME/lib -L/usr/lib64/ $LDFLAGS" \
  80. ./configure --prefix=$HOME \
  81. --with-gdalconfig=$HOME/bin/gdal-config \
  82. --with-geosconfig=$HOME/bin/geos-config \
  83. --with-jsondir=$HOME \
  84. --with-projdir=$HOME \
  85. --with-pgconfig=$HOME/bin/pg_config
  86. make # 50s
  87. ### make check # can't test PostGIS until you have a database with PostGIS installed up and running.
  88. make install
  89. Okay, PostgreSQL should now be installed. After installation, you have some manual post-install setup and configuration to do:
  90.  
  91. #####################
  92. # Post Installation #
  93. #####################
  94.  
  95. # First, make sure that we're using the correct "psql", "createuser", and "createdb" commands:
  96. export PATH="$HOME/bin:$PATH"
  97. hash -r
  98.  
  99. # Add it to $HOME/.bashrc to make this permanent
  100. echo 'export PATH="$HOME/bin:$PATH"' >> $HOME/.bashrc
  101.  
  102. # Set up DB location
  103. mkdir $HOME/pgsql
  104. $HOME/bin/initdb -D $HOME/pgsql/data
  105.  
  106. # Start postgresql server
  107. $HOME/bin/postgres -D $HOME/pgsql/data >> $HOME/pgsql/log 2>&1 &
  108.  
  109. # Create the 'postgres' superuser
  110. createuser -s postgres -P
  111.  
  112. # Create a database 'mydb'
  113. createdb 'mydb'
  114.  
  115. # Now, connect to it (Use Ctrl-D to exit)
  116. psql -U postgres mydb
  117. Hope that helps!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement