Browse Source

Autocuiseur

master
Erase 11 months ago
commit
7a8a3b92de

+ 3
- 0
.gitignore View File

@@ -0,0 +1,3 @@
/.env
/.vscode
.DS_Store

+ 119
- 0
README.md View File

@@ -0,0 +1,119 @@
# LAMP stack built with Docker Compose

This is a basic LAMP stack environment built using Docker Compose. It consists following:

* PHP 7.3
* Apache 2.4
* MySQL 5.7
* phpMyAdmin

## Installation

Clone this repository on your local computer. Run the `docker-compose up -d`.

```shell
git clone https://github.com/BSP-ALIPTIC/docker-lamp-simple-example.git
cd docker-lamp-simple-example
cp sample.env .env
docker-compose up -d
```
Your LAMP stack is now ready!! You can access it via `http://localhost:8081`.

## Configuration

This package comes with default configuration options. You can modify them by creating `.env` file in your root directory.

To make it easy, just copy the content from `sample.env` file and update the environment variable values as per your need.

### Configuration Variables

There are following configuration variables available and you can customize them by overwritting in your own `.env` file.

_**DOCUMENT_ROOT**_

It is a document root for Apache server. The default value for this is `./www`. All your sites will go here and will be synced automatically.

_**MYSQL_DATA_DIR**_

This is MySQL data directory. The default value for this is `./data/mysql`. All your MySQL data files will be stored here.

_**VHOSTS_DIR**_

This is for virtual hosts. The default value for this is `./config/vhosts`. You can place your virtual hosts conf files here.

> Make sure you add an entry to your system's `hosts` file for each virtual host.

_**APACHE_LOG_DIR**_

This will be used to store Apache logs. The default value for this is `./logs/apache2`.

_**MYSQL_LOG_DIR**_

This will be used to store Apache logs. The default value for this is `./logs/mysql`.

## Web Server

Apache is configured to run on port 8081. So, you can access it via `http://localhost:8081`.

#### Apache Modules

By default following modules are enabled.

* rewrite
* headers

> If you want to enable more modules, just update `./bin/webserver/Dockerfile`. You can also generate a PR and we will merge if seems good for general purpose.
> You have to rebuild the docker image by running `docker-compose build` and restart the docker containers.

#### Connect via SSH

You can connect to web server using `docker-compose exec` command to perform various operation on it. Use below command to login to container via ssh.

```shell
docker-compose exec webserver bash
```

## Database

There are following configuration variables available and you can customize them by overwritting in your own .env file.

## PHP

The installed version of PHP is 7.3

#### Extensions

By default following extensions are installed.

* mysqli
* mbstring
* zip
* intl
* mcrypt
* curl
* json
* iconv
* xml
* xmlrpc
* gd

> If you want to install more extension, just update `./bin/webserver/Dockerfile`. You can also generate a PR and we will merge if seems good for general purpose.
> You have to rebuild the docker image by running `docker-compose build` and restart the docker containers.

## phpMyAdmin

phpMyAdmin is configured to run on port 8080. Use following default credentials.

http://localhost:8080/

username: root
password: tiger

or restricted user :
username: docker
password: docker


## Redis

It comes with Redis. It runs on default port `6379`.

+ 1
- 0
bin/mysql/Dockerfile View File

@@ -0,0 +1 @@
FROM mysql:5.7

+ 56
- 0
bin/webserver/Dockerfile View File

@@ -0,0 +1,56 @@
FROM php:7.3-apache-stretch

# Surpresses debconf complaints of trying to install apt packages interactively
# https://github.com/moby/moby/issues/4032#issuecomment-192327844
ARG DEBIAN_FRONTEND=noninteractive

