-
-
Save nitrag/932ecd7d109f9d1e3ed378353e0d5c2f to your computer and use it in GitHub Desktop.
container_commands: | |
001installs: | |
command: "sudo yum-config-manager --enable epel" | |
setup_gdal: | |
command: cd /home/ec2-user/gdal-1.11.2/swig/python && /opt/python/run/venv/bin/python setup.py install |
option_settings: | |
aws:elasticbeanstalk:container:python: | |
WSGIPath: api/wsgi.py | |
aws:autoscaling:launchconfiguration: | |
EC2KeyName: ryan-mac | |
MonitoringInterval: "1 minute" | |
ImageId: "<< YOUR CUSTOM AMI ID HERE >>" | |
Resources: | |
AWSEBAutoScalingGroup: | |
Type: "AWS::AutoScaling::AutoScalingGroup" | |
Properties: | |
HealthCheckType: "ELB" | |
HealthCheckGracePeriod: "600" |
#!/bin/bash | |
# How to setup GeoDjango on AWS EB | |
# Created by Ryan G on 12-08-2016 | |
# | |
# Updated 10-05-2017 | |
# Latest "stock" beanstalk AMI for python2.7 == (aws-elasticbeanstalk-amzn-2017.03.1.x86_64-python27-hvm-201709251940 - ami-eb00f791) | |
# | |
# Background info / AWS instructions here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.customenv.html | |
# | |
# So you want GeoDjango to run on AWS Beanstalk Python 2.7? Two main steps: | |
# 1) Launch a base AMI, SSH into the EC2 instance and install these packages, save as custom image. You'll get a custom AMI ID. | |
# 2) Create an .ebextensions for the container_command (more info below, see file below) which will take the compiled GDAL python bindings and install to the virtual env | |
# 3) Create an .ebextensions called `django.config` to tell it to launch with your custom AMI. | |
# | |
# | |
sudo yum-config-manager --enable epel | |
sudo yum repolist | |
sudo yum -y install gcc gcc-c++ make cmake libtool libcurl-devel libxml2-devel rubygems swig fcgi-devel\ | |
libtiff-devel freetype-devel curl-devel libpng-devel giflib-devel libjpeg-devel\ | |
cairo-devel freetype-devel readline-devel openssl-devel | |
sudo yum -y group install "Development Tools" | |
wget http://download.osgeo.org/geos/geos-3.5.1.tar.bz2 | |
tar xjf geos-3.5.1.tar.bz2 | |
cd geos-3.5.1 | |
./configure | |
make | |
sudo make install | |
cd .. | |
wget http://download.osgeo.org/proj/proj-4.9.1.tar.gz | |
wget http://download.osgeo.org/proj/proj-datumgrid-1.5.tar.gz | |
tar xzf proj-4.9.1.tar.gz | |
cd proj-4.9.1/nad | |
tar xzf ../../proj-datumgrid-1.5.tar.gz | |
cd .. | |
./configure | |
make | |
sudo make install | |
cd .. | |
wget http://download.osgeo.org/gdal/1.11.2/gdal-1.11.2.tar.gz | |
tar xzf gdal-1.11.2.tar.gz | |
cd gdal-1.11.2 | |
./configure --with-python | |
make | |
sudo make install | |
cd swig & make & cd python | |
cd .. | |
# | |
# YOU MUST create an .ebextensions | |
# It will install the python binaries via the "virtual environment" python instance (/opt/python/run/venv/bin/python) | |
# if you don't do this, you'll get an error "osgeo" module not found | |
# | |
# 00-gdal.config | |
#container_commands: | |
# setup_gdal: | |
# command: cd /home/ec2-user/gdal-1.11.2/swig/python && /opt/python/run/venv/bin/python setup.py install | |
echo /usr/local/lib | sudo tee --append /etc/ld.so.conf | |
sudo ldconfig | |
sudo yum -y install postgresql95-devel | |
wget http://download.osgeo.org/postgis/source/postgis-2.3.0.tar.gz | |
tar zxvf postgis-2.3.0.tar.gz | |
cd postgis-2.3.0 | |
./configure --with-geosconfig=/usr/local/bin/geos-config --with-gdalconfig=/usr/local/bin/gdal-config | |
make | |
sudo make install | |
cd .. | |
sudo ldconfig | |
Updated and working!
Appear to be hitting problems on the latest ELB instances. This worked for me a few months ago.
Base AMI ELB has given is aws-elasticbeanstalk-amzn-2018.03.0.x86_64-python36-hvm-201805091805
during sudo make install of Gdal i get this:
building 'osgeo._gdal' extension
gcc -pthread -fno-strict-aliasing -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -DNDEBUG -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/usr/include/python2.7 -I. -I/home/ec2-user/gdal-2.0.0/include -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-2.7/extensions/gdal_wrap.o
gcc: error trying to exec 'cc1plus': execvp: No such file or directory
error: command 'gcc' failed with exit status 1
P.S. I tried the listed version of GDAL, plus also tried 2.0.0 just in case there was a difference (hence the different version logged above)
Okay, on the above the issue was differing versions of gcc vs g++ (gcc was pointing to 7, g++ to 4.8.5)
Symlinking the right version of GCC fixed it: ln -s /usr/bin/gcc48 /usr/bin/gcc
Okay, on the above the issue was differing versions of gcc vs g++ (gcc was pointing to 7, g++ to 4.8.5)
Symlinking the right version of GCC fixed it: ln -s /usr/bin/gcc48 /usr/bin/gcc
Thanks, I was having the same trouble. /usr/bin/gcc existed, I replaced it with the link. Should I return it to version 7 after the installation is complete?
I'm not sure this is valid anymore. I remember posting this and then having issues. Use at your own risk or let me know if it works for you.