Skip to content

Instantly share code, notes, and snippets.

@axd1967
Last active April 6, 2017 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axd1967/529e4f128eb7fa14d008809835cedb7b to your computer and use it in GitHub Desktop.
Save axd1967/529e4f128eb7fa14d008809835cedb7b to your computer and use it in GitHub Desktop.
install php5-gdal (GDAL 2) fails
#!/usr/bin/env bash
# big note: a while after creating this file, I stumbled across https://github.com/phalcon/vagrant/
THIS=`basename $0`
BASE=/vagrant/vagrant
source $BASE/const.sh
UBUNTU_VERSION=`lsb_release -a`
# Belnet repositories for ludicrous speed! (thx Michiel)
cat > /etc/apt/sources.list << EOF
deb http://ftp.belnet.be/ubuntu.com/ubuntu trusty main restricted universe multiverse
deb http://ftp.belnet.be/ubuntu.com/ubuntu trusty-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu trusty-security main restricted universe multiverse
EOF
apt-get -q update
export DEBIAN_FRONTEND=noninteractive
apt-get install -y -q \
debconf-utils \
\
function install_varia(){
apt-get install -q -y \
git \
tree \
lynx lynx-cur \
htop \
\
}
function enable_url_rewriting() {
a2enmod rewrite
cat << HERE >> /etc/apache2/sites-available/phalcon-rewrite.conf
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
# we need this block, it is not available in 000-default.conf
<Directory "/var/www/html">
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
HERE
a2ensite phalcon-rewrite
a2dissite 000-default
service apache2 restart
}
function install_phalcontools(){
[[ -d phalcon-devtools ]] && rm -rf phalcon-devtools /usr/bin/phalcon
git clone https://github.com/phalcon/phalcon-devtools.git
pushd phalcon-devtools
ln -s $PWD/phalcon.php /usr/bin/phalcon
chmod ugo+x /usr/bin/phalcon
popd
}
function install_phalcon(){
curl -s https://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh | bash
apt-get install -q -y \
php5 \
php5-phalcon \
php5-pgsql \
\
install_phalcontools
enable_url_rewriting
# test
php -i | grep phalcon
}
function install_apache(){
apt-get install -q -y \
apache2 \
\
}
function install_psql(){
# from https://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS23UbuntuPGSQL96Apt -> this one is worth remembering!
# see also http://php.net/manual/en/book.pgsql.php
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
# Setup postgres repository. Needed for recent postgres/postgis
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
apt-get update
apt-get install -y \
postgresql-9.6 \
postgresql-server-dev-9.6 \
postgresql-9.6-postgis-2.3 \
postgresql-contrib-9.6 \
postgresql-client \
postgis \
\
# make psql reachable
pushd /etc/postgresql/9.6/main/
cat << HERE >> pg_hba.conf
host all all all password
HERE
cat << HERE >> postgresql.conf
listen_addresses = '*'
HERE
popd
service postgresql restart
}
function install_pgadmin4(){
# http://askubuntu.com/questions/831262/how-to-install-pgadmin-4-in-desktop-mode-on-ubuntu-16-04
# (https://www.pgadmin.org/docs4/1.x/server_deployment.html is for mod_uwsgi)
# aaaa... Python keeps popping up :-)
apt-get install -q -y \
python-virtualenv python-pip libpq-dev python-dev \
\
# TODO don't run as root
pushd $PGADMINDIR
virtualenv pgadmin4
cd pgadmin4
source bin/activate
FILE=pgadmin4-1.3-py2.py3-none-any.whl
wget https://ftp.postgresql.org/pub/pgadmin3/pgadmin4/v1.3/pip/$FILE
pip install $FILE
CONFDIR=lib/python2.7/site-packages/pgadmin4
CONF_LOCAL=$CONFDIR/config_local.py
cp $CONFDIR/config.py $CONF_LOCAL
cat << HERE > $CONF_LOCAL
# modifications for prototype
SERVER_MODE = False # prevent password stuff
DEFAULT_SERVER = '0.0.0.0'
HERE
# TODO - turn this into a service! at the next reload, this is forgotten.
LOGFILE=/vagrant/nohup.out.log
nohup python $CONFDIR/pgAdmin4.py &> $LOGFILE &
popd
}
function install(){
DIR=$1
FILE=$2
pushd $DIR
./configure
make clean
make
make install
popd
rm -rf $FILE $DIR
}
function install_proj4(){
# http://proj4.org/
FILE=proj-4.9.3
PACK=$FILE.tar.gz
wget http://download.osgeo.org/proj/$PACK
tar -xzf $PACK
install $FILE $PACK
}
function install_php_geos(){
apt-get install -q -y \
php5-dev \
\
# git.osgeo.org/gogs/geos/php-geos
git clone https://git.osgeo.org/gogs/geos/php-geos.git
pushd php-geos
./autogen.sh
./configure
make # generates modules/geos.so
make install
popd
# rm -rf php-geos
}
function install_GEOS(){
#echo "skipping GEOS" && return
# https://trac.osgeo.org/geos/
FILE=geos-3.6.1
PACK=$FILE.tar.bz2
wget http://download.osgeo.org/geos/$PACK
tar -xjf $PACK
install $FILE $PACK
install_php_geos
}
function install_php_gdal(){
# https://www.drupal.org/node/2133103
apt-get install -q -y \
libgdal1-dev \
php5-dev \
php5-json \
g++ \
make \
\
pushd /tmp
REPO=https://github.com/geonef
P=php5-gdal
git clone $REPO/$P.git && cd $P
phpize
./configure
make
make install
cat << HERE > /etc/php5/mods-available/gdal.ini
; configuration for the PHP GDAL extension
extension=gdal.so
HERE
php5enmod gdal
# service apache2 restart # postpone to end of script
popd
rm -rf $P
php -i | grep gdal
}
function install_gdal(){
echo "skipping GDAL for now (because time expensive to build)" && return
# http://trac.osgeo.org/gdal/wiki/DownloadSource
FILE=gdal-2.1.3
PACK=$FILE.tar.gz
wget http://download.osgeo.org/gdal/2.1.3/$PACK
tar -xzf $PACK
install $FILE $PACK
install_php_gdal
}
function install_postgis(){
# from http://www.binpress.com/tutorial/introduction-to-postgis-part-1/24
apt-get install -y -q \
libproj-dev \
libgeos-3.4.2 \
libjson0 libjson0-dev \
gcc g++ \
libxml2 libxml2-dev \
libgdal-dev \
\
time install_proj4
time install_GEOS
time install_gdal
FILE=postgis-2.2.5
PACK=$FILE.tar.gz
wget http://download.osgeo.org/postgis/source/$PACK
tar -xzf $PACK
pushd $FILE
./configure --with-raster
make clean
time make
make install
popd
ldconfig
# make all this globally available in PATH
echo "PATH=${PATH}:/usr/lib/postgresql/9.3/bin/" > /etc/environment
}
install_varia
time install_psql
time install_phalcon
time install_apache
time install_postgis
time install_pgadmin4
service apache2 restart
$BASE/configure.sh
echo "machine installed"
@axd1967
Copy link
Author

