23.4 OS Specific Installations

23.4.1 Ubuntu

These are specific notes for installing PEcAn on Ubuntu (14.04) and will be referenced from the main installing PEcAn page. You will at least need to install the build environment and Postgres sections. If you want to access the database/PEcAn using a web browser you will need to install Apache. To access the database using the BETY interface, you will need to have Ruby installed.

This document also contains information on how to install the Rstudio server edition as well as any other packages that can be helpful.

23.4.1.1 Install build environment

sudo -s

# point to latest R
echo "deb http://cran.rstudio.com/bin/linux/ubuntu `lsb_release -s -c`/" > /etc/apt/sources.list.d/R.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9

# update package list
apt-get -y update

# install packages needed for PEcAn
apt-get -y install build-essential gfortran git r-base-core r-base-dev jags liblapack-dev libnetcdf-dev netcdf-bin bc libcurl4-gnutls-dev curl udunits-bin libudunits2-dev libgmp-dev python-dev libgdal1-dev libproj-dev expect

# install packages needed for ED2
apt-get -y install openmpi-bin libopenmpi-dev

# install requirements for DALEC
apt-get -y install libgsl0-dev

# install packages for webserver
apt-get -y install apache2 libapache2-mod-php5 php5

# install packages to compile docs
apt-get -y install texinfo texlive-latex-base texlive-latex-extra texlive-fonts-recommended

# install devtools
echo 'install.packages("devtools")' | R --vanilla

# done as root
exit

23.4.1.2 Install Postgres

Documentation: http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS21UbuntuPGSQL93Apt

sudo -s

# point to latest PostgreSQL
echo "deb http://apt.postgresql.org/pub/repos/apt `lsb_release -s -c`-pgdg main" > /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

# update package list
apt-get -y update

# install packages for postgresql (using a newer version than default)
apt-get -y install libdbd-pgsql postgresql postgresql-client libpq-dev postgresql-9.4-postgis-2.1 postgresql-9.4-postgis-2.1-scripts

# install following if you want to run pecan through the web
apt-get -y install php5-pgsql

# enable bety user to login with trust by adding the following lines after
# the ability of postgres user to login in /etc/postgresql/9.4/main/pg_hba.conf
local   all             bety                                    trust
host    all             bety            127.0.0.1/32            trust
host    all             bety            ::1/128                 trust

# Once done restart postgresql
/etc/init.d/postgresql restart

exit

To install the BETYdb database ..

23.4.1.3 Apache Configuration PEcAn

# become root
sudo -s

# get index page
rm /var/www/html/index.html
ln -s ${HOME}/pecan/documentation/index_vm.html /var/www/html/index.html

# setup a redirect
cat > /etc/apache2/conf-available/pecan.conf << EOF
Alias /pecan ${HOME}/pecan/web
<Directory ${HOME}/pecan/web>
  DirectoryIndex index.php
  Options +ExecCGI
  Require all granted
</Directory>
EOF
a2enconf pecan
/etc/init.d/apache2 restart

# done as root
exit

23.4.1.4 Apache Configuration BETY

sudo -s

# install all ruby related packages
apt-get -y install ruby2.0 ruby2.0-dev libapache2-mod-passenger 

# link static content
ln -s ${HOME}/bety/public /var/www/html/bety

# setup a redirect
cat > /etc/apache2/conf-available/bety.conf << EOF
RailsEnv production
RailsBaseURI /bety
PassengerRuby /usr/bin/ruby2.0
<Directory /var/www/html/bety>
  Options +FollowSymLinks
  Require all granted
</Directory>
EOF
a2enconf bety
/etc/init.d/apache2 restart

23.4.1.5 Rstudio-server

NOTE This will allow anybody to login to the machine through the rstudio interface and run any arbitrary code. The login used however is the same as the system login/password.

wget http://download2.rstudio.org/rstudio-server-0.98.1103-amd64.deb
# bceome root
sudo -s

# install required packages
apt-get -y install libapparmor1 apparmor-utils libssl0.9.8

# install rstudio
dpkg -i rstudio-server-*
rm rstudio-server-*
echo "www-address=127.0.0.1" >> /etc/rstudio/rserver.conf
echo "r-libs-user=~/R/library" >> /etc/rstudio/rsession.conf
rstudio-server restart

