Archive for the “Apache” Category

You can use the following command to list all the loaded modules in apache (both DSO and Static)
———-

 

# apachectl -t -D DUMP_MODULES

 

———-

The output will be something like
———
dir_module (static)
actions_module (static)
userdir_module (static)
alias_module (static)
rewrite_module (static)
so_module (static)
auth_passthrough_module (shared)
bwlimited_module (shared)
php5_module (shared)
fcgid_module (shared)
proxy_module (shared)

Comments No Comments »

According to Apache’s web site for FAQ:

Why the name “Apache”?
The name ‘Apache’ was chosen from respect for the Native American Indian tribe of Apache (Indé), well-known for their superior skills in warfare strategy and their inexhaustible endurance. For more information on the Apache Nation, we suggest searching Google, or AllTheWeb.

Secondarily, and more popularly (though incorrectly) accepted, it’s a considered cute name which stuck. Apache is “A PAtCHy server”. It was based on some existing code and a series of “patch files

I find the use of ‘it’s a patchy server’ to be a misnomer as it could apply to any type of server, whether running apache or not. Check your sources people.

Comments No Comments »

Looking through my server commands, there was a command called ‘ab’ that caught my eye. The command stands for ‘Apache Benchmark’ and it is a benchmarking tool for your webserver. Having never run a bench mark on my server I thought that this was a perfect opportunity to do so.

The command is designed to simulate a bunch of requests to your webserver from whatever machine you’re running the test from.

Syntax

