PHP Developers Network
http://forums.devnetwork.net/

Building a CGI
http://forums.devnetwork.net/viewtopic.php?f=30&t=137282
Page 2 of 2

Author:  Eric! [ Sun Jan 27, 2013 6:01 pm ]
Post subject:  Re: Building a CGI

I have one binary running fine on my host environment but it causes a segmentation fault on the server. All the other bins with their shared libraries run fine, except this one. There was just no output. I had the tech support run it in a shell and they can see the segmentation fault. So I realized I'm not seeing the stderr output...

Is there anyway to get the stderr output on a shared host?

BTW does a segmentation fault mean there is some kind of difference between my host and the target? I know the kernel looks slightly different patch levels. Can binaries be built remotely on a shared host? I guess that's my next step.

EDIT: I found I can pipe them with 2> error.txt with bash to capture stderr. This will save me a lot of configuration guessing.

Author:  Eric! [ Mon Jan 28, 2013 11:07 am ]
Post subject:  Re: Building a CGI

Since I don't often build from source, the solutions to my problems weren't obvious. So I'll share what ended up working. I was surprised to find that I could access gcc though the bash shell and this allowed me to build the bins on the server itself.

The tricks required to compile everything remotely were two switches:
--prefix and --exec-prefix

These allow one to define where the bins and info/library will be installed. Here's an example bash install script that you would run in your $HOME/cgi-bin/ directory.
Syntax: [ Download ] [ Hide ]
#!/bin/bash
#Your full absolute path is required
HOME="/home/user/public_html";
#what you want to reference this application as (creates subdirectory too)
APP="grib-api";
echo "Content-type: text/html";
echo "";
echo '<html>';
echo '<head>';
echo "<title>Build $APP Program</title>";
echo '</head>';
echo '<body>';
echo '<h2>Downloading, Expanding, Building</h2>';
echo "<pre>";
curl -LO -k https://software.ecmwf.int/wiki/downloa ... 0.0.tar.gz
gunzip grib_api-1.10.0.tar.gz
tar -xvf grib_api-1.10.0.tar
mkdir $APP
chmod 777 $APP
cd grib_api-1.10.0
chmod 755 configure
./configure --prefix=$HOME/cgi-bin/grib_api/ --exec-prefix=$HOME/cgi-bin/$APP/ --disable-jpeg 2>config-$APP-errors.txt
make 2> make-$APP-errors.txt
make install 2> install-$APP-errors.txt
echo ""
echo "CONFIG ERRORS:"
cat config-$APP-errors.txt
echo ""
echo "MAKE ERRORS:"
cat make-$APP-errors.txt
echo ""
echo "INSTALL ERRORS:"
cat install-$APP-errors.txt
echo "</pre></body></html>"

Once it is installed you can go back and set the permission levels to the necessary settings and remove the source and tarballs. Building additional binaries that require shared libraries is easier too with everything in one location on the server.

Page 2 of 2 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/