1.添加源
sudo apt-get install python-software-properties
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:ubuntugis && sudo apt-get update
2.安裝django和django-rest-framework
pip install Django==1.11.3
pip install djangorestframework
pip install markdown
pip install django-filter
3.安裝binutils、libpq-dev 韵卤、python-dev
sudo apt-get install binutils libpq-dev python-dev #后面的安裝包可能依賴它
4.安裝libproj-dev白翻、libgeos-dev吃粒、gdal-bin忧饭、python-gdal
sudo apt-get install libproj-dev libgeos-dev gdal-bin python-gdal #安裝gdal县忌、proj4僧凰、geos等
5.安裝postgresql-9.6
sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main"
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-9.6
sudo apt-get install postgresql-9.6-postgis
#提示安裝libgdal1探颈,因此安裝libgdal1,然后再安裝postgresql-9.6
sudo apt-get install libgdal1
sudo apt-get install postgresql-9.6-postgis
sudo apt-get install postgresql-server-dev-9.6
sudo pip install pip install psycopg2
6.postgres的數(shù)據(jù)庫設(shè)置
6.1 PostgreSQL數(shù)據(jù)庫創(chuàng)建一個postgres用戶作為數(shù)據(jù)庫的管理員,密碼隨機(jī)训措,所以需要修改密碼伪节,方式如下:
步驟一:登錄PostgreSQL
sudo -u postgres psql
步驟二:修改登錄PostgreSQL密碼
ALTER USER postgres WITH PASSWORD ‘postgres’;
注:密碼postgres要用引號引起來
命令最后有分號
步驟三:退出PostgreSQL客戶端
\q
6.2 修改linux系統(tǒng)postgres用戶的密碼
PostgreSQL會創(chuàng)建一個默認(rèn)的linux用戶postgres,修改該用戶密碼的方法如下:
步驟一:刪除用戶postgres的密碼
sudo passwd -d postgres
步驟二:設(shè)置用戶postgres的密碼
sudo -u postgres passwd
系統(tǒng)提示輸入新的密碼
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
6.3 創(chuàng)建空間數(shù)據(jù)庫
sudo su - postgre
createdb geodjango
psql geodjango
CREATE EXTENSION postgis;
\q
exit