Joshua's Thoughts

view realtime requests per second from log

Tags: , ,

so you want to view the number of requests to your webserver per second. here’s a quick and easy php script that you can run from command line.

  while(true){
    echo exec('cat /var/log/httpd/access_log | wc -l') . "\n";
    sleep(1);
  }

it isn’t perfect, but it will work for doing some basic troubleshooting. just hit ctrl+c to terminate.

and if you want to simulate a bunch of request so you can watch the num go up and down, here’s a script to help:

while(true){
  exec('wget yourdomain.com');
  unlink('index.html');
}
?>

how to enable libcurl in wamp

Tags: , , ,

if you’re getting “Fatal error: Call to undefined function: curl_init()” and you’re using wamp, you’ve got to perform a few extra steps to get curl working.

wamp comes with a crap load of extensions, including curl. it’s just a matter of getting the extension loaded when wamp is started. and no, enabling php_curl from within the wamp menu is not how to do it. for some reason, that just doesn’t work.

here’s what you need to do:

  • open C:\wamp\bin\php\php5.2.6\php.ini
  • find “;extension=php_curl.dll” and remove the semicolon to uncomment the line
  • do the same for C:\wamp\bin\apache\apache2.2.8\bin\php.ini

it doesn’t matter what version of wamp you’re running at the time, the process is the same.

next, you need to make sure apache can find the extension to load, so make sure that in both php.ini files, you find the lines:

; Directory in which the loadable extensions (modules) reside.
extension_dir = “C:\wamp\bin\php\php5.2.6\ext”

… and have them both point to the ext folder within your PHP folder. by default, they will be something like /usr/bin/ext. change that.

restart wamp and it should all work. you can look in the phpinfo to see if curl was loaded. if it still doesn’t work, check the apache error log within the wamp logs folder.