Changes between Initial Version and Version 1 of PHPBuildDebugLinux


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

--

Legend:

Unmodified
Added
Removed
Modified
  • PHPBuildDebugLinux

    v1 v1  
     1= Building and Debugging PHP MapScript on Linux =
     2
     3Stephen Woodbridge wrote:
     4{{{
     5 > I have finally gotten around to trying to debug the
     6 > PHP3/Mapscript? problem I was having. You said I should
     7 > build PHP/Mapscript? as a static php CGI executable so I
     8 > can run it in gdb.
     9}}}
     10Actually, 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.
     11
     12Once you're all setup, you can debug a PHP script that crashes using the 'php' CGI executable in gdb with:
     13{{{
     14  $ gdb ./php
     15  ...
     16  (gdb) run /path/to/test.php
     17  ...
     18}}}
     19Here is the fun part: If you need to setup a breakpoint inside php_mapscript.so then you have to:
     20
     21 - First set a breakpoint in php_dl()
     22 - start the program, when it reaches php_dl(), type "finish" to let
     23   php_dl() finish its execution
     24 - debugger will stop again at the end of php_dl(), after
     25   php_mapscript.so is loaded... then you can set breakpoints anywhere
     26   in php_mapscript.so and enjoy gdb!  :)
     27 - Make sure you disable all breakpoints before re-running the program
     28   or gdb will keep complaining about them
     29
     30There may be ways to automate this in gdb but I never looked into that any further... I welcome suggestions.
     31{{{
     32 > All the documentation only talks about building it as a DSO module for
     33 > apache. Can you send me a link or have someone add it to Wiki? I think
     34 > this would be a great help to aid others that might want to work with
     35 > PHP3 and Mapscript.
     36 >
     37}}}
     38The answer to this question has been moved to a separate PHPMapScriptCGI page.
     39{{{
     40 > Also have you guys posted documentation on how to build Mapscript for
     41 > PHP4 and !MapServer 3.5? on Wiki?
     42 >
     43}}}
     44Nothing 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):
     45
     461- Compile and install PHP as a CGI as described above
     47
     482- Run configure in your mapserver dir. with the --with-php switch:
     49
     50   ./configure --with-php=/path/to/php-src-that-you-just-compiled ...
     51
     523- run 'make', that will automagically build mapserv, etc. ... and php_mapscript.so in mapserver/mapscript/php3
     53
     544- Edit your php.ini and make sure extensions_dir is set to point to a valid location (e.g. /usr/local/lib/php4)
     55
     565- Copy php_mapscript.so to your extensions_dir
     57
     586- 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
     59
     607- You're ready to use dl("php_mapscript.so"); to load and use PHP MapScript in your PHP apps.
     61
     62See also the PHPMapScript-install-HOWTO for more info: http://www.mapserver.org/installation/php.html