{"id":2086,"date":"2022-08-30T15:21:56","date_gmt":"2022-08-30T15:21:56","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/12\/25\/each-time-i-run-curl-on-php-the-server-will-die-i-have-to-restart-the-apache-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:21:56","modified_gmt":"2022-08-30T15:21:56","slug":"each-time-i-run-curl-on-php-the-server-will-die-i-have-to-restart-the-apache-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/each-time-i-run-curl-on-php-the-server-will-die-i-have-to-restart-the-apache-collection-of-common-programming-errors\/","title":{"rendered":"each time I run curl on php, the server will die. I have to restart the apache-Collection of common programming errors"},"content":{"rendered":"<p>Each time I run curl on php, the server will die. I have to restart the apache.<\/p>\n<p>The code is the following: I am trying to connect to my notification server and push notifications.<\/p>\n<p>I can, indeed, receive the notification, but the page with php-curl will never be open, and after that, my server will die(any pages can not be open, need to restart apache)<\/p>\n<pre><code>$url = 'http:\/\/myip:myport\/send';\n$fields = array(\n    'channel'=&gt;urlencode(\"mychannel\"),\n    'secretkey'=&gt;urlencode(\"mypassword\"),\n    'property1'=&gt;urlencode(\"from PHP\"),\n    'property2'=&gt;urlencode(\"Hello jimmy!\")\n    );\n\n$fields_string = \"\";\nforeach($fields as $key=&gt;$value) { $fields_string .= $key.'='.$value.'&amp;'; }\nrtrim($fields_string,'&amp;');\n\n$ch = curl_init();\ncurl_setopt($ch,CURLOPT_URL,$url);\ncurl_setopt($ch,CURLOPT_POST,count($fields));\ncurl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);\n\n$result = curl_exec($ch);\n\n\/\/close connection\ncurl_close($ch);\n<\/code><\/pre>\n<p>Supplement: It&#8217;s a Amazon&#8217;s EC2 server. also, i found that if i run curl in terminal, it not returning anything but it works properly.<\/p>\n<ol>\n<li>\n<p>I assume it is a Windows machine. Are you using XAMPP or WAMP? Google &#8220;php cURL crashes with windows&#8221; or your specific package, try to update your cURL extension. The code have nothing to do with your server crashing!<\/p>\n<\/li>\n<\/ol>\n<p id=\"rop\"><small>Originally posted 2013-12-25 10:55:34. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>Each time I run curl on php, the server will die. I have to restart the apache. The code is the following: I am trying to connect to my notification server and push notifications. I can, indeed, receive the notification, but the page with php-curl will never be open, and after that, my server will [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2086","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2086","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=2086"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/2086\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=2086"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=2086"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=2086"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}