Apache http

Operational sequences and downloads

You require the following operational sequences and download packages for setting up the Apache httpd.

NOTE

Installation security

Ensure that the current version is always used for the installation.

  1. Download the following data packages:

    If your IoT2040 has an Internet connection, call "wget" and download the data packages directly.

    - OR -

    • Download the data packages manually.

    • Copy the data packages to the following directory: /usr/downloads.

  2. Create the directory "/usr/downloads":
    cd /usr
    mkdir downloads
    cd downloads

  3. To download all required packages, execute the following commands:

    Note: Run the following lines as a command:
    wget http://mirror.netcologne.de/apache.org//httpd/httpd-2.4.33.tar.gz wget http://mirror.23media.de/apache//apr/apr-1.6.3.tar.gz wget http://mirror.23media.de/apache//apr/apr-util-1.6.1.tar.gz

    Note: Run the following lines as a command:
    wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.42.tar.gz

Opening packages

To open the packages, execute the following commands in the "/usr/downloads/" directory:
tar zxf httpd-2.4.33.tar.gz
tar zxf apr-1.6.3.tar.gz
tar zxf apr-util-1.6.1.tar.gz
tar zxf pcre-8.42.tar.gz

Storing packages in the appropriate folders

To store the packages in the appropriate folders and to name them correctly, run the following commands in directory "/usr/downloads/":

mkdir --parents /usr/local
mv httpd-2.4.33 apache2
mv apache2 /usr/local/
mv apr-1.6.3 apr
mv apr /usr/local/apache2/srclib/
mv apr-util-1.6.1 apr-util
mv apr-util /usr/local/apache2/srclib/
mv pcre-8.42 pcre
mv pcre /usr/local/

Installing "opkg" and "pcre"

  1. Download and install "opkg".
    opkg install make

  2. Compile and install "pcre".
    Run the following commands in directory "/usr/local/pcre/":
    ./configure --prefix=/usr/local/pcre
    make
    make install

Apache APR - Compiling and installing

NOTE

Error in APR V1.6.3

Because of an error in APR V1.6.3, the compilation of APR causes an error. Edit the file manually to prevent this error.

Further information can be found at: APR.

  • Execute the following instructions.

  • Check whether the error is still present in future APR versions.

  1. Execute the following command:
    cd /usr/local/apache2/srclib/apr/

  2. Create a copy of the original file before you begin editing.
    cp configure configure.original

  3. Replace the
    $RM "$cfgfile" line
    with
    $RM -f "$cfgfile"

  4. Save the change.

  5. Switch to the folder: cd /usr/local/apache2/srclib/apr/
    Run the following commands:
    ./configure --prefix=/usr/local/apr/
    make
    make install
    /usr/local/apache2/srclib/apr/libtool --finish /usr/local/apr/lib/

Compiling and installing Apache APR-util

  1. Switch to the folder: cd /usr/local/apache2/srclib/apr-util/

  2. Execute the following commands:
    ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
    make
    make install

Compiling and installing Apache HTTP server (httpd)

  1. Switch to the folder: cd /usr/local/apache2/

  2. Execute the following command:

    Note: Run the following lines as a command:

    ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr/bin --with-apr-util=/usr/local/apr-util/bin --with-pcre=/usr/local/pcre/bin/pcre-config

    NOTE

    Line breaks

    Retain the line breaks - The preceding lines form a command.

    make
    make install

Starting and stopping Apache Webserver (httpd)

  • Manual start:
    /usr/local/apache2/bin/apachectl start

  • Manual stop:
    /usr/local/apache2/bin/apachectl –k stop

  • Manual restart:
    /usr/local/apache2/bin/apachectl –k graceful

Apache Webserver (httpd) - Configuring autostart

Creating the start file

  1. Switch to the "/etc/init.d/" directory.

  2. Create the "apache2" file.

  3. Enter the following text in the file:

#!/bin/bash

#

# apache2

Startup script for the Apache HTTP server

#

chkconfig:

3 85 15

# description:

Apache is a World Wide Web server.

It is used to serve \

HTML files and CGI.

/usr/local/apache2/bin/apachectl $@

Editing file properties

  1. Enter:
    chmod 755 /etc/init.d/apache2

  2. Execute the following command:
    update-rc.d -f apache2 defaults

Further details can be found at: Apache Autostart