离线地图使用私有OSM Server做为Tile服务器, 前端使用Openlayer渲染地图数据. 共实践了两种安装环境(准确来讲是三种, 可是放弃了在Redhat 6.5的部署...).html
#Ubuntu 16.04 安装介绍前端
名称 | 说明 |
---|---|
OS | ubuntu 16.04 x64 |
参考 https://switch2osm.org/serving-tiles/manually-building-a-tile-server-14-04/node
除一下两点外, 均可以按照参考文档安装.python
能够经过apt安装, 不用从源码编译.nginx
apt install libmapnik-dev libmapnik3.0 mapnik-utils mapnik-vector-tile python-mapnik python3-mapnik sudo apt install libmapnik-dev libmapnik3.0 mapnik-utils mapnik-vector-tile python-mapnik python3-mapnik
vim /usr/local/etc/renderd.conf
plugins_dir=/usr/lib/mapnik/3.0/input
值修改成mapnik-config --input-plugins
的结果.git
名称 | 说明 |
---|---|
OS | CentOS 7.2 x64 |
HTTP server | httpd |
安装过程主要流程参考Manually building a tile server (14.04),这个网站是针对Ubuntu 14.04写的,可是须要安装的软件基本相同,能够参考这个教程安装配置OSM Server。这里如无特殊说明的话,均在root用户下操做。github
epel-release
& 更新系统软件yum install epel-release yum update
参考这里 or:web
rpm -ivh http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm yum install postgresql95 postgresql95-server postgresql95-libs postgresql95-contrib postgresql95-devel
/usr/pgsql-9.5/bin/postgresql95-setup initdb service postgresql-9.5 start
chkconfig postgresql-9.5 on
这里添加的用户名为usergis,能够按需替换,后续的usergis都要替换。sql
adduser -m usergis passwd usergis
sudo -u postgres -i createuser usergis createdb -E UTF8 -O usergis gis exit
根据安装的postgresql版本选择postgis软件,这里postgresql使用的是9.5的版本,因此采用postgis2_95,95
是postgresql的版本号。数据库
yum install postgis2_95 postgis2_95-client sudo -u postgres -i \c gis CREATE EXTENSION postgis; ALTER TABLE geometry_columns OWNER TO usergis; ALTER TABLE spatial_ref_sys OWNER TO usergis; \q exit
安装过程尽可能采用GitHub上osm2pgsql的安装介绍,这里说明一下依赖的安装。
进入osm2pgsql目录,建立build
目录并cd build/
yum install cmake yum install expat yum install expat-devel yum install bzip yum install bzip2 yum install bzip2-devel yum install zlib-devel yum install geos-devel yum install proj-devel yum install liblua-devel yum install lua-devel yum install boost-devel
依赖安装完成后就能够开始编译了
cmake .. make make install
同osm2pgsql同样,咱们也尽可能follow官方安装流程,点这里。 这里说一下依赖的安装。
这里咱们使用branch为2.2.x,你也可使用最新版本。切换方法:
git branch 2.2 origin/2.2.x git checkout 2.2 -f
若是使用3.x的版本,mapnik库文件的安装位置可能发生改变,在后边配置renderd.conf的时候须要根据mapnik-config --input-plugins
来配置。
安装依赖
yum install freetype-config yum install libicu-devel yum install harfbuzz-devel yum install freetype-devel yum install libjpeg-devel libpng-devel libtiff-devel libxml2-devel yum install python-devel
这里mapnik的lib安装在/usr/local/lib/libmapnik.so.2.2
,须要将此目录包含在ld的search path中,建立/编辑/etc/ld.so.conf
,加入一行/usr/local/lib
。
ldconfig
而后能够愉快的开始编译安装了。安装完成后参考官方文档测试mapnik能够正常被python搜索到便可。
同上参考官方安装手册,点这里。这里介绍依赖的安装。
安装依赖:
yum install httpd-devel
开始编译安装吧。
安装过程参考*Manually building a tile server (14.04)*的说明便可,这里咱们的Web Server为httpd,so 启动服务的时候须要相应修改。须要注意的是在上文这一节结尾的make.py部分,有部分依赖须要安装。
yum search carto yum install libcairo yum install cairo yum install nodejs yum install npm
高版本的nodejs已经内置了npm,不须要单独安装。这里咱们使用的是默认repo中0.10.x的版本。
npm i -g carto npm i -g millstone
以后就能够执行./make.py
了。
基本参考*Manually building a tile server (14.04)*的配置便可,其中module的配置文件的存放位置为/etc/httpd/conf.modules.d/
,能够建立mod_tile的配置文件00-mod_tile.conf
放到此目录,内容以下:
LoadModule tile_module /usr/lib64/httpd/modules/mod_tile.so
可使用locate
指令肯定mod_tile.so
文件的位置,固然执行locate
以前须要执行updatedb
来更新文件索引。
建立文件vim /etc/httpd/conf.d/tile_server.conf
,内容以下便可:
<VirtualHost *:9000> # However, you must set it for any further virtual host explicitly. #ServerName www.example.com ServerAdmin webmaster@localhost LoadTileConfigFile /usr/local/etc/renderd.conf ModTileRenderdSocketName /var/run/renderd/renderd.sock # Timeout before giving up for a tile to be rendered ModTileRequestTimeout 0 # Timeout before giving up for a tile to be rendered that is otherwise missing ModTileMissingRequestTimeout 30 DocumentRoot /var/www/test_openlayer </VirtualHost>
重启http服务后,访问宿主http://host:9000/osm_tiles/0/0/0.png
能看到图片即代表成功。
File: /usr/local/etc/renderd.conf
[renderd] socketname=/var/run/renderd/renderd.sock num_threads=4 tile_dir=/var/lib/mod_tile stats_file=/var/run/renderd/renderd.stats [mapnik] plugins_dir=/usr/local/lib/mapnik/input font_dir=/usr/local/lib/mapnik/fonts font_dir_recurse=1 [default] URI=/osm_tiles/ TILEDIR=/var/lib/mod_tile XML=/usr/local/share/maps/style/OSMBright/OSMBright.xml HOST=localhost TILESIZE=256 ;HTCPHOST=proxy.openstreetmap.org ;** config options used by mod_tile, but not renderd ** ;MINZOOM=0 MAXZOOM=18 ;TYPE=png image/png ;DESCRIPTION=This is a description of the tile layer used in the tile json request ;ATTRIBUTION=©<a href=\"http://www.openstreetmap.org/\">OpenStreetMap</a> and <a href=\"http://wiki.openstreetmap.org/wiki/Contributors\">contributors</a>, <a href=\"http://opendatacommons.org/licenses/odbl/\">ODbL</a> ;SERVER_ALIAS=http://localhost/ ;CORS=http://www.openstreetmap.org ;ASPECTX=1 ;ASPECTY=1 ;SCALE=1.0