Showing posts with label Apache. Show all posts
Showing posts with label Apache. Show all posts

Thursday, June 26, 2014

HOW TO FIGURE OUT WHAT IS CAUSING AN APACHE SEGMENTATION FAULT

— SkyHi @ Thursday, June 26, 2014

Having an apache segmentation fault on your server can drive you crazy trying to solve it… So, I’m gonna explain you how I figured out what was causing the last apache segfault I had.
My server was running under Debian Squeeze, with Apache 2.2 and PHP 5.3, and I got randomly segmentation faults:
I supposed the problem was on some php extension, so I deactivated some of them…but the problem was still there :(
After spending a lot of time looking for what was causing it, I decided to debug apache with gdb. I installed it through backports because I needed an upper version than gdb 7.0 (7.0.1-2 is the current version on squeeze stable repository) otherwise I got this: “warning: The current binary is a PIE (Position Independent Executable), which GDB does NOT currently support. Most debugger features will fail if used in this session.” when I was trying to debug apache:
Well, I had the debugger installed, but I also needed the php and apache debug symbols:
Once I had installed all I needed, I configured apache to create a core dump file every time it had a segfault by adding in /etc/apache2/httpd.conf the following line:
Previously, I had created the /tmp/apache-coredumps directory
By default, my system core file size was 0, so I had to change it through ulimit:
I restarted apache, and I only had to wait for the next Segmentation fault… and I didn’t have to wait too much …
Then, as the message said, I had a core file in /tmp/apache-coredumps, and I was closer to finding out what was causing segfaults :)
Therefore, it was time to use gdb:
I had a problem with php as I thought, and I was able to find more information about it. And after Googling for a few minutes, I found there is a bug with the PHP and APC version that I was using! (more info here)
After that, I could solve the problem and until now I haven’t got more segfaults on this server :)
Using gdb will not solve your segmentation faults, but at least, you will be able to figure out what’s causing it, and you’ll get more info to solve it.


REFERENCES
http://sysadmin.carlusgg.com/?p=197

Monday, April 29, 2013

Error : ” child pid exit signal File size limit exceeded (25) in Apache ” Resolution

— SkyHi @ Monday, April 29, 2013

Many times if you find apache processes dying in the top process list or apache failing to start completely then one of the reasons could be a log file larger than 2Gb , which is indicated by the below error in the apache error logs :

child pid XXXX exit signal File size limit exceeded (25)
where XXXX is process id for the process which is failing and generating the error in the error log.
To fix this you will need to locate the log file which has grown to or above 2Gb size and either empty it or make a tar , rename and create a new log file. It can be access_log , error_log itself, the suphp_log , suexec_log etc.
For cPanel serves you should set the log rotation from following link in WHM to avoid this :
WHM >> Service Configuration >> Apache Configuration >> Log Rotation
For finding files greater then 2Gb below commands can be helpful :

This will print the top ten files with respect to size in the current directory
# find `pwd` -xdev -type f -ls | sort -k7nr | head


This will print any files greater than 2Gb
# ls -l | awk '{ if ( $5 > 2147483648 ) print $9 "\t" $5 }'


This will show files greater than 2Gb using simple find command
# find / -size +2G

Note : Depending on the version of find command on your server you may need to use different value, like in Mbs or Kbs in your find command.

REFERENCES

Thursday, March 22, 2012

Why are docx, xlsx, pptx downloading from webserver as zip files?

— SkyHi @ Thursday, March 22, 2012
The server doesn't have proper mime types set up for the new ms file types
add the following to the /etc/mime.types file and restart apache and the problem should be fixed.
# Added by myname 2009-06-03
application/vnd.ms-word.document.macroEnabled.12                        docm
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
application/vnd.ms-powerpoint.template.macroEnabled.12                  potm
application/vnd.openxmlformats-officedocument.presentationml.template   potx
application/vnd.ms-powerpoint.addin.macroEnabled.12                     ppam
application/vnd.ms-powerpoint.slideshow.macroEnabled.12                 ppsm    
application/vnd.openxmlformats-officedocument.presentationml.slideshow  ppsx
application/vnd.ms-powerpoint.presentation.macroEnabled.12              pptm
application/vnd.openxmlformats-officedocument.presentationml.presentation       pptx
application/vnd.ms-excel.addin.macroEnabled.12                          xlam
application/vnd.ms-excel.sheet.binary.macroEnabled.12                   xlsb
application/vnd.ms-excel.sheet.macroEnabled.12                          xlsm
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet       xlsx    
application/vnd.ms-excel.template.macroEnabled.12                       xltm    
application/vnd.openxmlformats-officedocument.spreadsheetml.template    xltx











REFERENCES
http://serverfault.com/questions/19060/why-are-docx-xlsx-pptx-downloading-from-webserver-as-zip-files

Thursday, March 1, 2012

Howto: Performance Benchmarks a Webserver Howto

— SkyHi @ Thursday, March 01, 2012
You can benchmark Apache, IIS and other web server with apache benchmarking tool called ab. Recently I was asked to performance benchmarks for different web servers.
It is true that benchmarking a web server is not an easy task. From how to benchmark a webserver:
First, benchmarking a web server is not an easy thing. To benchmark a web server the time it will take to give a page is not important: you don't care if a user can have his page in 0.1 ms or in 0.05 ms as nobody can have such delays on the Internet.
What is important is the average time it will take when you have a maximum number of users on your site simultaneously. Another important thing is how much more time it will take when there are 2 times more users: a server that take 2 times more for 2 times more users is better than another that take 4 times more for the same amount of users."
Here are few tips to carry out procedure along with an example:

