[mapserver-users] Debugging PHP/Mapscript

Stephen Woodbridge woodbri at swoodbridge.com
Tue Jan 15 17:05:46 PST 2002


Daniel,

Thank you for you help, this has been very instructive. I will also add
it to Wiki for future reference.

I just tried the php3/examples/test_draw_map.phtml file on my demo.map
which is working with 3.5 and it ran fine? So I am now wondering if the
problem may not lie in the gmap75 stuff. I will check the map file to
make sure it has the lastest 3.5 changes applied to it.

Many thanks for you support.

-Steve

Daniel Morissette wrote:
> 
> Stephen Woodbridge wrote:
> >
> > I have finally gotten around to trying to debug the PHP3/Mapscript
> > problem I was having. You said I should build PHP/Mapscript as a static
> > php CGI executable so I can run it in gdb.
> >
> 
> Actually, I meant compile PHP as a CGI executable instead of as an
> Apache DSO.  And then you still compile PHP MapScript the same way, as a
> php_mapscript.so file that will be loaded by PHP at runtime.
> 
> Once you're all setup, you can debug a PHP script that crashes using the
> 'php' CGI executable in gdb with:
> 
>   $ gdb ./php
>   ...
>   (gdb) run /path/to/test.php
>   ...
> 
> Here is the fun part: If you need to setup a breakpoint inside
> php_mapscript.so then you have to:
> 
>  - First set a breakpoint in php_dl()
>  - start the program, when it reaches php_dl(), type "finish" to let
>    php_dl() finish its execution
>  - debugger will stop again at the end of php_dl(), after
>    php_mapscript.so is loaded... then you can set breakpoints anywhere
>    in php_mapscript.so and enjoy gdb!  :)
>  - Make sure you disable all breakpoints before re-running the program
>    or gdb will keep complaining about them
> 
> There may be ways to automate this in gdb but I never looked into that
> any further... I welcome suggestions.
> 
> > All the documentation only talks about building it as a DSO module for
> > apache. Can you send me a link or have someone add it to Wiki? I think
> > this would be a great help to aid others that might want to work with
> > PHP3 and Mapscript.
> >
> 
> You should be able to find detailed information at
> http://www.php.net/manual/en/installation.php
> 
> I believe that PHP's default 'configure' behavior is to build a 'php'
> CGI executable.  It's the --with-apxs and/or --with-apache PHP configure
> options that enable PHP to be built as an Apache DSO.
> 
> So basically to build PHP as a CGI simply make sure that you don't
> provide the --with-apxs or --with-apache switch to the PHP configure.
> It is also good practice when building PHP as a CGI to include the
> --enable-force-cgi-redirect switch for security reasons.
> 
> Then once you have a 'php' executable, copy it to your server's cgi-bin
> directory and add to your httpd.conf:
> 
>   AddType  application/x-httpd-php3 .php3
>   AddType  application/x-httpd-php3 .phtml
>   AddType  application/x-httpd-php3 .php
> 
>   Action application/x-httpd-php3 /cgi-bin/php
> 
> The same works for PHP3 or PHP4 as a CGI.
> 
> Note: Make sure you don't have an old PHP DSO already preloaded in your
> Apache... this is common with preinstalled Apache on RedHat systems for
> instance.  If you're in that situation and don't feel like recompiling
> Apache then you can bypass the module by removing the original AddType
> lines and using another type for your PHP CGI AddType and Action
> directives, e.g.
> 
>   AddType  application/x-httpd-php-cgi .php3
>   AddType  application/x-httpd-php-cgi .phtml
>   AddType  application/x-httpd-php-cgi .php
> 
>   Action application/x-httpd-php-cgi /cgi-bin/php
> 
> > Also have you guys posted documentation on how to build Mapscript for
> > PHP4 and MapServer 3.5? on Wiki?
> >
> 
> Nothing special to say there... MapServer's configure takes care of it
> all on most platforms... here are some detailed steps (hopefully I
> didn't forget anything):
> 
> 1- Compile and install PHP as a CGI as described above
> 
> 2- Run configure in your mapserver dir. with the --with-php switch:
>    ./configure --with-php=/path/to/php-src-that-you-just-compiled ...
> 
> 3- run 'make', that will automagically build mapserv, etc.
>     ... and php_mapscript.so in mapserver/mapscript/php3
> 
> 4- Edit your php.ini and make sure extensions_dir is set to point to a
>    valid location (e.g. /usr/local/lib/php4)
> 
> 5- Copy php_mapscript.so to your extensions_dir
> 
> 6- Make sure all libs used in your MapServer build are included in your
> runtime library path.  See the PHP MapScript install FAQ about this
> common problem:
> http://mapserver.gis.umn.edu/doc/phpmapscript-install-howto.html#d41e543
> 
> 7- You're ready to use dl("php_mapscript.so"); to load and use PHP
> MapScript in your PHP apps.
> 
> See also the PHPMapScript-install-HOWTO for more info:"
> http://mapserver.gis.umn.edu/doc/phpmapscript-install-howto.html
> 
> I hope that helps...
> 
> P.S. I have added a copy of this message in the Wiki at
> http://mapserver.gis.umn.edu/cgi-bin/wiki.pl?PHPBuildDebugLinux
> 
> --
> ------------------------------------------------------------
>  Daniel Morissette               morissette at dmsolutions.ca
>  DM Solutions Group              http://www.dmsolutions.ca/
> ------------------------------------------------------------
>   Don't put for tomorrow what you can do today, because if
>       you enjoy it today you can do it again tomorrow.



More information about the MapServer-users mailing list