Creating Innovation in SMB Technology

Menu

Tag Archives: Apache2

I just completed the lovely process of modifying the Apache FTP module so that it would work on httpd2.4. The current versions of mod_ftp on the repository are built for apache2.2. Between version 2.2 and 2.4 there were a few changes to the core API, which means the modules need to be updated to work with the new API. To update the current module, you need to make 3 general changes.

Basically you will need to do the following:

1) First uninstall and delete your current version of mod_ftp. If you haven’t yet installed mod_ftp, good, otherwise if you have, save your configuration file before you uninstall so that it won’t need to be recreated.

2) Get a complete version of mod_ftp from the repository. I used the trunk (version 1.0.1) when doing my install.

3) Configure with apxs

4) Modify the source files for the new API by replacing all instances of ‘remote_ip’ with ‘client_ip’ and all instances of ‘remote_addr’ with ‘client_addr’.

5) Add a new data structure to the ftp_data_connections.c file. Directly before the ftp_open_dataconn function add the following code.

The Apache2 web server has two mods which can be used to compress data sent to the client (ie browser); mod_deflate and mod_gzip. The gzip mod is more versatile but more challenging to setup. For simple compression of HTML, CSS and JavaScript files, the deflate mod works just file.

Compression is particularly important on Amazon Web Services (AWS) because:

HTML is very redundant and bulky

Smaller files are sent to the client faster

AWS charges you based upon OUTPUT bandwidth; smaller files = less bandwidth usage per file

Simple activation of mod_deflate

These instructions assume you have already setup an AWS instance and have an SSH client (like PuTTY) available and a SCP client (like WinSCP) to use when editing the configuration files.

Log in to your instance via the SCP client then open the apache2 virtual hosts configuration file (“/etc/httpd/conf.d/vhosts.conf” for the default setup mentioned in other instructions here).

Add the “AddOutputFilterByType DEFLATE text/html text/plain text/xml” Filter to each virtual host (virtual hosts are the groupings starting with “<VirtualHost “). You should inclose the filter in a conditional module statement (“<IfModule xxxx.x>”) to make sure your web server keeps running even if you happen to remove the deflate module.

This is actually really easy, assuming you are using the base version of PHP (5.3.X) from the AWS package repository. YUM has phpMyAdmin as a package and most of the default settings work just fine. The first time I install on an AWS instance it took maybe 15 minutes to complete.

Installing phpMyAdmin

These instructions assume you have already setup an AWS instance and have an SSH client (like PuTTY) available and a SCP client (like WinSCP) to use when editing the configuration files.

Log in to your instance via the SSH client. Transfer to the root user (“sudo su”).

Use YUM to install phpMyAdmin

Press “Y” when it asks if you want to install phpMyAdmin

Open the SCP client and go to the apache2 configuration files directory (default is “/etc/httpd/conf.d”)

Open the “phpMyAdmin.conf” file.

Add an access exception to apache2 authentication protocol. There are three safe ways to allow access to phpMyAdmin;

Allow Exception from a static IP Address Under the Directory tag “/usr/share/phpMyAdmin/”, add the following line at the end of the <IfModule mod_authz_core.c><RequreAny> tag, “Require ip XXX.XXX.XXX.XXX” and the following line at the end of the <IfModule !mod_authz_core.c> tag, “Allow from XXX.XXX.XXX.XXX”. In each situation you should be replace XXX.XXX.XXX.XXX with the actual IP address.

Allow access from a VPN You will need a Virtual Private Network setup already, which is well beyond these instructions. Under the Directory tag “/usr/share/phpMyAdmin/”, add the following line at the end of the <IfModule mod_authz_core.c><RequreAny> tag, “Require ip XXX.XXX.XXX.XXX” and the following line at the end of the <IfModule !mod_authz_core.c> tag, “Allow from XXX.XXX.XXX.XXX”. In each situation you should be replace XXX.XXX.XXX.XXX with the actual IP address.

Use SSL Certificate for authentication These instructions are not complete yet.

First few lines of phpMyAdmin.conf file with default installation path, edited for access by a single IP address

# phpMyAdmin – Web based MySQL browser written in php
#
# Allows only localhost by default
#
# But allowing phpMyAdmin to anyone other than localhost should be considered
# dangerous unless properly secured by SSL

Go down to the line “$cfg[‘blowfish_secret’] = ‘XXXXXXXX’;” where XXXXXX is some alphanumeric combination. Add a bunch more letters and numbers within the single quotes.

Go down to the line “$cfg[‘Servers’][$i][‘controlhost’]” and make sure it is uncommented. After it, add “= ‘localhost’;”

The next line should be “$cfg[‘Servers’][$i][‘controluser’]”and make sure it is uncommented. After it, add “= ‘USERNAME’;” where USERNAME is the username you want to log into phpMyAdmin using.

The next line should be “$cfg[‘Servers’][$i][‘controlpass’]”and make sure it is uncommented. After it, add “= ‘PASSWORD’;” where PASSWORD is the password associated with the previously entered username.

Save the file as “config.inc.php”.

Use YUM to install phpMyAdmin

Press “Y” when it asks if you want to install phpMyAdmin

Open the SCP clint and go to the apache2 configuration files directory (default is “/etc/httpd/conf.d”)

Open the “phpMyAdmin.conf” file.

Direct your browser to “http://XXX.XXX.XXX.XXX/phpMyAdmin&#8221; where XXX.XXX.XXX.XXX is the IP address of your server. You should be prompted for a username and login. Enter the pair you just saved in the config file and you should run phpMyAdmin.

There is a variety of software you will need to get your new AWS web server up and running. You probably already have the desktop clients if you every did any server work previously, the core server software however will need to be installed, depending on your purposes for the server.

This page will be updated from time to time as new installation and configuration guides are added.

I am bias to Windows software. All of these programs run on Windows XP and Windows 7 (32-bit & 64-bit systems). If you are running a Linux or Mac system….well…they may work. The program’s name link will go to instructions on configuring the software to access your AWS Instance.

Core Server Software

Software

Usage

Description

Documentation

Apache2

Website hosting

The basic web server which deals with internet (http/https) traffic to the server.

Note all of these programs are free, and most are open source. All of the installation instructions are specific to the Amazon Linux AMI. This stripped down version of Linux is a special Amazon derivative of Fedora. When I was originally setting up our servers, some of the differences between RedHat, Ubuntu, Debian and this version of Linux drove me crazy, therefore all of these instructions worked on the newest Amazon Linux AMI version (currently 2012.03).