# setup rstudio forwarding in apache
a2enmod proxy_http
cat > /etc/apache2/conf-available/rstudio.conf << EOF
ProxyPass        /rstudio/ http://localhost:8787/
ProxyPassReverse /rstudio/ http://localhost:8787/
RedirectMatch permanent ^/rstudio$ /rstudio/
EOF
a2enconf rstudio
/etc/init.d/apache2 restart

# all done, exit root
exit

23.4.1.6 Additional packages

HDF5 Tools, netcdf, GDB and emacs

sudo apt-get -y install hdf5-tools cdo nco netcdf-bin ncview gdb emacs ess nedit

23.4.2 CentOS/RedHat

These are specific notes for installing PEcAn on CentOS (7) and will be referenced from the main installing PEcAn page. You will at least need to install the build environment and Postgres sections. If you want to access the database/PEcAn using a web browser you will need to install Apache. To access the database using the BETY interface, you will need to have Ruby installed.

This document also contains information on how to install the Rstudio server edition as well as any other packages that can be helpful.

23.4.2.1 Install build environment

sudo -s

# install packages needed for PEcAn
yum -y groupinstall 'Development Tools' 
yum -y install git netcdf-fortran-openmpi-devel R bc curl libxml2-devel openssl-devel ed  udunits2 udunits2-devel netcdf netcdf-devel gmp-devel python-devel gdal-devel proj-devel proj-epsg expect

# jags
yum -y install http://download.opensuse.org/repositories/home:/cornell_vrdc/CentOS_7/x86_64/jags3-3.4.0-54.1.x86_64.rpm
yum -y install http://download.opensuse.org/repositories/home:/cornell_vrdc/CentOS_7/x86_64/jags3-devel-3.4.0-54.1.x86_64.rpm

