~$ sudo apt-get


Install PHP Modules via PECL

by on Jan.13, 2010, under Apache, PHP

First, mount the /tmp partition with exec permissions.

mount -o remount,exec /tmp

To install a package via pecl, run the following.

pecl install ssh2
(If the package is in a state other than stable, append the state after the package name ‘pecl install ssh2-beta’)

Last few lines of the module install will list the location of the library, usually /usr/lib/php/modules. Create a ini file with the module name within /etc/php.d/ with the extension directive.

# cat /etc/php.d/gd.ini
; Enable gd extension module

At this point, run the mount command to reestablish noexec for the /tmp partition.

mount -o remount,noexec /tmp

Gracefully restart apache and you are done.

Leave a Comment more...

Urchin : Unable to retrieve local file listing / Permission denied

by on Dec.10, 2009, under Apache, Linux

A common issue with occurs when apache is updated. Red Hat Enterprise Linux will revert /var/log/httpd to 0755 with root:root as ownership resulting in the following error.

WARNING: (****-****-****) Unable to retrieve local file listing
DETAIL: /var/log/httpd/access_log : Permission denied

A temporary fix until the next apache update, which are few and far between, is to ‘chmod 0755 /var/log/httpd’. Then ensure the current access logs are readable to the urchin user, 0644 should work. A permanent work around is to specify a log directory that will not be touched by the httpd rpm and give urchin sufficient permissions to access it.

Leave a Comment more...

Force SSL with mod_rewrite

by on Oct.15, 2009, under Apache, Linux

Create a .htaccess within the document root with the following.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

You must ensure AllowOverride is set to All within the apache configuration or it will not read the .htaccess.

Leave a Comment more...

Total memory usage by Apache processes

by on May.13, 2009, under Apache, Linux, Server

ps ax | grep httpd | awk '{ print $1 }' | xargs pmap -x | awk '{ SUM += $2 } END { print SUM }'
Leave a Comment more...

Summarize concurrent HTTP connections

by on Apr.01, 2009, under Apache, Linux

This will display how many different IPs are connected to the server via port 80.

netstat -plant | grep "insertIPhere:80" | awk '{ print $5 }' | cut -d ":" -f 1 | sort | uniq | wc -l

Modifying the previous slightly allows us to display, in descending order, all the IPs connecting on port 80 and how many active connections they have.

netstat -plant | grep "-insertIPhere:80" | awk '{ print $5 }' | cut -d ":" -f 1 | sort | uniq -c | sort -rn
Leave a Comment more...

Modified Apache Summary – Top 100 Files and IPs

by on Mar.27, 2009, under Apache, Linux

TOPFILES=100;TOPIPS=100;DATE=`date +%d.%b.%Y:%H`;for i in `lsof -p $(netstat -ltpn|awk '$4 ~ /:80$/ {print 
substr($7,1,index($7,"/")-1)}'|head -1)| awk '$9 ~ /access.log$/ {print $9| "sort -u"}'` ;  do echo "-------"$i"------"$DATE; 
awk '$4 ~ /^.'$DATE'/ {day=substr($4,2,2);hour=substr($4,14,2);sixth=substr($4,17,1); 
hit[day"t"hour"."sixth"0 - "hour"."sixth"9"]++;ip[$1]++;bytes[day"t"hour"."sixth"0 - "hour"."sixth"9"]+=$10; 
flds=split($7, req, ///);toss=split(req[flds],fn,/?/);files[fn[1]]++ } END { for (i in hit) 
{ print hit[i]"t"i"t"sprintf("%2.2d",bytes[i]/1024)"K"|"sort -k 3,3n"}; print "";for (i in ip) { if(ip[i] > '$TOPIPS') 
{ print ip[i]"t"i|"sort -n;echo """}}; for (i in files) { if(files[i] > '$TOPFILES') {print files[i], i|"sort -k 1,1n;echo """}} }' 

Original one-liner would not work with directives specifying IPs to listen on versus

Leave a Comment more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...