设置的Django与GeoDjango支持在AWS魔豆或EC2实例 [英] Setting up Django with GeoDjango Support in AWS Beanstalk or EC2 Instance
问题描述
所以,我已经在一个点上通过了这个魔豆去,使用Amazon实例(2013.09)AMI-35792c5c。当时,当放置在.ebextensions你回购/
So I have at one point had this going via Beanstalk, using Amazon Instance (2013.09) ami-35792c5c . At the time this ebextension scripts worked great when placed in the root of your repo in .ebextensions/
00_repo.config
00_repo.config
packages:
rpm:
pgdg-redhat93-9.3-1: 'http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-redhat93-9.3-1.noarch.rpm'
remi: 'http://rpms.famillecollet.com/enterprise/remi-release-6.rpm'
files:
"/etc/yum.repos.d/pgdg-93-redhat.repo":
mode: "000644"
owner: root
group: root
content: |
[pgdg93]
name=PostgreSQL 9.3 $releasever - $basearch
baseurl=http://yum.postgresql.org/9.3/redhat/rhel-6-$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-93
[pgdg93-source]
name=PostgreSQL 9.3 $releasever - $basearch - Source
failovermethod=priority
baseurl=http://yum.postgresql.org/srpms/9.3/redhat/rhel-6-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-93
commands:
epel_repo:
command: yum-config-manager -y --enable epel
remi_repo:
command: yum-config-manager -y --enable remi
01_app.config
01_app.config
packages:
yum:
libtiff-devel: ''
libjpeg-devel: ''
libzip-devel: ''
freetype-devel: ''
postgresql-devel: ''
gdal: ''
gdal-python: ''
geos: ''
proj: ''
libmemcached: ''
libmemcached-devel: ''
cyrus-sasl-devel: ''
zlib-devel: ''
container_commands:
01_collectstatic:
command: 'PYTHONPATH=.:..:../lib cd site/kpmkhv && ./manage.py collectstatic -c --noinput && cd ../..'
leader_only: true
02_syncdb:
command: 'PYTHONPATH=.:..:../lib cd site/kpmkhv && ./manage.py syncdb --noinput && cd ../..'
leader_only: true
03_migrate:
command: 'PYTHONPATH=.:..:../lib cd site/kpmkhv && ./manage.py migrate --noinput && cd ../..'
leader_only: true
option_settings:
- namespace: aws:elasticbeanstalk:container:python
option_name: WSGIPath
value: site/kpmkhv/wsgi.py
- namespace: aws:elasticbeanstalk:container:python:staticfiles
option_name: /static/
value: site/kpmkhv/static/
- option_name: DJANGO_SETTINGS_MODULE
value: settings_prod
所以现在当我用同样的实例并启动我的环境,我得到这个错误有关的依赖。
So now when I use the same instance and launch my environment, I get this error regarding a dependency.
Error: Package: gdal-libs-1.9.2-5.rhel6.x86_64 (pgdg93)
Requires: libpoppler.so.5()(64bit)
You could try using --skip-broken to work around the problem
You could try running: rpm -Va --nofiles --nodigest
貌似相同的回购现在是返回poppler的较新版本,它的12.x,现在它22.x暂时和GDAL需要旧版本。
Looks like the same repo is now returning a newer version of poppler, it was 12.x and now its 22.x and gdal needs the old version.
我还测试了这一点,在一个EC2实例,并得到了同样的错误。但后来我遇到了这个文件,从亚马逊锁定的AMI到原来的资源库版本。
I also tested this out on an EC2 Instance and got the same error. But then I ran into this document from amazon on locking an AMI to its original repository version.
所以增加这通过EC2控制台用户选项,当您启动修复该问题上的EC2:
So adding this to User Options via the EC2 Console when you launch fixes the problem on EC2:
#cloud-config
repo_releasever: 2014.03
什么是总有这个选项,当你的魔豆推出的EC2实例代表你的最佳方法是什么?我读到云init和可能通过ebextensions部署脚本将是最好的选择?
What is the best way to always have this option when your Beanstalk launches the EC2 Instance on your behalf? I read about cloud-init and perhaps a script deployed via ebextensions would be the best bet?
对此有何见解是AP preciated,谢谢。
Any insight on this is appreciated, thanks.
推荐答案
所以,我现在有2013.09堆栈阿美阿美-35792c5c工作ebextensions工作流程。对于2014.09堆栈看到其他的解决方案。在PostGIS通过安装所需的GDAL组件,00_repo.config需要像这样的解决方案如下工作:
So I now have a working ebextensions workflow on 2013.09 stack ami ami-35792c5c. For the 2014.09 stack see the other solution. The solution below works with postgis by installing the needed gdal component, 00_repo.config needs to look like this:
files:
"/etc/yum.repos.d/pgdg-93-redhat.repo":
mode: "000644"
owner: root
group: root
content: |
[pgdg93]
name=PostgreSQL 9.3 $releasever - $basearch
baseurl=http://yum.postgresql.org/9.3/redhat/rhel-6-$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-93
[pgdg93-source]
name=PostgreSQL 9.3 $releasever - $basearch - Source
failovermethod=priority
baseurl=http://yum.postgresql.org/srpms/9.3/redhat/rhel-6-$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG-93
commands:
epel_repo:
command: yum-config-manager -y --enable epel
remi_repo:
command: yum-config-manager -y --enable remi
packages:
rpm:
pgdg-redhat93-9.3-1: 'http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-redhat93-9.3-1.noarch.rpm'
remi: 'http://rpms.famillecollet.com/enterprise/remi-release-6.rpm'
qt4-devel: 'http://mirror.centos.org/centos/6/os/x86_64/Packages/qt-4.6.2-28.el6_5.x86_64.rpm'
第2扩展停留在机智。这适用于亚马逊实例(2013.09)AMI-35792c5c,我没有尝试过的新容器还没有吧。
The 2nd extension stays in tact. This works on Amazon Instance (2013.09) ami-35792c5c, I haven't tried the newer containers yet with it.
选择1
如果你想在回购较少依赖/从ebextensions文件的RPM,您可以上传所有必需的RPM,以S3和更新ebextensions'包'指向你的S3的转速。设置你的S3存储使用CORS头公众可以访问。
If you want less dependencies on repos / rpms from the ebextensions file, you could upload all required rpms to S3 and update the ebextensions 'packages' to point to your s3 rpms. Setup your S3 bucket for public get access using CORS headers.
方案2
创建自定义AMI,你从源代码编译的所有依赖关系。这样一来就没有转冲突,你没有脾气由您自定义的AMI提供的默认回购。看到这个答案: <一href="http://stackoverflow.com/questions/17326294/configuring-amazon-elastic-beanstalk-with-postgis">Configuring亚马逊弹性魔豆在PostGIS
Create a custom AMI where you compile all dependencies from source. This way there will be no rpm conflicts and you don't have to temper with the default repos supplied by the AMI you are customizing. See this answer: Configuring Amazon Elastic Beanstalk with PostGIS
另外,请查阅我所取得的工具:
Also check out the tool I made:
https://github.com/radlws/django-awseb-tasks
这篇关于设置的Django与GeoDjango支持在AWS魔豆或EC2实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!