Apache Benchmark Procedures

  • You need to use same hardware configuration and kernel (OS) for all tests
  • You need to use same network configuration. For example, use 100Mbps port for all tests
  • First record server load using top or uptime command
  • Take at least 3-5 readings and use the best result
  • After each test reboot the server and carry out test on next configuration (web server)
  • Again record server load using top or uptime command
  • Carry on test using static html/php files and dynamic pages
  • It also important to carry out test using the Non-KeepAlive and KeepAlive (the Keep-Alive extension to provide long-lived HTTP sessions, which allow multiple requests to be sent over the same TCP connection) features
  • Also don't forget to carry out test using fast-cgi and/or perl tests

Webserver Benchmark Examples:

Let us see how to benchmark a Apache 2.2 and lighttpd 1.4.xx web server.

Static Non-KeepAlive test for Apache web server

i) Note down server load using uptime command
$ uptime
ii) Create a static (small) html page as follows (snkpage.html) (assuming that server IP is 202.54.200.1) in /var/www/html (or use your own webroot):
PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


Webserver test


This is a webserver test page.


 
Login to Linux/bsd desktop computer and type following command:
$ ab -n 1000 -c 5 http://202.54.200.1/snkpage.html
Where,
  • -n 1000: ab will send 1000 number of requests to server 202.54.200.1 in order to perform for the benchmarking session
  • -c 5 : 5 is concurrency number i.e. ab will send 5 number of multiple requests to perform at a time to server 202.54.200.1
For example if you want to send 10 request, type following command:
$ ab -n 10 -c 2 http://www.somewhere.com/
Output:
This is ApacheBench, Version 2.0.41-dev <$Revision: 1.141 $> apache-2.0
Copyright (c) 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright (c) 1998-2002 The Apache Software Foundation, http://www.apache.org/
Benchmarking www.cyberciti.biz (be patient).....done
Server Software:
Server Hostname:        www.somewhere.com
Server Port:            80
Document Path:          /
Document Length:        16289 bytes
Concurrency Level:      1
Time taken for tests:   16.885975 seconds
Complete requests:      10
Failed requests:        0
Write errors:           0
Total transferred:      166570 bytes
HTML transferred:       162890 bytes
Requests per second:    0.59 [#/sec] (mean)
Time per request:       1688.597 [ms] (mean)
Time per request:       1688.597 [ms] (mean, across all concurrent requests)
Transfer rate:          9.59 [Kbytes/sec] received
Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:      353  375  16.1    386     391
Processing:  1240 1312  52.1   1339    1369
Waiting:      449  472  16.2    476     499
Total:       1593 1687  67.7   1730    1756
Percentage of the requests served within a certain time (ms)
  50%   1730
  66%   1733
  75%   1741
  80%   1753
  90%   1756
  95%   1756
  98%   1756
  99%   1756
 100%   1756 (longest request)
Repeat above command 3-5 times and save the best reading.

Static Non-KeepAlive test for lighttpd web server

First, reboot the server:
# reboot
Stop Apache web server. Now configure lighttpd and copy /var/www/html/snkpage.html to lighttpd webroot and run the command (from other linux/bsd system):
$ ab -n 1000 -c 5 http://202.54.200.1/snkpage.html
c) Plot graph using Spreadsheet or gnuplot.

How do I carry out Web server Static KeepAlive test?

Use -k option that enables the HTTP KeepAlive feature using ab test tool. For example:
$ ab -k -n 1000 -c 5 http://202.54.200.1/snkpage.html
Use the above procedure to create php, fast-cgi and dynmic pages to benchmarking the web server.
Please note that 1000 request is a small number you need to send bigger (i.e. the hits you want to test) requests, for example following command will send 50000 requests :
$ ab -k -n 50000 -c 2 http://202.54.200.1/snkpage.html

How do I save result as a Comma separated value?

Use -e option that allows to write a comma separated value (CSV) file which contains for each percentage (from 1% to 100%) the time (in milliseconds) it took to serve that percentage of the requests:
$ ab -k -n 50000 -c 2 -e apache2r1.cvs http://202.54.200.1/snkpage.html

How do I import result into excel or gnuplot programs so that I can create graphs?

Use above command or -g option as follows:
$ ab -k -n 50000 -c 2 -g apache2r3.txt http://202.54.200.1/snkpage.html
Put following files in your webroot (/var/www/html or /var/www/cgi-bin) directory. Use ab command.

Sample test.php file

#!/usr/bin/perl
$command=`perl -v`;
$title = "Perl Version";
 
print "Content-type: text/html\n\n";
print "$title\n\n\n";
 
print "

$title

  \n"
; print $command;   print "\n\n";  
Run ab command as follows:
$ ab -n 3000 -c 5 http://202.54.200.1/cgi-bin/test.pl

Sample psql.php (php+mysql) file

Php+MySQL


   $link = mysql_connect("localhost", "USERNAME", "PASSWORD");
   mysql_select_db("DATABASE");
 
   $query = "SELECT * FROM TABLENAME";
   $result = mysql_query($query);
 
   while ($line = mysql_fetch_array($result))
   {
      foreach ($line as $value)
       {
         print "$value\n";
      }
   }
 
    mysql_close($link);
?>


 
Run ab command as follows:
$ ab -n 1000 -c 5 http://202.54.200.1/psql.php

Featured Articles:



Here is a way to let ab produce a CSV file that covers a range of concurrencies (like 0-1,000), saving you the hurdle of running ab 1,000 times (and merging results).
It has been used to benchmark Apache, IIS 5.1 and 7.0, Nginx, Cherokee, Rock and TrustLeap G-WAN, see:
You just have then to import the CSV file into Open Office to generate Charts!



REFERENCES
http://www.cyberciti.biz/tips/howto-performance-benchmarks-a-web-server.html