axd1967 commented Mar 24, 2017

related issue: geonef/php5-gdal#13

original error (now corrected)

==> default: + make
==> default: /bin/bash /tmp/php5-gdal/libtool --mode=compile g++  -I. -I/tmp/php5-gdal -DPHP_ATOM_INC -I/tmp/php5-gdal/include -I/tmp/php5-gdal/main -I/tmp/php5-gdal -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -I/usr/include/gdal  -DHAVE_CONFIG_H  -g -O2   -c /tmp/php5-gdal/php_gdal.cc -o php_gdal.lo
==> default: libtool: compile:  g++ -I. -I/tmp/php5-gdal -DPHP_ATOM_INC -I/tmp/php5-gdal/include -I/tmp/php5-gdal/main -I/tmp/php5-gdal -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -I/usr/include/gdal -DHAVE_CONFIG_H -g -O2 -c /tmp/php5-gdal/php_gdal.cc  -fPIC -DPIC -o .libs/php_gdal.o
==> default: /tmp/php5-gdal/php_gdal.cc: In function 'void zm_info_gdal(zend_module_entry*)':
==> default: /tmp/php5-gdal/php_gdal.cc:310:50: warning: 'static OGRSFDriverRegistrar* OGRSFDriverRegistrar::GetRegistrar()' is deprecated (declared at /usr/include/gdal/ogrsf_frmts.h:320) [-Wdeprecated-declarations]
==> default:    registrar = OGRSFDriverRegistrar::GetRegistrar();
==> default:                                                   ^
==> default: /tmp/php5-gdal/php_gdal.cc:311:45: warning: 'int OGRSFDriverRegistrar::GetDriverCount()' is deprecated (declared at /usr/include/gdal/ogrsf_frmts.h:324) [-Wdeprecated-declarations]
==> default:    for (i = 0; i < registrar->GetDriverCount(); ++i) {
==> default:                                              ^
==> default: /tmp/php5-gdal/php_gdal.cc:312:39: warning: 'GDALDriver* OGRSFDriverRegistrar::GetDriver(int)' is deprecated (declared at /usr/include/gdal/ogrsf_frmts.h:325) [-Wdeprecated-declarations]
==> default:      ogrDriver = registrar->GetDriver(i);
==> default:                                        ^
==> default: /tmp/php5-gdal/php_gdal.cc:312:39: error: invalid conversion from 'GDALDriver*' to 'OGRSFDriver*' [-fpermissive]
==> default: /tmp/php5-gdal/php_gdal.cc:313:31: warning: 'virtual const char* OGRSFDriver::GetName()' is deprecated (declared at /usr/include/gdal/ogrsf_frmts.h:275) [-Wdeprecated-declarations]
==> default:      name = ogrDriver->GetName();
==> default:                                ^
==> default: make:
==> default: *** [php_gdal.lo] Error 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment