Changes between Initial Version and Version 1 of PHPMapScriptRH73


Ignore:
Timestamp:
Jan 27, 2009, 9:00:59 AM (15 years ago)
Author:
jmckenna
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PHPMapScriptRH73

    v1 v1  
     1= Setting up !MapServer/!MapScript version 3.6 on !RedHat 7.3 =
     2
     3NOTE: These instructions were based on [wiki:PHPMapScript72 Detailed instructions to compile/install PHP MapScript 3.6 on RedHat 7.2].
     4
     5== Objective ==
     6
     7Configure a brand new RedHat 7.3 server to host MapServer-based apps:
     8
     9  - MapServer 3.6 (WMS)
     10  - PHPMapScript 3.6
     11  - GMap
     12
     13== Server Information ==
     14
     15We start with a clean !RedHat 7.3 install, configured with Apache preinstalled but no PHP.
     16
     17Source packages will be compiled under "/home/src" and installed in /usr/local
     18
     19Web Server installed under /var/www:
     20
     21 DocRoot = /var/www/html
     22 CGI dir = /var/www/cgi-bin
     23 Config  = /etc/httpd/conf
     24
     25!MapServer apps will be installed under /home/msapps using a logical link from /var/www/html/ -> /home/msapps/
     26
     27== List of required files or packages ==
     28
     29  proj-4.4.5.tar.gz
     30  proj-nad27-1.1.tar.gz
     31
     32  gdal-1.1.7.tar.gz
     33
     34  gd-2.0.7gif.tar.gz
     35
     36  libwww-5.3.2-20011211.tar.gz (CVS version as of 2001-12-11)
     37
     38  php-4.2.3.tar.gz
     39
     40  mapserver-3.6.3.tar.gz
     41
     42... and just for testing:
     43
     44  gmap-ms36.tar.gz
     45
     46== COMPILE/INSTALL PROJ-4 ==
     47{{{
     48  $ cd /home/src
     49  $ tar xzvf ~/arch/proj-4.4.5.tar.gz
     50  $ cd proj-4.4.5/nad
     51  $ tar xzvf ~/arch/proj-nad27-1.1.tar.gz
     52  $ cd ..
     53  $ ./configure
     54  $ make
     55  $ sudo make install
     56  $ cd ..
     57}}}
     58... also copy the custom "epsg" file (with EPSG:42xxx projections: http://www2.dmsolutions.ca/mapserver/dl/proj4-epsg-with-42xxx.zip):
     59{{{
     60  $ sudo cp ~/arch/epsg /usr/local/share/proj/epsg
     61}}}
     62... edit /etc/ld.so.conf and add /usr/local/lib, then run
     63{{{
     64  $ sudo /sbin/ldconfig
     65}}}
     66== COMPILE/INSTALL GDAL ==
     67{{{
     68  $ tar xzvf ~/arch/gdal-1.1.7.tar.gz
     69  $ cd gdal-1.1.7
     70  $ ./configure
     71  $ make
     72  $ sudo make install
     73  $ cd ..
     74  $ sudo /sbin/ldconfig
     75}}}
     76== COMPILE/INSTALL W3C-LIBWWW V5.3.2 ==
     77
     78... w3c-libwww version 5.3.2 with the latest fixes can be obtained only via CVS, but for this install, I've tared the copy that was previously downloaded and built on another server... it's simpler this way ;) (http://www2.dmsolutions.ca/mapserver/dl/misc/libwww-5.3.2-20011211.tar.gz)
     79{{{
     80  $ tar xzvf ~/arch/libwww-5.3.2-20011211.tar.gz 
     81  $ cd libwww
     82  $ ./configure
     83  $ make
     84  $ sudo make install
     85  $ cd ..
     86  $ sudo /sbin/ldconfig
     87}}}
     88== COMPILE/INSTALL GD-2.0.7 (with GIF and TTF) ==
     89
     90RH7.3 comes with a copy of gd-1.8.4 (without GIF) preinstalled. Since we want gd-2.0.7 with GIF (http://www.rime.com.au/gd/), we have to uninstall gd-devel-1.8.4-4.rpm and then install our new copy of gd under /usr/local/lib. This won't affect or break existing applications because removing the RPM only removes /usr/lib/libgd.so (logical link) and /usr/lib/libgd.a and the associated headers, but the physical file (libgd.so.1.8.4) will remain there for applications that came preinstalled on the RH system.
     91{{{
     92  $ sudo rpm -e gd-devel-1.8.4-4
     93
     94  $ tar xzvf ~/arch/gd-2.0.7gif.tar.gz 
     95  $ cd gd-2.0.7gif
     96
     97  $ ./configure
     98  $ make
     99  $ sudo make install
     100  $ cd ..
     101}}}
     102== COMPILE/INSTALL PHP 4 ==
     103
     104Note: We want PHP to use our custom GD compiled with Freetype 1.3, but PHP won't detect freetype by default. For PHP to detect the freetype1 headers, we have to create a logical link in /usr/include:
     105{{{
     106  $ cd /usr/include
     107  $ sudo ln -s freetype1/freetype freetype
     108}}}
     109... then we can proceed with normal PHP configuration.
     110{{{
     111  $ tar xzvf ~/arch/php-4.2.3.tar.gz 
     112  $ cd php-4.2.3
     113}}}
     114Compilation will fail unless two source files are corrected. Apparently the method free() was renamed to gd_free().
     115
     116    Modify ./ext/gd/gd.c
     117
     118        Change line 1014 from io_ctx->free(io_ctx); to io_ctx->gd_free(io_ctx);
     119        Change line 1017 from io_ctx->free(io_ctx); to io_ctx->gd_free(io_ctx);
     120        Change line 1209 from io_ctx->free(io_ctx); to io_ctx->gd_free(io_ctx);
     121
     122    Modify ./ext/gd/gd_ctx.c
     123
     124        Change line 70 from ctx->free = _php_image_output_ctxfree; to ctx->gd_free = _php_image_output_ctxfree;
     125        Change line 98 from ctx->free(ctx); to ctx->ctx->gd_free(ctx);
     126{{{
     127  $ ./configure  --enable-shared --with-regex=system --with-gd \
     128    --with-ttf=/usr --enable-gd-native-ttf --with-jpeg-dir=/usr \
     129    --with-png-dir=/usr --with-zlib --enable-force-cgi-redirect \
     130    --enable-dbase --with-config-file-path=/etc/httpd/conf
     131
     132  $ make
     133  $ strip php
     134  $ sudo make install
     135  $ sudo cp php /var/www/cgi-bin/php
     136  $ sudo cp php.ini-dist /etc/httpd/conf/php.ini
     137  $ cd ..
     138}}}
     139... edit /etc/httpd/conf/php.ini to set:
     140{{{
     141  ...
     142  log_errors = On
     143  ...
     144  extension_dir = /usr/local/lib/php/extensions/
     145  ...
     146}}}
     147... edit /etc/httpd/conf/httpd.conf
     148{{{
     149 #
     150 # And for PHP 4.x, use:
     151 #
     152 ##
     153 ## Commented-out... we bypass the PHP module and use PHP4 as
     154 ## a CGI instead ... see below
     155 ##
     156 ## ... old config ...
     157 ##
     158 #    <IfModule mod_php4.c>
     159 #        AddType application/x-httpd-php .php .php4 .php3 .phtml
     160 #        AddType application/x-httpd-php-source .phps
     161 #    </IfModule>
     162 ##
     163 ## New PHP 4 CGI config
     164 ##
     165 ## Use a different application type to bypass the PHP DSO
     166 ##
     167 AddType application/x-httpd-php4 .php4 .php3 .phtml .php
     168 Action  application/x-httpd-php4 /cgi-bin/php
     169}}}
     170Then restart the server using
     171{{{
     172  $ sudo /etc/rc.d/init.d/httpd restart
     173}}}
     174== COMPILE/INSTALL MAPSERVER ==
     175{{{
     176  $ tar xzvf ~/arch/mapserver-3.6.3.tar.gz
     177  $ cd mapserver-3.6.3
     178  $ ./configure --with-proj --with-wmsclient --with-libwww \
     179    --with-gdal --enable-runpath --with-php=../php-4.2.3 \
     180    --without-tiff --with-gd --enable-force-freetype1 \
     181    --enable-internal-ld-detect
     182
     183  $ make
     184
     185  $ cp mapserv /var/www/cgi-bin/mapserv_36
     186  $ sudo cp mapscript/php3/php_mapscript.so /usr/local/lib/php/extensions/php_mapscript_36.so
     187
     188  $ cd /usr/local/lib/php/extensions
     189  $ sudo ln -s php_mapscript_36.so php_mapscript.so
     190}}}
     191== Setup MapServer IMAGEDIR and cleanup script ==
     192{{{
     193  $ sudo mkdir /tmp/ms_tmp
     194  $ sudo chmod 777 /tmp/ms_tmp
     195}}}
     196... also add the commands above to /etc/rc.d/rc.local as well to recreate the directory when the system reboots, after a /tmp cleanup...
     197
     198... create a logical link for the ms_tmp directory on the web server
     199{{{
     200  $ cd /var/www/html
     201  $ ln -s /tmp/ms_tmp ms_tmp
     202}}}
     203... create "/etc/cron.daily/ms_clear_tmp.sh" ... you can also place the file in /etc/cron.hourly/ for busier sites...
     204{{{
     205 #! /bin/sh
     206 #
     207 # MapServer temporary file cleanup - run daily by cron
     208 #
     209 # Flush all files from /tmp/ms_tmp older than 6 hours (360 minutes)
     210 #
     211 find /tmp/ms_tmp -name "*.*" -amin +360 -exec rm -f {} \;
     212 exit 0
     213}}}
     214== SETUP GMAP DEMO ==
     215
     216Install a copy of the latest GMap demo to test our installation:
     217{{{
     218 $ cd /home/msapps
     219 $ tar xzvf ~/arch/gmap-ms36.tar.gz
     220}}}
     221... create a link from the htdocs directory to the application's htdoc:
     222{{{
     223 $ cd /var/www/html/
     224 $ ln -s /home/msapps/gmap/htdocs gmap
     225}}}
     226... modify the .map file to provide the complete pathname to the FontSet:
     227
     228    Modify /home/msapps/gmap/htdocs/gmap75.map
     229
     230        Change the FONTSET line (14) to FONTSET /home/msapps/gmap/etc/fonts.txt
     231
     232You should now be able to run GMap at
     233
     234    http://your.host.name/gmap/gmap75.phtml