# Update
RUN apt-get -y update --fix-missing && \
apt-get upgrade -y && \
apt-get --no-install-recommends install -y apt-utils && \
rm -rf /var/lib/apt/lists/*


# Install useful tools and install important libaries
RUN apt-get -y update && \
apt-get -y --no-install-recommends install nano wget dialog libsqlite3-dev libsqlite3-0 && \
apt-get -y --no-install-recommends install mysql-client zlib1g-dev libzip-dev libicu-dev && \
apt-get -y --no-install-recommends install --fix-missing apt-utils build-essential git curl && \
apt-get -y --no-install-recommends install --fix-missing libcurl3 libcurl3-dev zip openssl && \
rm -rf /var/lib/apt/lists/* && \
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

# Install xdebug
RUN pecl install xdebug-2.7.2 && \
docker-php-ext-enable xdebug

# Install redis
RUN pecl install redis-4.0.1 && \
docker-php-ext-enable redis

# Other PHP7 Extensions

RUN docker-php-ext-install pdo_mysql && \
docker-php-ext-install pdo_sqlite && \
docker-php-ext-install mysqli && \
docker-php-ext-install curl && \
docker-php-ext-install tokenizer && \
docker-php-ext-install json && \
docker-php-ext-install zip && \
docker-php-ext-install -j$(nproc) intl && \
docker-php-ext-install mbstring && \
docker-php-ext-install gettext

# Install Freetype
RUN apt-get -y update && \
apt-get --no-install-recommends install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev && \
rm -rf /var/lib/apt/lists/* && \
docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \
docker-php-ext-install -j$(nproc) gd

# Enable apache modules
RUN a2enmod rewrite headers

# Cleanup
RUN rm -rf /usr/src/*

+ 3
- 0
config/php/php.ini View File

@@ -0,0 +1,3 @@
memory_limit = 128M
post_max_size = 100M
upload_max_filesize = 20M

+ 8
- 0
config/vhosts/default.conf View File

@@ -0,0 +1,8 @@
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot "/var/www/html"
ServerName localhost
<Directory "/var/www/html/">
AllowOverride all
</Directory>
</VirtualHost>

+ 0
- 0
data/.gitkeep View File


+ 61
- 0
docker-compose.yml View File

@@ -0,0 +1,61 @@
version: "3"

services:
webserver:
build:
context: ./bin/webserver
container_name: '7.3.x-webserver'
restart: 'always'
ports:
- "${HOST_MACHINE_UNSECURE_HOST_PORT}:80"
- "${HOST_MACHINE_SECURE_HOST_PORT}:443"
links:
- mysql
volumes:
- ${DOCUMENT_ROOT-./www}:/var/www/html
- ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/php.ini
- ${VHOSTS_DIR-./config/vhosts}:/etc/apache2/sites-enabled
- ${LOG_DIR-./logs/apache2}:/var/log/apache2
environment:
HTTP_PORT: ${HOST_MACHINE_UNSECURE_HOST_PORT}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_SERVER: mysql
mysql:
build:
context: "./bin/${DATABASE}"
container_name: '5.7-mysql'
restart: 'always'
ports:
- "${HOST_MACHINE_MYSQL_PORT}:3306"
volumes:
- ${MYSQL_DATA_DIR-./data/mysql}:/var/lib/mysql
- ${MYSQL_LOG_DIR-./logs/mysql}:/var/log/mysql
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: 'sc-phpmyadmin'
links:
- mysql
environment:
PMA_HOST: mysql
PMA_PORT: 3306
PMA_USER: ${MYSQL_USER}
PMA_PASSWORD: ${MYSQL_PASSWORD}
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
ports:
- '8080:80'
volumes:
- /sessions
redis:
container_name: 'sc-redis'
image: redis:latest
ports:
- "${HOST_MACHINE_REDIS_PORT}:6379"

+ 0
- 0
logs/.gitkeep View File


+ 0
- 0
logs/apache2/.gitkeep View File


+ 0
- 0
logs/mysql/.gitkeep View File


+ 28
- 0
sample.env View File

@@ -0,0 +1,28 @@
DOCUMENT_ROOT=./www
VHOSTS_DIR=./config/vhosts
APACHE_LOG_DIR=./logs/apache2
PHP_INI=./config/php/php.ini

DATABASE=mysql

MYSQL_DATA_DIR=./data/mysql
MYSQL_LOG_DIR=./logs/mysql

# If you already has the port 8081 in use, you can change it (for example if you have Apache)
HOST_MACHINE_UNSECURE_HOST_PORT=8081
HOST_MACHINE_SECURE_HOST_PORT=440

# If you already has the port 3300 in use, you can change it (for example if you have MySQL)
HOST_MACHINE_MYSQL_PORT=3300

# If you already has the port 6379 in use, you can change it (for example if you have Redis)
HOST_MACHINE_REDIS_PORT=6379


# MySQL root user password
MYSQL_ROOT_PASSWORD=tiger

# Database settings: Username, password and database name
MYSQL_USER=docker
MYSQL_PASSWORD=docker
MYSQL_DATABASE=docker

+ 1
- 0
web/assets/css/bulma.min.css
File diff suppressed because it is too large
View File


+ 72
- 0
web/index.php View File

@@ -0,0 +1,72 @@
<?php

define('DB_HOST', getenv('MYSQL_SERVER'));
define('DB_USER', getenv('MYSQL_USER'));
define('DB_PASS', getenv('MYSQL_PASSWORD'));
define('DB_BASE', getenv('MYSQL_DATABASE'));
define('DB_CONN', 'mysql:host='.DB_HOST.';dbname='.DB_BASE);

?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>LAMP STACK</title>
<link rel="stylesheet" href="/assets/css/bulma.min.css">
</head>
<body>
<section class="hero is-medium is-info is-bold">
<div class="hero-body">
<div class="container has-text-centered">
<h1 class="title">
LAMP STACK
</h1>
<h2 class="subtitle">
Your local development environment
</h2>
</div>
</div>
</section>
<section class="section">
<div class="container">
<div class="columns">
<div class="column">
<h3 class="title is-3 has-text-centered">Environment</h3>
<hr>
<div class="content">
<ul>
<li><?= apache_get_version(); ?></li>
<li>PHP <?= phpversion(); ?></li>
<li>


<?php

try{
$pdo = new PDO(DB_CONN, DB_USER, DB_PASS);
echo "MySQL Server ".$pdo->getAttribute(PDO::ATTR_SERVER_VERSION );
} catch (PDOException $e){
echo 'Datebase error : '.$e->getMessage();
}

?>
</li>
</ul>
</div>
</div>
<div class="column">
<h3 class="title is-3 has-text-centered">Quick Links</h3>
<hr>
<div class="content">
<ul>
<li><a href="http://localhost:<?php echo getenv('HTTP_PORT');?>/phpinfo.php">phpinfo()</a></li>
<li><a href="http://localhost:8080">phpMyAdmin</a></li>
</ul>
</div>
</div>
</div>
</div>
</section>
</body>
</html>

+ 3
- 0
web/phpinfo.php View File

@@ -0,0 +1,3 @@
<?php
phpinfo();


Loading…
Cancel
Save