(Load) http://www.thegreatwall.com.cn/public/index.php? B _id = 2294.
Notes on building a mapserver/Ka-map experiment environment in Desktop Linux
[Tutorial goal]: Build a mapserver experimental environment based on Desktop Linux (such as FC2), including the webserver + Ka-map runtime environment, compilation environment, and necessary tool set.
[Purpose of this article]: reduce the difficulty of building mapserver on Linux and promote the use of open-source GIS and other open-source products.
[Readers]: mapserver and Linux users like me
2. Environment Description
This is my lab environment.
Pavilion dv4000 notebook
CPU celeon M 1.5g
Mem 512 m
[Desktop Linux selection]:
Co-create Linux SP1 1206rc
Because FC2 has stopped upgrade and maintenance in last year, so the domestic release of the FC2-based Desktop Linux version co-create Linux SP1 1206rc, this version by the http://www.opendesktop.net/
The Community provides support and is an XP operating style suitable for beginners/office users to use.
Co-create Linux requires that the cpu Of the machine be no less than piii800, the memory is greater than 128, and the disk space is greater than 4 GB.
3. Install the Desktop Linux and development environment:
1. Install co-create linux2005 SP1 1206rc, which provides the basic desktop environment.
: The ftp://ftp.opendesktop.net/co-create/desktop/2005sp1/Baby2-i386-disc-SP1-20051206.iso is recommended to download and then install the dial. Bare metal installation is best. If a Windows machine is installed, only one hard disk is required for the PC, and an idle partition is opened at the end of the hard disk for installation.
2. Install the co-create linux2005 SP1 1206rc Development Kit
It can be installed on a dial or downloaded to a hard disk.
Hard Disk Installation Method: on the Linux terminal (right-click the blank area on the desktop and choose the first item from the menu), run the following command in the current directory of the development kit:
Mount cocreate-devel-packages-12-06.iso iso-oloop
Sh./install. Sh -- all
4. Install the mapserver Runtime Environment
The running environment of mapserver includes webserver and support library.
After testing, in the cocreatelinuxsp1 + Development Kit environment, the dependencies of mapserver are as follows:
The arrows in the figure indicate dependency, for example, postgresql-devel depends on postgresql-lib.
An endpoint connection indicates that the required library file exists in a package. For example, libodbc. so.1 is available in unixodbc.
In addition, ka-map also requires PHP and PHP-GD support, their dependencies are as follows
Php-devel will be used in later compiling environments. It is listed here.
Install related software packages as follows:
1. In the http://mappinghacks.com/rpm/fedora/2/, download:
2. Search for other FC2-based packages on http://rpm.phone.net/, including unixodbc, httpd, PHP, PHP-Gd
Note: The appropriate PHP-Gd package is not found. Download the packages of other versions and directly extract the files and copy them to the specified location for testing.
Run the following command in the directory where the package is located (the file downloaded through the browser is located in/root/desktop/my_documents/my_downloads:
Rpm-IVH unixODBC-2.2.8-5.i386.rpm postgresql-libs-7.4.6-mh1.i686.rpm postgresql-devel-7.4.6-mh1.i686.rpm geos-2.1.1-mh1.i686.rpm gdal-1.2.5-mh1.i686.rpm ogdi-3.1.4-mh1.i686.rpm
Cp gd. INI/etc/PHP. d /.
Cp gd. So/usr/lib/PhP4 /.
4. Start httpd
Service httpd start (or/etc/init. d/httpd start)
Access http: // localhost/cgi-bin/mapserv to display no query information to decode. QUERY_STRING is set, but empty. indicates that the mapserver runtime environment is successfully installed.
Note that the Ka-map cannot run at this time because php_mapscript.so cannot be dynamically loaded. I later used the source code package of the same version (4.4.1) to compile the php_mapscript.so locally. I guess it is because php_mapscipt requires the include file of PHP in the process of compilation and generation by mapserver, therefore, PHP versions may be strictly consistent.
5. Install the mapserver compiling environment
As mentioned above, if the local PHP version is inconsistent with the PHP version used during mapserver compilation, the php_mapscipt.so file cannot be dynamically loaded, and the Ka-map file cannot be used normally. Considering some possible experiments, such as compiling the latest mapserver4.8, it is necessary to build a mapserv compiling environment.
After testing, the dependencies of the compiling environment of mapserver are as follows:
Among them, the dependencies required by PHP-devel have been described earlier, and the remaining several packages that devel depends on have been installed before.
1. In the http://mappinghacks.com/rpm/fedora/2/, download:
2. Search for the Ming, Ming-devel, pdflib, pdflib-devel, PHP-devel for FC2 on the http://rpm.phone.net.
The command is as follows:
Rpm-IVH gdal-devel-1.2.5-mh1.i686.rpm geos-devel-2.1.1-mh1.i686.rpm ming-0.2a-2.1.fc2.rf.i386.rpm ming-devel-0.2a-2.1.fc2.rf.i386.rpm pdflib-6.0.1-1.1.fc2.rf.i386.rpm pdflib-devel-6.0.1-1.1.fc2.rf.i386.rpm php-devel-4.3.4-11.i386.rpm
Now the configuration environment of mapserver is ready!
1. Compile SRC. rpm, take mapserver-4.6.0beta3-mh1.src.rpm as an example.
The FC2 directory on mappinghacks.com only provides the RPM package of mapserver4.2.1, it seems that the support for the new package has been stopped, so if you need the RPM package of the mapserver-4.6, you can only try it yourself.
Since the FC3 and FC2 structures do not differ much, we try to rebuild the FC3 mapserver-4.6.0beta3-mh1.src.rpm provided by mappinghacks.com on cocreatelinux.
The command is as follows:
Rpmbuild-ba -- target = i686./mapserver. spec
Result: The compilation is successful. Both the generated mapserver and php_mapscript.so can work normally.
2. Compile the source code package
Download mapserver-4.8.1.tar.gz and 4.6.2, 4.4.1 source code package on the http://mapserver.gis.umn.edu/, all compiled successfully.
Tar xvzf mapserver-4.8.1.tar.gz
./Configure -- With-proj -- With-PHP =/usr/include/PHP
There are many configure parameters. Here I list the two most basic and essential parameters. The former is about projection, and the latter generates php_mapscript.so. The other parameters are obtained based on their own needs, for example, -- With-PDF -- With-ming.
6. Map File editing tool
Tools that support editing or generating map files include maplab and qgis.
1. Installation of maplab
Maplab is a Web-based map file editing tool and script debugging tool. It consists of three components: mapedit, mapbrowser, and gmapfactory.
A. Installation Requirements:
Maplab requires that the compilation parameters of mapserver and PHP-mapscript be -- With-Gd -- enable-force-freetype1 -- With-PHP -- With-proj-with-wmsclients-with-gdal
The environment in this article is: -- With-Gd -- enable-force-freetype1 -- With-PHP =/usr/include/PHP/-- With-proj-with-wmsclients-with-gdal
B. Installation Process:
1) php_dbase support
Maplab requires php_dbase support. Download the php_dbase support library on the http://phprpms.sourceforge.net/dbase.
Because the PHP version on FC2 is relatively old (4.3.4), the package provided on php_dbase already corresponds to PHP version 4.3.10. It is troublesome to re-compile PHP, so we should look for the previous version.
I went down to the php-dbase-4.3.2-26.ent.1.i386.rpm on EL3 and there was no problem after the experiment.
2) Brief HTTP configuration
In maplab, the file Suffix of many PHP scripts is phtml. You must specify it in the httpd configuration file.
Edit the httpd. conf file in/etc/httpd/conf:
CP httpd. conf httpd. conf. Default
VI httpd. conf or gedit httpd. conf
Add addtype application/X-httpd-PHP. phtml to a row;
Service httpd restart
Download the latest maplab-2.2.1.tar.gz
Tar xvzf maplab-2.2.1.tar.gz
Chmod 777 config data ptoject
Chmod 666 *
Access http: // localhost/maplab/htdocs/in a browser/
In this case, you can access the home page of maplab.
Click the 5th icon button in the upper left column (the prompt is "Open xml configuration tool"). Open each configuration page and click "Apply.
Maplab installation is complete.
Ii. Installation of qgis
Qgis is a lightweight GIS data viewing and editing software. It is still in development. Because it supports map file output, let's first introduce it.
A. RPM package installation:
Provides http://mappinghacks.com/rpm/fedora/2/ in qgis-0.5.0-0.i386.rpm
This package can be directly installed in the aforementioned environment (qgis0.5 depends on gdal and postgresql-devel.
After the installation is complete, run qgis on the command line to start the GUI qgis.
For ease of use, we create a shortcut on the cocreatelinux desktop. Right-click the blank area on the desktop, select the second item "create initiator" in the pop-up menu, and fill in qgis and qgis respectively in the name and command of the pop-up window, and select an icon (the default qgis icon is located in/usr/share/qgis/images/icons/qgis-icon2.png), click OK.
B. compiling environment
1. Compile 0.6
The qgis version of FC2 provided by mappinghacks is relatively old. Only SHP is supported and the format of MapInfo is not supported. It will be supported later than 6.0. Therefore, we try to build a qgis compiling environment to obtain a new version for installation.
Conservative approach, we're trying to get started with the FC3 qgis-0.6.0-mh2.src.rpm provided online.
First install, rpm-IVH qgis-0.6.0-mh2.src.rpm
Here we can take a further step: the RPM compiling condition is sometimes described in a spec file provided in this source code RPM package. We can view this file to understand the dependency environment of qgis0.6.
Press SHIFT + Pageup on the terminal to view the displayed content. You can see the following two lines:
Requires: gdal postgresql-postgis QT
Buildrequires: gdal-devel postgresql-devel QT-devel
This is the environment that tells us the RPM package security and source code compilation dependencies.
Here, the QT compilation support environment has been provided in the development package, but if this package is missing, you need to download and install it.
The rest is postgresql-postgis, which needs to be used during installation.
We will discuss the installation of postgresql-postgis in the following database section. Currently, compilation conditions are met.
Rpmbuild-ba -- target = i686./qgis-06-grass.spec
The package generated after compilation is located under/usr/src/RedHat/RPMS/i686.
Because it is a program written in C ++, qgis compilation takes about 40 minutes.
2. Compile 0.7.4
We will further test the latest version 0.7.4, which adds the first requirement for SQLite and proj.
1) download SQLite and SQLite-devel:
2) download the latest source code package
The latest version is 0.7.4.
Tar xvzf qgis-0.7.4.tar.gz
3) Compilation and Installation
4) Create an RPM package
You can compile and prepare its RPM package, so that you can install the RPM package to facilitate future program management, such as uninstall and upgrade. You can modify the 0.6 spec file for 0.7.4 to create an RPM package. This process is complicated. If you are familiar with Linux, try it. I will not describe it in detail here.
In version 0.7.4, qgis supports local locale settings to display Chinese layers. We look forward to its further perfection.