ab [options] [http[s]://]hostname[:port]/path

Looking at the man page will give you the available options. you will need to use the ‘-n’ and ‘-c’ options. The ‘-n’ option indicates the number of requests to make, and the ‘-c’ options indicates how many of the connections should be concurrent. It states that it uses 1 as the default for concurrency, but when I kept getting errors when I left that option off. The command issued to benchmark my server was:

ab -n 1000 -c 5 http://www.8bitpipe.com/

The command give  you nice little updates after every 100 attempts. At the end of the test it will display a report giving you a range of times that the requests fall within. It is worth noting that you should be aware of the type of connection you have to the internet, any latency on your localnet will affect the test. As you may remember, I have a horrible connection to the internet and running the test from my local machine produced terrible results:

[root@localhost]# ab -n 1000 -c 5 http://www.8bitpipe.com/
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking www.8bitpipe.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Completed 1000 requests
Finished 1000 requests

Server Software:        Apache
Server Hostname:        www.8bitpipe.com
Server Port:            80

Document Path:          /
Document Length:        42100 bytes

Concurrency Level:      5
Time taken for tests:   3819.611 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      42279000 bytes
HTML transferred:       42100000 bytes
Requests per second:    0.26 [#/sec] (mean)
Time per request:       19098.054 [ms] (mean)
Time per request:       3819.611 [ms] (mean, across all concurrent requests)
Transfer rate:          10.81 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        2    8   5.2      7      51
Processing:  1690 19068 12676.4  15300  128973
Waiting:     1640 15453 5923.0  15252   24723
Total:       1694 19076 12676.3  15308  128977

Percentage of the requests served within a certain time (ms)
50%  15308
66%  19737
75%  25082
80%  25726
90%  34978
95%  42059
98%  49926
99%  65594
100%  128977 (longest request)

Compare this to a remote server that has a better connection:

[root@remotehost]# ab -n 1000 -c 5 http://www.8bitpipe.com/
This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Copyright 2006 The Apache Software Foundation, http://www.apache.org/

Benchmarking www.8bitpipe.com (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
Completed 500 requests
Completed 600 requests
Completed 700 requests
Completed 800 requests
Completed 900 requests
Finished 1000 requests

Server Software:        Apache
Server Hostname:        www.8bitpipe.com
Server Port:            80

Document Path:          /
Document Length:        42100 bytes

Concurrency Level:      5
Time taken for tests:   39.341961 seconds
Complete requests:      1000
Failed requests:        0
Write errors:           0
Total transferred:      42279000 bytes
HTML transferred:       42100000 bytes
Requests per second:    25.42 [#/sec] (mean)
Time per request:       196.710 [ms] (mean)
Time per request:       39.342 [ms] (mean, across all concurrent requests)
Transfer rate:          1049.46 [Kbytes/sec] received

Connection Times (ms)
min  mean[+/-sd] median   max
Connect:        0    0   1.7      0      20
Processing:   129  195  38.1    189     495
Waiting:       58   89  22.9     85     295
Total:        129  195  38.1    189     495

Percentage of the requests served within a certain time (ms)
50%    189
66%    204
75%    216
80%    225
90%    247
95%    265
98%    285
99%    303
100%    495 (longest request)

That is much better. Don’t forget to run this on a regular basis to get the trends of your server response. Hopefully this will help keep your little portion of the internet more responsive.

Further Reading:

Howto Performance Benchmark a Web Server

Howto Benchmark

Comments No Comments »

Given a common log format, the following one-liner calculates the bandwidth used per IP from the Apache logs. and does it pretty darn quickly – under 2 seconds for a 200-MB file.


# awk ‘{array[$1]+=$10} END { for ( item in array ) print
array[item]/1048576 “MB”, item }’ access_log.processed | sort -n


Omit the -n argument to sort if you want the largest numbers to appear at the top of the output.

It generates output that looks like the following:


1.00981MB 66.249.71.109
1.13482MB 129.188.33.27
1.13523MB 95.108.150.241
1.1675MB 151.151.109.22
1.19112MB 12.213.224.36
1.27849MB 82.44.133.226
1.3791MB 66.249.71.39
1.45494MB 38.105.83.11
1.4975MB 207.200.116.6
1.68302MB 88.131.106.30


Comments No Comments »

Creating a Self Signed Certificate is actually pretty easy, there are a number of web sites out there that you can use to create a certificate. I’m not going to post one cause it would be unsecure to have a 3rd party you don’t trust create a key and certificate file.

There is an excellent article on how to create a Self Signed Certificate at “How to create a self-signed SSL Certificate“. If you can go all the way through that without looking for a new page, you should be well versed in creating a Self Signed Certificate. I prefer the following command:

# openssl req -new -newkey rsa:1024 -days 365 -nodes -x509 -keyout server.key -out server.crt

It is going to ask you the following questions to generate the certificate:

Country Name (2 letter code) [GB]:US
State or Province Name (full name) [Berkshire]:Washington
Locality Name (eg, city) [Newbury]:Seattle
Organization Name (eg, company) [My Company Ltd]:8 Bit Pipe
Organizational Unit Name (eg, section) []:Blog
Common Name (eg, your name or your server’s hostname) []:www.8bitpipe.com
Email Address []:styles@8bitpipe.com

Please note that the common name is the name of the domain you want to create the certificate for. Now all you have to do is move the certificate and key file to where you need them to be. I apologize if this is too short for you, but you are more than welcome to follow the instructions on other sites.

Comments 1 Comment »

Wow, multiple posts in the same month. Watch out, I may actually start buying into this blogging thing. So I was looking for a way to mask the header information that the server sends. Well I found this nice article explaining how to set headers if you have mod_headers installed. Well I checked and I did, I verified I had a version of apache to be able to make the change. It was a simple one liner in the httpd.conf file, but for some reason, it didn’t work. Yes, I restarted apache after the change. Well, after looking at some more articles, which said exactly the same thing, I got disheartened.

I did find a post on http://www.fatofthelan.com/ that talked about Server tokens. This masks some of the header information, but not all of it. Here the explanation for it:

ServerTokens Prod[uctOnly]
Server sends (e.g.): Server: Apache

ServerTokens Min[imal]
Server sends (e.g.): Server: Apache/1.3.0

ServerTokens OS
Server sends (e.g.): Server: Apache/1.3.0 (Unix)

ServerTokens Full (or not specified)
Server sends (e.g.): Server: Apache/1.3.0 (Unix) PHP/3.0 MyMod/1.2

By default, apache has it set to ‘ ServerTokens OS’. This change at least hides some of your header infomation. You can find the explanation here:

http://httpd.apache.org/docs/1.3/mod/core.html#servertokens

Comments No Comments »

  • 100 – Continue
  • 101 – Switching Protocols

Successful

  • 200 – OK
  • 201 – Created
  • 202 – Accepted
  • 203 – Non-Authoritative Information
  • 204 – No Content
  • 205 – Reset Content
  • 206 – Partial Content

Redirection

  • 300 – Multiple Choices
  • 301 – Moved Permanently
  • 302 – Found
  • 303 – See Other
  • 304 – Not Modified
  • 305 – Use Proxy
  • 307 – Temporary Redirect

Client Error

  • 400 – Bad Request
  • 401 – Unauthorized
  • 402 – Payment Required
  • 403 – Forbidden
  • 404 – Not Found
  • 405 – Method Not Allowed
  • 406 – Not Acceptable
  • 407 – Proxy Authentication Required
  • 408 – Request Timeout
  • 409 – Conflict
  • 410 – Gone
  • 411 – Length Required
  • 412 – Precondition Failed
  • 413 – Request Entity Too Large
  • 414 – Request-URI Too Long
  • 415 – Unsupported Media Type
  • 416 – Requested Range Not Satisfiable
  • 417 – Expectation Failed

Server Error

  • 500 – Internal Server Error
  • 501 – Not Implemented
  • 502 – Bad Gateway
  • 503 – Service Unavailable
  • 504 – Gateway Timeout
  • 505 – HTTP Version Not Supported

OK, so every time a client says that they’re site is not redirection, I have to go check the HTTP status code. There are much better sites with more detailed information. The issue I have is I usually don’t want the detailed information. I usually want a quick list that I don’t have to scroll through. That being said, I have made a short list of the Status Codes. There is more detailed information below or you can seek out the actual RFC 2616 or checkout the most excellent source at wiki.blowbyu.net.

Comments No Comments »