Web server Tutorials

PHP Memory Limit and htaccess

The PHP memory limit will need to changed sooner or later as we start writing and running more resource intensive scripts. The idea of a memory limit is important on a web server since the server may be serving many requests at a given time, and we wouldn't want any one request or script consuming too many resources. Also, it is useful to limit how much memory a script can consume in a setting (like a VPS) where resources like RAM are limited.

Count search engine referrals using web server logs and shell commands

Suppose you want to know how much of your website traffic comes from Google or another search engine. It's very easy if you use Awstats or Google analytics, but what if you haven't configured these tools? Using only the web server log files and some shell commands will enable us to quickly parse log files and give a count of how many referrals we had from a search engine.

For the purposes of this tutorial, we will be assuming an Apache web server, and that the search engine that we are counting the referrals from is Google.

Use cron to run PHP script

Using a cron job to run a PHP script is very easy if you know how. If we recall, cron is a Unix/Linux utility that is used to perform tasks at specified intervals. By setting up a cron job with the appropriate parameters, we can get our system to execute PHP scripts or any other kind of script.

Apache compiled in modules

Apache is a very well-designed and modular web server. Its power and convenience partly comes from its ability to use various modules, and the ease in which these modules can be changed as necessary. Specific modules can be compiled into the server when it is being built so that a web server suited for a particular task is ready out of the box.

Most times, we are not the ones who have compiled Apache so we have no way to immediately know what modules have been compiled into it. Coming to our rescue is a simple command we can execute to determine Apache's compiled modules.

Check Apache version on Ubuntu linux

To ensure that we have the latest version of the Apache web server running, we need to perform a check on our current version. In the tutorial below, we will demonstrate how easy it is to check our Apache version on Ubuntu or other similar modern flavour of Linux.

To check what version of Apache we have running, we can open a terminal and execute the following command:

apache2 -v

We invoke the apache2 binary which is located at /usr/sbin/apache2 (by default in Ubuntu 10.04 LTS) and tell it that we want to know the current version.

Ignore IP Address Awstats

In this tutorial, we will learn how to ignore or exclude specific IP addresses from our Awstats data. When set up, Awstats parses our server log files and generates detailed reports of user locations, IP addresses, referrers, and so on. Awstats can be used to give an excellent idea of where your visitors are coming from, how they got to your site, and what they are looking on once on your site.

Using this information will allow a webmaster to fine-tune aspects of his or her site for maximum user satisfaction.

Using wget and an XML Sitemap to Spider website - Keeping the Drupal cache warm

This tutorial will speak in the context of using this technique on a website which uses Drupal for content management. This technique need not be limited to a Drupal website and should work well if adapted properly.

Hide Apache and PHP Version and Signatures in Ubuntu Linux

By default, your Apache web server (and PHP if it is installed) will indicate to clients the exact version of the Apache software which is running. This version information can be seen in the HTTP response header.

Enable Compression on Apache with mod_deflate

Enabling compression on Apache is a trade-off between CPU load and bandwidth. It is usually faster to compress content as more time is saved when transferring a smaller file as opposed to the minimum CPU time which is required to compress the data in the first place. We first need to enable mod_deflate. This is the module which handles the compression of the data.

On modern Linux versions with Apache 2:

a2enmod deflate

On Windows edit the "httpd.conf" file and uncomment the following line like so: