Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
LAMP stack with Postgres/PostGIS
# update and add user
apt-get update
useradd -G users <username>
passwd <username>
visudo #add sparafina to shudders
# install apache
apt-get install apache2
apt-get install php5 libapache2-mod-php5
apt-get install php5-pgsql
/etc/init.d/apache2 restart
# test php
vi /var/www/test.php
# copy into test.php
# <?php phpinfo(); ?>
# check browser to see if php info displays
#install postgres
sudo apt-get -y install libxml2-dev
sudo apt-get -y install postgresql-8.4 postgresql-server-dev-8.4 postgresql-contrib-8.4 libpq-dev
/etc/init.d/postgresql-8.4 stop
apt-get -y install bzip2 g++ checkinstall
# install geos
cd /tmp
bunzip2 geos-3.3.0.tar.bz2
tar xvf geos-3.3.0.tar
chown -R sparafina /tmp/geos-3.3.0
cd geos-3.3.0
make install
# install proj
cd ..
wget xvfz proj-4.7.0.tar.gz
cd proj-4.7.0
make install
# install postgis
cd ..
tar xvfz postgis-1.5.3.tar.gz
cd postgis-1.5.3
make install
# configure postgres
sudo -u postgres /etc/init.d/postgresql-8.4 start
sudo -u postgres psql -c"ALTER user postgres WITH PASSWORD '<password>'"
# configure postgis
sudo -u postgres createdb postgis_template
sudo -u postgres createlang -dpostgis_template plpgsql
sudo -u postgres psql -dpostgis_template -f /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
sudo -u postgres psql -dpostgis_template -f /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
sudo -u postgres psql -dpostgis_template -c"select postgis_lib_version();"
# configure postgres to accept connections
cd /etc/postgresql/8.4/main/
vi pg_hba.conf
# add:
# host all all md5
vi postgresql.conf
# add:
# listen_addresses = '*'
# password_encryption = on
# restart postgres/ connect with pgadmin
etc/init.d/postgresql-8.4 stop
/etc/init.d/postgresql-8.4 start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment