Sure.
simple-test-script.php
simple-test-script.c
"SELECT * FROM pages" returns 4 rows / 5 short columns each.
I got ubuntu:
on p4 2.xghz 512ram
Apache2 run just from apt-get install + mod_php + mod_fastcgi (-processes 10 - same as lsws).
Lsws standard with c fastcgi as described in previous posts (php fastcgi is built in - as I get it).
I typically measured it with
simple-test-script.php
Code:
<html><head><title>CGI C Example #3</title></head>
<body><h1>CGI C Example #3</h1>
<table border=2>
<?
$db = mysql_pconnect("localhost","root","") or die('konnekt');
mysql_select_db("ht3") or die('db');
$r = mysql_query("SELECT * FROM pages");
if ($r)
{
$nrows = mysql_num_rows($r);
$num_fields = mysql_num_fields($r);
printf("rows: %i, cols: %i
\n",$nrows,$num_fields);
printf("<table border=2>\n");
while ( $row = mysql_fetch_array($r) )
{
printf("<tr>");
for($j = 0; $j < $num_fields; $j++)
{
printf("<td>%s</td>", $row[$j] ? $row[$j] : NULL");
}
printf("</tr>");
printf("\n");
}
printf("</table></body></html>\n");
mysql_free_result($r);
}
mysql_close($db);
?>
</table></body></html>
Code:
#include <stdio.h>
#include <mysql.h>
#include "fcgi_config.h"
#include <stdlib.h>
#include "fcgi_stdio.h"
int main ()
{
int err = 0;
MYSQL dbase;
if (mysql_init(&dbase) == NULL) err = 1;
else
{
if(mysql_real_connect(&dbase,"localhost","root","","ht3",0,NULL,0) == NULL) err = 1;
}
if(err)
{
printf("
Error connecting to database</body></html>\n");
exit(0);
}
//
// B E G I N R E Q U E S T
//
while (FCGI_Accept() >= 0)
{
char sqlbuff[255];
MYSQL_RES *result;
printf("Content-type: text/html\r\n\r\n");
printf("<html><head><title>CGI C Example #3</title></head>\n");
printf("<body><h1>CGI C Example #3: %i</h1>\n",getpid());
sprintf(sqlbuff,"SELECT * FROM pages");
if(mysql_real_query(&dbase,sqlbuff,strlen(sqlbuff)))
{
printf("
SQL error</body></html>\n");
exit(1);
}
result = mysql_store_result(&dbase);
if(result)
{
int i, j, num_fields, nrows;
MYSQL_ROW row;;
nrows = mysql_num_rows(result);
num_fields = mysql_num_fields(result);
printf("rows: %i, cols: %i
\n",nrows,num_fields);
printf("<table border=2>\n");
while ( row = mysql_fetch_row(result) )
{
printf("<tr>");
for(j = 0; j < num_fields; j++)
{
printf("<td>%s</td>", row[j] ? row[j] : "NULL");
}
printf("</tr>");
printf("\n");
}
printf("</table></body></html>\n");
mysql_free_result(result);
free(result);
}
else
{
printf("No entries</body></html>\n");
}
} /* while */
mysql_close(&dbase);
return 0;
}
I got ubuntu:
Code:
root@fryk:/var/www # uname -a
Linux fryk 2.6.10-5-386 #1 Tue Apr 5 12:12:40 UTC 2005 i686 GNU/Linux
Apache2 run just from apt-get install + mod_php + mod_fastcgi (-processes 10 - same as lsws).
Lsws standard with c fastcgi as described in previous posts (php fastcgi is built in - as I get it).
I typically measured it with
Code:
ab -n 20000 -c 50 PATH