Skip to content

Downes/docker-lamp

 
 

Repository files navigation

downes/lamp

This is a fork of furia/lamp (full Readme below). It adds Perl to the set of supported environments, and sets up a cgi-bin directory at /var/www/html/cgi-bin. The Maria database (mysql) is loaded, a database is created with a test user, and Perl access to the database is created and tested. Run cgi-bin/server_test.cgi to test all Perl functions.

Docker image is here: https://hub.docker.com/r/downes/docker-lamp

The complete story of how I built the image: https://halfanhour.blogspot.com/2020/09/boxing-grsshopper.html

To run:

docker pull downes/docker-lamp

docker run --publish 80:80 --detach --name bb3 downeslamp

OR, run from thw GitHub repository as follows:

Process:

git clone  https://github.com/Downes/docker-lamp
    (or git pull origin master if reloading the changed repo)
cd docker-lamp

docker build --tag downeslamp .

docker run --publish 80:80 --detach --name bb3 downeslamp

Testing the server

http://localhost (should show Apache index page)

http://localhost/index.php (should show PHP index page)

http://localhost/cgi-bin/server_test.cgi (should show Perl test page)

If Perl CGI isn't running properly, try:

docker exec -it bb3 /etc/init.d/apache2 reload

(you can't docker exec -it bb3 apache2ctl restart because it crashes the entire container - see https://stackoverflow.com/questions/37523338/how-to-restart-apache2-without-terminating-docker-container )

( if you crash it, docker start bb3 )

Open a shell inside

docker exec -i -t bb3 bash

What I've changed from furia/lamp

Dockerfile:

Inserted the following lines (this is just a starter, I'll be adding more later):

RUN apt-get install -y \

      libcgi-session-perl \
      
      libwww-perl \
      
      libmime-types-perl \
      
      libjson-perl \
      
      libjson-xs-perl \
      
      libtypes-datetime-perl \
      
      libmime-lite-tt-html-perl

RUN a2enmod cgid 

RUN rm -f /etc/apache2/conf-available/serve-cgi-bin.conf 

COPY cgi-enabled.conf /etc/apache2/conf-available/

RUN mkdir /var/www/html/cgi-bin

RUN a2enconf cgi-enabled 


COPY index.php /var/www/html/

COPY server_test.cgi /var/www/html/cgi-bin

RUN chmod 705 /var/www/html/cgi-bin/server_test.cgi

COPY run-lamp.sh /usr/sbin/

COPY grsshopper.sql /var/www/html/cgi-bin/grsshopper.sql

RUN /bin/bash -c "/usr/bin/mysqld_safe &" && \

  sleep 5 && \
  
  mysql -u root -e "CREATE DATABASE grsshopper" && \
  
  mysql -u root -e "grant all privileges on grsshopper.* TO 'grsshopper_user'@'localhost' identified by 'user_password'" && \
  
  mysql -u root grsshopper < /var/www/html/cgi-bin/grsshopper.sql
  

Also:

  • remove existing serve-cgi-bin.conf because it redirects cgi-bin to /usr/lib/cgi-bin

  • Created cgi-enabled.conf to set up cgi-bin configuration

  • Created server_test.cgi which tests Perl modules

  • Created grsshopper.sql as a test database with one table in it

fauria/lamp

docker_logodocker_fauria_logo

Docker Pulls Docker Build Status

This Docker container implements a last generation LAMP stack with a set of popular PHP modules. Includes support for Composer, Bower and npm package managers and a Postfix service to allow sending emails through PHP mail() function.

If you dont need support for MySQL/MariaDB, or your app runs on PHP 5.4, maybe fauria/lap suits your needs better.

Includes the following components:

  • Ubuntu 16.04 LTS Xenial Xerus base image.
  • Apache HTTP Server 2.4
  • MariaDB 10.0
  • Postfix 2.11
  • PHP 7
  • PHP modules
    • php-bz2
    • php-cgi
    • php-cli
    • php-common
    • php-curl
    • php-dbg
    • php-dev
    • php-enchant
    • php-fpm
    • php-gd
    • php-gmp
    • php-imap
    • php-interbase
    • php-intl
    • php-json
    • php-ldap
    • php-mcrypt
    • php-mysql
    • php-odbc
    • php-opcache
    • php-pgsql
    • php-phpdbg
    • php-pspell
    • php-readline
    • php-recode
    • php-snmp
    • php-sqlite3
    • php-sybase
    • php-tidy
    • php-xmlrpc
    • php-xsl
  • Development tools
    • git
    • composer
    • npm / nodejs
    • bower
    • vim
    • tree
    • nano
    • ftp
    • curl

Installation from Docker registry hub.

You can download the image using the following command:

docker pull fauria/lamp

Environment variables

This image uses environment variables to allow the configuration of some parameteres at run time:

  • Variable name: LOG_STDOUT
  • Default value: Empty string.
  • Accepted values: Any string to enable, empty string or not defined to disable.
  • Description: Output Apache access log through STDOUT, so that it can be accessed through the container logs.

  • Variable name: LOG_STDERR
  • Default value: Empty string.
  • Accepted values: Any string to enable, empty string or not defined to disable.
  • Description: Output Apache error log through STDERR, so that it can be accessed through the container logs.

  • Variable name: LOG_LEVEL
  • Default value: warn
  • Accepted values: debug, info, notice, warn, error, crit, alert, emerg
  • Description: Value for Apache's LogLevel directive.

  • Variable name: ALLOW_OVERRIDE
  • Default value: All
  • All, None
  • Accepted values: Value for Apache's AllowOverride directive.
  • Description: Used to enable (All) or disable (None) the usage of an .htaccess file.

  • Variable name: DATE_TIMEZONE
  • Default value: UTC
  • Accepted values: Any of PHP's supported timezones
  • Description: Set php.ini default date.timezone directive and sets MariaDB as well.

  • Variable name: TERM
  • Default value: dumb
  • Accepted values: dumb
  • Description: Allow usage of terminal programs inside the container, such as mysql or nano.

Exposed port and volumes

The image exposes ports 80 and 3306, and exports four volumes:

  • /var/log/httpd, containing Apache log files.
  • /var/log/mysql containing MariaDB log files.
  • /var/www/html, used as Apache's DocumentRoot directory.
  • /var/lib/mysql, where MariaDB data files are stored.
  • /etc/apache2, where Apache configuration files are stored.

Please, refer to https://docs.docker.com/storage/volumes for more information on using host volumes.

The user and group owner id for the DocumentRoot directory /var/www/html are both 33 (uid=33(www-data) gid=33(www-data) groups=33(www-data)).

The user and group owner id for the MariaDB directory /var/log/mysql are 105 and 108 repectively (uid=105(mysql) gid=108(mysql) groups=108(mysql)).

Use cases

Create a temporary container for testing purposes:

	docker run -i -t --rm fauria/lamp bash

Create a temporary container to debug a web app:

	docker run --rm -p 8080:80 -e LOG_STDOUT=true -e LOG_STDERR=true -e LOG_LEVEL=debug -v /my/data/directory:/var/www/html fauria/lamp

Create a container linking to another MySQL container:

	docker run -d --link my-mysql-container:mysql -p 8080:80 -v /my/data/directory:/var/www/html -v /my/logs/directory:/var/log/httpd --name my-lamp-container fauria/lamp

Get inside a running container and open a MariaDB console:

	docker exec -i -t my-lamp-container bash
	mysql -u root

About

🐳 Docker container running the latest version of the LAMP stack.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Perl 47.0%
  • Dockerfile 32.7%
  • Shell 18.4%
  • PHP 1.9%