3

I need to upgrade from Ubuntu 14.04 to 16.04 but php5 is not officially supported on Ubuntu 16. I install php5.5 by ondrej repo https://askubuntu.com/a/756186/483814
but when I try to install php5-mapscript on it i get error :

root@ubuntu16:~# apt-get install php5-mapscript
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package php5-mapscript is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'php5-mapscript' has no installation candidate

Therefore i try to compile and install php-mapscript from scratch but i don't find any updated and working manual.

So if somebody done it before or have general knowledge about mapserver compilation or if know how to install it from repositories please help.

4

First answer

Don't try to compile Mapscript on Ubuntu 16.04 with PHP as long as your PHP version is not 5.x.

It will not work for the simple reason that supported PHP version in Ubuntu 16.04 is 7.0 and infortunately for you PHP 7 and MapScript are incompatible at the moment. You can see the related opened issue on the official MapServer Github repository.

The best solution IMO is simply to not upgrade: the support for 14.04 end in April 2019 (source)

Addition

You need when you compile to be sure to have PHP headers (the package is usually named php-dev or php5.6-dev) and to set the cmake option to support PHP like illustrated in the section http://www.mapserver.org/installation/unix.html#compiling

  • I know it and don't want to compile it on php 7 I want to compile it based on php5.5.36 from ondrej repository. – MSS Nov 16 '16 at 6:43
  • Made addition for some compiling help. – ThomasG77 Nov 16 '16 at 7:05
  • At first i should solve this problem: FREETYPE library/component could not be found and is a mandatory dependency – MSS Nov 16 '16 at 7:10
  • apt-get install libfreetype6-dev Deduced from packages.ubuntu.com/en/source/xenial/mapserver – ThomasG77 Nov 16 '16 at 7:26
  • apt-get install libfreetype6-dev apt-get install libproj-dev apt-get install libfribidi-dev – MSS Nov 16 '16 at 7:27
3

Thanks to @ThomasG77 i did compile and install php5-mapscript of Mapserver7.0.2 compiled and got loaded successfully: enter image description here

The manual is based on mapserver general compile documentations: http://www.mapserver.org/installation/unix.html#compiling

Here is the manual I follow to compile [Ubuntu 16.04 /PHP 5.5.38-3+deb.sury.org~xenial+1]:

  1. installing php5.5:

    sudo apt-get purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
    sudo add-apt-repository ppa:ondrej/php
    sudo apt-get update
    sudo apt-get install php5.5
    
  2. download and extract mapserver source and change directory:

    wget http://download.osgeo.org/mapserver/mapserver-7.0.2.tar.gz
    tar xvf mapserver-7.0.2.tar.gz
    cd mapserver-7.0.2/
    
  3. install cmake

    sudo apt-get install cmake
    
  4. make build directory and change to it [~/mapserver-7.0.2/build]:

    mkdir build
    cd build
    
  5. install compile requirement

    apt-get install libfreetype6-dev 
    apt-get install php5.5-dev
    apt-get install libproj-dev
    apt-get install libfribidi-dev
    apt-get install libharfbuzz-dev
    apt-get install libcairo-dev
    apt-get install libgdal-dev
    apt-get install libgpg-dev
    
  6. config , compile and install

    cmake -DCMAKE_INSTALL_PREFIX=/opt \
            -DCMAKE_PREFIX_PATH=/usr/local/pgsql/91:/usr/local:/opt \
            -DWITH_CLIENT_WFS=ON \
            -DWITH_CLIENT_WMS=ON \
            -DWITH_CURL=ON \
            -DWITH_SOS=ON \
            -DWITH_PHP=ON \
            -DWITH_FCGI=OFF \
            -DWITH_PYTHON=OFF \
            -DWITH_SVGCAIRO=OFF \
            ../ >../configure.out.txt
    make
    make install
    echo extension=php_mapscript.so>/etc/php/5.5/mods-available/mapscript.ini
    phpenmod mapscript
    service apache2 restart
    
1

In addition to the very helpfull answer of MSS and still (rather frustrated...) waiting for proper PHP-Mapscript-Support in PHP7:

Some hints for compiling Mapscript MapServer version 7.2.0 under Debian 9.5 with PHP 5.6:

Step 1:
(Install PHP 5.6 instead of PHP 5.5)
see:
https://stackoverflow.com/questions/46378017/install-php5-6-in-debian-9
https://stackoverflow.com/questions/45367249/apache2-4-php-5-6-and-php7-1-running-at-the-same-time

apt-get install apt-transport-https lsb-release ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list
apt-get update
apt-get install php5.6
update-alternatives --config php  
(and select the item with PHP 5.6)  
a2dismod php7.0
a2enmod php5.6
service apache2 restart

Step 2:

wget http://download.osgeo.org/mapserver/mapserver-7.2.0.tar.gz
tar xvf mapserver-7.2.0.tar.gz
cd mapserver-7.2.0/

Step 5:

apt-get install libfreetype6-dev
apt-get install php5.6-dev
apt-get install libproj-dev
apt-get install libfribidi-dev
apt-get install libharfbuzz-dev
apt-get install libcairo-dev
apt-get install libgdal-dev
apt-get install libgpg-error-dev

Step 6:

cmake 
-DCMAKE_INSTALL_PREFIX=/opt 
-DCMAKE_PREFIX_PATH="/usr/local:/opt" 
-DWITH_PROTOBUFC=0 
-DWITH_CLIENT_WFS=ON 
-DWITH_CLIENT_WMS=ON 
-DWITH_CURL=ON 
-DWITH_SOS=ON 
-DWITH_PHP=ON 
-DWITH_FCGI=OFF 
-DWITH_PYTHON=OFF 
-DWITH_SVGCAIRO=OFF .. >../configure.out.txt

(all in one line)

make
make install
echo extension=php_mapscript.so>/etc/php/5.6/mods-available/mapscript.ini
ln -s /etc/php/5.6/apache2/conf.d/mapscript.ini /etc/php/5.6/apache2/conf.d/mapscript.ini  
phpenmod mapscript
service apache2 restart

enter image description here

0

The current version of PHP-MapScript is not compatible with PHP7. To compile MapServer with PHP7-MapScript replace the code in ~/mapserver/mapscript/php with the code from https://github.com/bjoernboldt/mapscript-php7. Then run cmake with WITH_PHP=1. Sometimes it is nessecary to add the PHP-Path too.

For example:

cd ~/mapserver

mkdir build

cd build

cmake -D WITH_PHP=1 -D PHP_INCLUDES=/usr/include/php/20151012 ..

make

make install

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.