# fix include folder for udunits2
ln -s /usr/include/udunits2/* /usr/include/

# install packages needed for ED2
yum -y install environment-modules openmpi-bin libopenmpi-dev

# install requirements for DALEC
yum -y install gsl-devel

# install packages for webserver
yum -y install httpd php
systemctl enable httpd
systemctl start httpd
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload

# install packages to compile docs
#apt-get -y install texinfo texlive-latex-base texlive-latex-extra texlive-fonts-recommended

# install devtools
echo 'install.packages("devtools")' | R --vanilla

# done as root
exit

echo "module load mpi" >> ~/.bashrc
module load mpi

23.4.2.2 Install and configure PostgreSQL, udunits2, NetCDF

sudo -s

# point to latest PostgreSQL
yum install -y epel-release 
yum -y install http://yum.postgresql.org/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-1.noarch.rpm

# install packages for postgresql (using a newer version than default)
yum -y install postgresql94-server postgresql94-contrib postgis2_94 postgresql94-devel udunits2 netcdf

# install following if you want to run pecan through the web
yum -y install php-pgsql

# enable bety user to login with trust by adding the following lines after
# the ability of postgres user to login in /var/lib/pgsql/9.4/data/pg_hba.conf
local   all             bety                                    trust
host    all             bety            127.0.0.1/32            trust
host    all             bety            ::1/128                 trust

# Create database
/usr/pgsql-9.4/bin/postgresql94-setup initdb

# Enable postgres
systemctl enable postgresql-9.4
systemctl start postgresql-9.4

exit

23.4.2.3 Apache Configuration PEcAn

Install and Start Apache

yum -y install httpd
systemctl enable httpd
systemctl start httpd
# become root
sudo -s

# get index page
rm /var/www/html/index.html
ln -s /home/carya/pecan/documentation/index_vm.html /var/www/html/index.html

# fix selinux context (does this need to be done after PEcAn is installed?)
chcon -R -t httpd_sys_content_t /home/carya/pecan /home/carya/output

# setup a redirect
cat > /etc/httpd/conf.d/pecan.conf << EOF
Alias /pecan /home/carya/pecan/web
<Directory /home/carya/pecan/web>
  DirectoryIndex index.php
  Options +ExecCGI
  Require all granted
</Directory>
EOF
a2enconf pecan
/etc/init.d/apache2 restart

# done as root
exit

23.4.2.4 Apache Configuration BETY

sudo -s

# install all ruby related packages
sudo curl --fail -sSLo /etc/yum.repos.d/passenger.repo https://oss-binaries.phusionpassenger.com/yum/definitions/el-passenger.repo
yum -y install ruby ruby-devel mod_passenger

# link static content
ln -s /home/carya/bety/public /var/www/html/bety

# fix GemFile
echo 'gem "test-unit"' >> bety/Gemlile

# fix selinux context (does this need to be done after bety is installed?)
chcon -R -t httpd_sys_content_t /home/carya/bety

# setup a redirect
cat > /etc/httpd/conf.d/bety.conf << EOF
RailsEnv production
RailsBaseURI /bety
PassengerRuby /usr/bin/ruby
<Directory /var/www/html/bety>
  Options +FollowSymLinks
  Require all granted
</Directory>
EOF
systemctl restart httpd

23.4.2.5 Rstudio-server

NEED FIXING

NOTE This will allow anybody to login to the machine through the rstudio interface and run any arbitrary code. The login used however is the same as the system login/password.

wget http://download2.rstudio.org/rstudio-server-0.98.1103-amd64.deb
# bceome root
sudo -s

# install required packages
apt-get -y install libapparmor1 apparmor-utils libssl0.9.8

# install rstudio
dpkg -i rstudio-server-*
rm rstudio-server-*
echo "www-address=127.0.0.1" >> /etc/rstudio/rserver.conf
echo "r-libs-user=~/R/library" >> /etc/rstudio/rsession.conf
rstudio-server restart

# setup rstudio forwarding in apache
a2enmod proxy_http
cat > /etc/apache2/conf-available/rstudio.conf << EOF
ProxyPass        /rstudio/ http://localhost:8787/
ProxyPassReverse /rstudio/ http://localhost:8787/
RedirectMatch permanent ^/rstudio$ /rstudio/
EOF
a2enconf rstudio
/etc/init.d/apache2 restart

# all done, exit root
exit

Alternative Rstudio instructions

23.4.2.5.1 Install and configure Rstudio-server

Install RStudio Server by following the official documentation for your platform. Then, proceed with the following:

  • add PATH=$PATH:/usr/sbin:/sbin to /etc/profile
   cat "PATH=$PATH:/usr/sbin:/sbin; export PATH" >> /etc/profile
   wget https://gist.github.com/dlebauer/6921889/raw/d1e0f945228e5519afa6223d6f49d6e0617262bd/rstudio.conf
   sudo mv rstudio.conf /httpd/conf.d/
  • restart the Apache server: sudo httpd restart
  • now you should be able to access http://<server>/rstudio

23.4.2.6 Install ruby-netcdf gem

cd $RUBY_APPLICATION_HOME
export $NETCDF_URL=http://www.gfd-dennou.org/arch/ruby/products/ruby-netcdf/release/ruby-netcdf-0.6.6.tar.gz
export $NETCDF_DIR=/usr/local/netcdf
gem install narray
export NARRAY_DIR="$(ls $GEM_HOME/gems | grep 'narray-')"
export NARRAY_PATH="$GEM_HOME/gems/$NARRAY_DIR"
cd $MY_RUBY_HOME/bin
wget $NETCDF_URL -O ruby-netcdf.tgz
tar zxf ruby-netcdf.tgz && cd ruby-netcdf-0.6.6/
ruby -rubygems extconf.rb --with-narray-include=$NARRAY_PATH --with-netcdf-dir=/usr/local/netcdf-4.3.0
sed -i 's|rb/$|rb|' Makefile
make
make install
cd ../ && sudo rm -rf ruby-netcdf*

cd $RUBY_APPLICATION
bundle install --without development

23.4.2.7 Additional packages

NEED FIXING

HDF5 Tools, netcdf, GDB and emacs

sudo apt-get -y install hdf5-tools cdo nco netcdf-bin ncview gdb emacs ess nedit

23.4.3 Mac OSX

These are specific notes for installing PEcAn on Mac OSX and referenced from the installing PEcAn page.

Build environment and Postgres sections are required to install and use PEcAn.

Optional software includes Apache, Rails, and Rstudio. Apache is required to run the BETYdb UI and the web-based version of PEcAn - both are optional. Rails is requred to use the BETYdb web interface. Rstudio is a commonly used IDE for R.

23.4.3.1 Install build environment

23.4.3.1.1 Option 1: Download and install

R: download from http://cran.r-project.org/bin/macosx/

gfortran: download from http://cran.r-project.org/bin/macosx/tools/

# install OpenMPI
curl -o openmpi-1.6.3.tar.gz http://www.open-mpi.org/software/ompi/v1.6/downloads/openmpi-1.6.3.tar.gz
tar zxf openmpi-1.6.3.tar.gz
cd openmpi-1.6.3
./configure --prefix=/usr/local
make all
sudo make install
cd ..

# install szip
curl -o szip-2.1-MacOSX-intel.tar.gz ftp://ftp.hdfgroup.org/lib-external/szip/2.1/bin/szip-2.1-MacOSX-intel.tar.gz
tar zxf szip-2.1-MacOSX-intel.tar.gz
sudo mv szip-2.1-MacOSX-intel /usr/local/szip

# install HDF5

curl -o hdf5-1.8.11.tar.gz http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-1.8.11.tar.gz
tar zxf hdf5-1.8.11.tar.gz
cd hdf5-1.8.11
sed -i -e 's/-O3/-O0/g' config/gnu-flags 
./configure --prefix=/usr/local/hdf5 --enable-fortran --enable-cxx --with-szlib=/usr/local/szip
make
# make check
sudo make install
# sudo make check-install
cd ..
23.4.3.1.2 Option 2: Homebrew
# R
brew install --cask r
# gfortran
brew install gcc
# OpenMPI
brew install open-mpi
# szip
brew install szip
# HDF5
brew install hdf5 
## homebrew should configure hdf5 with fortran and cxx, otherwise:
## brew install hdf5 --with-fortran --with-cxx

23.4.3.2 Install Postgres and PostGIS

23.4.3.2.1 Option 1:

For MacOS, the Postgres.app provides Postgres with PostGIS already installed (http://postgresapp.com/).

To run Postgres: * Open Postgres.app. * In the menu bar, click the elephant icon and select “Open psql”.

23.4.3.2.2 Option 2: install using homebrew:
# optional: remove existing postgres installations with:
# brew uninstall --force postgresql

# install Postgres, fixed at v12 (officially supported by BETYdb):
brew install postgres@12
brew pin postgres@12

# PostGIS
brew install postgis

# to run Postgres:
brew services start postgresql

23.4.3.3 Enable PostGIS

To enable PostGIS, you should start Postgres:

psql postgres

And then run the following commands:

##### Enable PostGIS (includes raster)
CREATE EXTENSION postgis;
##### Enable Topology
CREATE EXTENSION postgis_topology;
##### fuzzy matching needed for Tiger
CREATE EXTENSION fuzzystrmatch;
##### Enable US Tiger Geocoder
CREATE EXTENSION postgis_tiger_geocoder;

To check your postgis run the following command again in psql:

SELECT PostGIS_full_version();`

23.4.3.4 Additional installs

23.4.3.4.1 Install JAGS
23.4.3.4.2 Option 1: using homebrew
brew install jags
23.4.3.4.4 Install udunits
23.4.3.4.5 Option 1: Install using homebrew:
brew install udunits
23.4.3.4.6 Option 2: Install udunits-2 on MacOSX is done from source.
curl -o udunits-2.1.24.tar.gz ftp://ftp.unidata.ucar.edu/pub/udunits/udunits-2.1.24.tar.gz
tar zxf udunits-2.1.24.tar.gz
cd udunits-2.1.24
./configure
make
sudo make install

23.4.3.5 Apache Configuration (Optional)

Mac does not support pdo/postgresql by default. The easiest way to install is use: http://php-osx.liip.ch/

To enable pecan to run from your webserver.

cat > /etc/apache2/others/pecan.conf << EOF
Alias /pecan ${PWD}/pecan/web
<Directory ${PWD}/pecan/web>
  DirectoryIndex index.php
  Options +All
  Require all granted
</Directory>
EOF

23.4.3.6 Ruby (Optional)

Note: it is recommended that BETYdb be run using Docker because the application uses unsupported versions of Ruby and Rails.

The BETYdb application requires Ruby version 2.7.7, as specified in PecanProject/bety/.ruby-version.

brew install rbenv
rbenv init
rbenv install 2.7.7 

23.4.3.7 Rstudio (Optional)

For MacOS, you can download Rstudio Desktop.

Or using homebrew:

brew install --cask rstudio

23.4.4 Installing BETY

⚠️ Deprecated BETY Installation Page

This page documents legacy, non-Docker installation methods for BETYdb. These instructions are no longer recommended for new installations and are kept only for users who already depend on manual deployments.

Recommended approach (for new users): - Use the Docker-based BETY installation described in the PEcAn Docker section.

Authoritative BETY documentation: - https://pecan.gitbook.io/betydb-documentation

If you are installing BETY for the first time, do not follow the instructions below.