Apache

libphp5.so on Apache 2 is faster than CGI or FastCGI

Why this site loads so fast ? The reason is we are using Apache 2.2.10 with libphp5.so

Earlier we were using CGI.

I also tried PHP-FastCGI

Creating an automatic installer for HTTPD

This tutorial explains how to create a simple shell script with default HTTPD compile options which can install HTTPD just in one command PROVIDED you have sudo and the NOPASSWD: ALL in your username's entry in the sudoers file.

So, here's a script which can do the above task. Please note that you need not rewrite all the options given to configure while compiling first time, you can just take a copy of config.nice script which is created by configure present in the build directory. For instance, if your apache directory is /usr/local/apache2 ; then you'll find config.nice in /usr/local/apache2/build.

Actually I must say this is an extension of the config.nice file as I myself created this using config.nice ;)

Note: I have used config,nice from httpd-2.2.9's compilation, may not work for httpd-1.x or httpd-2.0.x

#!/bin/bash

# Apache Install Script
# Modified version of config.nice

# ------- PARAMETERS REQUIRED -------
# 1st Parameter - Extracted Source code directory

if [ ! $1 ]; then

echo -e "You must pass the first argument as the SOURCE CODE directory\n"

exit 1

fi

SRCDIR=$1

if [ -d $SRCDIR ] && [ $(pwd) != $SRCDIR ]; then

echo -e "Current Working Directory is $(pwd)\n\n"

echo -e "Changing Directory to $SRCDIR\n\n"

cd $SRCDIR &> /dev/null

CD_RETVAL=$?

if [ $CD_RETVAL -ne 0 ]; then

echo -e "Failed to change directory to $SRCDIR\n\n"

exit $CD_RETVAL

fi

fi

# Replacing ./configure from config.nice to $SRCDIR/configure as the configure script is in $SRCDIR
# Parameters for configure taken from config.nice

# configure by default will install in /usr/local/apache2

"$SRCDIR/configure" \
"-C" \
"--build=i686-pc-linux-gnu" \
"--host=i686-pc-linux-gnu" \
"--target=i686-pc-linux-gnu" \
"--enable-mods-shared=authn-file authn-dbm authn-dbd authn-default authn-anon authn-alias authz-host authz-groupfile authz-user authz-dbm authz-owner authz-default auth-basic auth-digest file-cache cache disk-cache mem-cache dbd ext-filter include filter substitute charset-lite deflate log-config log-forensic logio env mime-magic cern-meta expires headers ident usertrack unique-id setenvif version proxy proxy-connect proxy-ftp proxy-http proxy-ajp proxy-balancer ssl mime dav status autoindex asis info cgid cgi suexec dav-fs dav-lock vhost-alias negotiation dir imagemap actions speling userdir rewrite alias" \
"--enable-modules=so" \
"--with-mpm=worker" \
"--with-included-apr" \
"$@"

AUTOCONF_RETVAL=$?

if [ $AUTOCONF_RETVAL -ne 0 ]; then

echo -e "\n\nError\n\n"

exit $AUTOCONF_RETVAL

fi

make -f Makefile

sudo make -f Makefile install

This script will install httpd in /usr/local/apache2

Enjoy! :)

Bugs, if found, shall be posted in comments and the same for any suggested improvements or modifications ;)

Preventing Bandwidth theft by hotlinked images

Tagged:  

Apache Logo

One of the biggest advantage of using Apache (httpd) as your webserver that it is extremely customisable. So here is a simple tutorial about how to prevent bandwidth theft from your image site.

This tutorial uses the mod_setenvif module.

Suppose you have a image subdomain say img.yoursite.com

Now, you want to prevent bandwidth theft. So here's a little step, Its working on my subdomain img.itech7.com, still feedback and more ideas would be appriciated.

#.htaccess (or httpd.conf part) of your subdomain 

SetEnvif Referer yoursite.com yoursite_ref


Deny from All


Allow from env=yoursite_ref

 

Limiting HTTP Upload size

Tagged:  

Ever wondered how to limit the request size in Apache ?

You can do it by the LimitRequestBody directive either in httpd.conf or in .htaccess

The directive accepts the limit value in bytes.

For the geeky, it will limit the size of the HTTP PUT requests.

So it can be done like this -

.htaccess -

LimitRequestBody <size in bytes>

httpd.conf -

<Directory dir>

LimitRequestBody <size in bytes>

</Directory>

 

Syndicate content
All trademarks and copyrights on this page are owned by their respective owners. Comments are owned by the Poster. Rest Copyright © iTech7.com

For License and Copyrights see http://www.itech7.com/Content-Copyrights