Question:
How can I fix "unable to fork" error in php?
CuriousCliff
2009-06-24 13:45:41 UTC
I'm trying to setup a php page that will allow me to create a mysql database, and then build tables, views, etc. by importing a file previously created by mysqldump. When I get to the following command:

passthru("/usr/bin/mysql -u $username -p$password $dbname < /home/service/dump.sql");

I get this error:


Warning: system() [function.system]: Unable to fork [/usr/bin/mysql -u dbMaker -pbogusPwd fakeDB < /home/service/dump.sql] in /home/jboss/jboss-web-2.1.1.CR3/webapps/ROOT/newdb.php on line
37

My server is Ubuntu Hardy Heron, php 5.2.3, and mysql 4.1.20

I've been unsuccessful in diagnosing this problem. So here I am.
Three answers:
2016-12-10 16:58:39 UTC
Php Exec Unable To Fork
Jamie
2009-06-24 14:28:25 UTC
First would be to figure out what is going on, once you do that it should be pretty easy. (or at least, you'll know whether it's possible on that host)



Do you have access to the server via ssh ? try that. (ssh is really good - I wouldn't even consider a hosting company that didn't provide full access via ssh)



Is there indeed a command: /usr/bin/mysql ? (maybe it's in /usr/local some place?)



Try it via perl (or even a shell) OFTEN php is compiled with limitations.



Try using passthru on other commands and see if they work.



Do a little investigating to see if httpd is chroote'd. (this is sometimes the case, but rare)



Try and see if that tells you anything.



Could be ulimit or php settings or (doubtful) the system is overworked.



My guess is either the command /usr/bin/mysql isn't actually present (from the web servers perspective) or php has been compiled with severe restrictions.



I've seen some ISP's limit the number of processes you can have at any given time, down to laughably small numbers. (which is unfortunate, one way to reduce memory requirements on long running processes is via the use of fork for memory intensive parts) if mysql is actually a shell wrapper, the process limitations can become a factor. (doubtful)



I deal in different hosts all the time, often ISP's (especially the cheap-o packages that are supposed to be "easy to use") totally mess up php. Avoid them at all costs, you'll spend more time and $$ screwing around with the limitations than you'd save by going with a better host.
2009-06-25 10:15:04 UTC
i would check the permission to the directory that you are trying to execute in



http://www.somacon.com/p255.php


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...