Hosting

Nasty Apache, Nasty Error Detected in the Parent Process

At <a href=”http://progmaatic.com” title=”PROGmaatic Developer Network”>PROGmaatic</a>, we have several servers for different purposes. In one of our server, often during midnight (thats GMT+6) the Apache stops. I thought, OK may be it was due to load or something. Since it was not our production server, I wasn’t that much concerned.

Last month I moved an application to that server to off-load some processes from our main server. Now I started noticing the Apache downtime (which I should have fixed before 🙁 ). So finally today I started digging into the mighty Apache error log and found the something interesting:
<!–more–>
<code>
[Fri May 03 11:34:33 2013] [notice] caught SIGTERM, shutting down
[Fri May 03 11:35:35 2013] [notice] seg fault or similar nasty error detected in the parent process
</code>

After doing some Google search (No wonder here :D), I found that if <em>Apachectl graceful</em> is issued, this error occurs. So I know how to reproduce the error 🙂

So I issued this command in console and checked the error log. Same error. Nothing new! But after giving <em>Apachectl restart</em> I noticed a warning in error log.
<code>
PHP Warning: PHP Startup: Unable to load dynamic library ‘/usr/lib/php5/20090626+lfs/idn.so’ – /usr/lib/php5/20090626+lfs/idn.so: cannot open shared object file: No such file or directory in Unknown on line 0
</code>
Voila! It seems php5-idn is not available. So I issued <em>apt-get install php5-idn</em>. Btw php5-idn is required to show international characters in DNS

Now issuing <em>Apachectl graceful</em> stopped giving seg fault 🙂

How to run Python scripts in your shared hosting server

Direct to the how-to 🙂

  1. First make sure your hosting supports Python. Now a days almost all shared hosting providers support Python.
  2. Find your python installation location, this is required for “shebang” line added at the top of your python script. Usually this is /usr/bin/python or /usr/local/bin/python
  3. Make sure to include two print statements which will print the content-type and an empty line.
  4. Now put the script in cgi-bin directory inside your root public folder, usually public_html
  5. Change the permission of the script to 0755
  6. Try to browse now 🙂