├── data └── mysql │ └── .gitkeep ├── logs ├── apache2 │ └── .gitkeep └── mysql │ └── .gitkeep ├── bin ├── mysql │ └── Dockerfile └── webserver │ └── Dockerfile ├── .gitignore ├── www └── .gitignore ├── config ├── php │ └── php.ini └── vhosts │ └── default.conf ├── sample.env ├── LICENSE ├── docker-compose.yml └── README.md /data/mysql/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /logs/apache2/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /logs/mysql/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bin/mysql/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM mysql:8 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.env 2 | /config/* 3 | /data/* 4 | /logs/* 5 | #/www/** 6 | -------------------------------------------------------------------------------- /www/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore -------------------------------------------------------------------------------- /config/php/php.ini: -------------------------------------------------------------------------------- 1 | memory_limit = 128M 2 | post_max_size = 100M 3 | upload_max_filesize = 20M 4 | pdo_mysql.default_socket=/var/run/mysqld/mysqld.sock 5 | -------------------------------------------------------------------------------- /sample.env: -------------------------------------------------------------------------------- 1 | DOCUMENT_ROOT=./www 2 | VHOSTS_DIR=./config/vhosts 3 | APACHE_LOG_DIR=./logs/apache2 4 | PHP_INI=./config/php/php.ini 5 | MYSQL_DATA_DIR=./data/mysql 6 | MYSQL_LOG_DIR=./logs/mysql -------------------------------------------------------------------------------- /config/vhosts/default.conf: -------------------------------------------------------------------------------- 1 | 2 | ServerAdmin webmaster@localhost 3 | DocumentRoot "/var/www/html" 4 | ServerName localhost 5 | 6 | AllowOverride All 7 | 8 | 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Narendra Vaghela 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | webserver: 5 | build: 6 | context: ./bin/webserver 7 | container_name: 'my-webserver' 8 | restart: 'always' 9 | ports: 10 | - "80:80" 11 | - "443:443" 12 | links: 13 | - mysql 14 | volumes: 15 | - ${DOCUMENT_ROOT-./www}:/var/www/html 16 | - ${PHP_INI-./config/php/php.ini}:/usr/local/etc/php/php.ini 17 | - ${VHOSTS_DIR-./config/vhosts}:/etc/apache2/sites-enabled 18 | - ${LOG_DIR-./logs/apache2}:/var/log/apache2 19 | networks: 20 | - web-db-net 21 | mysql: 22 | build: ./bin/mysql 23 | container_name: 'my-mysql' 24 | command: --default-authentication-plugin=mysql_native_password 25 | restart: 'always' 26 | ports: 27 | - "3306:3306" 28 | volumes: 29 | - ${MYSQL_DATA_DIR-./data/mysql}:/var/lib/mysql 30 | - ${MYSQL_LOG_DIR-./logs/mysql}:/var/log/mysql 31 | environment: 32 | MYSQL_ROOT_PASSWORD: tiger 33 | networks: 34 | - web-db-net 35 | phpmyadmin: 36 | image: phpmyadmin/phpmyadmin 37 | container_name: 'my-phpmyadmin' 38 | links: 39 | - mysql 40 | environment: 41 | PMA_HOST: mysql 42 | PMA_PORT: 3306 43 | ports: 44 | - '8080:80' 45 | volumes: 46 | - /sessions 47 | networks: 48 | - web-db-net 49 | # adminer: 50 | # image: adminer 51 | # container_name: 'my-adminer' 52 | # restart: always 53 | # ports: 54 | # - 8080:8080 55 | # environment: 56 | # ADMINER_DEFAULT_SERVER: mysql 57 | # networks: 58 | # - web-db-net 59 | 60 | networks: 61 | web-db-net: 62 | -------------------------------------------------------------------------------- /bin/webserver/Dockerfile: -------------------------------------------------------------------------------- 1 | # Quickfix - Basebox for PHP7.2 Library now uses Debian "10" Buster, superceeding #libcurl3, stretch is most compatible at this time whilst devs workout backport. 2 | # https://github.com/docker-library/php/issues/865 3 | 4 | FROM php:7.2-apache-stretch 5 | 6 | # Surpresses debconf complaints of trying to install apt packages interactively 7 | # https://github.com/moby/moby/issues/4032#issuecomment-192327844 8 | 9 | ARG DEBIAN_FRONTEND=noninteractive 10 | 11 | RUN apt-get -y update --fix-missing --no-install-recommends 12 | RUN apt-get -y upgrade 13 | 14 | # Install useful tools 15 | RUN apt-get -yq install apt-utils nano wget dialog 16 | 17 | # Install important libraries 18 | RUN apt-get -y install --fix-missing apt-utils build-essential git curl libcurl3 libcurl3-dev zip openssl 19 | 20 | # Composer 21 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 22 | 23 | # Install xdebug 24 | RUN pecl install xdebug-2.6.0 25 | RUN docker-php-ext-enable xdebug 26 | 27 | # Install redis 28 | RUN pecl install redis-4.0.1 29 | RUN docker-php-ext-enable redis 30 | 31 | # Other PHP7 Extensions 32 | 33 | RUN apt-get -y install libsqlite3-dev libsqlite3-0 mysql-client 34 | RUN docker-php-ext-install pdo_mysql 35 | RUN docker-php-ext-install pdo_sqlite 36 | RUN docker-php-ext-install mysqli 37 | 38 | RUN docker-php-ext-install curl 39 | RUN docker-php-ext-install tokenizer 40 | RUN docker-php-ext-install json 41 | 42 | RUN apt-get -y install zlib1g-dev 43 | RUN docker-php-ext-install zip 44 | 45 | RUN apt-get -y install libicu-dev 46 | RUN docker-php-ext-install -j$(nproc) intl 47 | 48 | RUN docker-php-ext-install mbstring 49 | RUN docker-php-ext-install gettext 50 | 51 | RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev 52 | RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ 53 | RUN docker-php-ext-install -j$(nproc) gd 54 | 55 | # Enable apache modules 56 | RUN a2enmod rewrite headers 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # WAMP stack built with Docker Compose 2 | 3 | This is a basic WAMP stack environment built using Docker Compose. It consists following: 4 | 5 | * Apache v2.4 6 | * MySQL v8 7 | * PHP v7.2 8 | * phpMyAdmin 9 | 10 | ## Installation 11 | 12 | Clone this repository on your local computer. Run the `docker-compose up`. 13 | 14 | ```shell 15 | git clone https://github.com/solodyagin/docker-compose-wamp.git 16 | cd docker-compose-wamp/ 17 | git fetch --all 18 | docker-compose up 19 | ``` 20 | 21 | Your WAMP stack is now ready!! You can access it via `http://localhost`. 22 | 23 | ## Configuration 24 | 25 | This package comes with default configuration options. You can modify them by creating `.env` file in your root directory. 26 | 27 | To make it easy, just copy the content from `sample.env` file and update the environment variable values as per your need. 28 | 29 | ### Configuration Variables 30 | 31 | There are following configuration variables available and you can customize them by overwritting in your own `.env` file. 32 | 33 | _**DOCUMENT_ROOT**_ 34 | 35 | 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. 36 | 37 | _**MYSQL_DATA_DIR**_ 38 | 39 | This is MySQL data directory. The default value for this is `./data/mysql`. All your MySQL data files will be stored here. 40 | 41 | _**VHOSTS_DIR**_ 42 | 43 | This is for virtual hosts. The default value for this is `./config/vhosts`. You can place your virtual hosts conf files here. 44 | 45 | > Make sure you add an entry to your system's `hosts` file for each virtual host. 46 | 47 | _**APACHE_LOG_DIR**_ 48 | 49 | This will be used to store Apache logs. The default value for this is `./logs/apache2`. 50 | 51 | _**MYSQL_LOG_DIR**_ 52 | 53 | This will be used to store Apache logs. The default value for this is `./logs/mysql`. 54 | 55 | ## Web Server 56 | 57 | Apache is configured to run on port 80. So, you can access it via `http://localhost`. 58 | 59 | #### Apache Modules 60 | 61 | By default following modules are enabled. 62 | 63 | * rewrite 64 | * headers 65 | 66 | > 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. 67 | > You have to rebuild the docker image by running `docker-compose build` and restart the docker containers. 68 | 69 | #### Connect via SSH 70 | 71 | You can connect to web server using `docker exec` command to perform various operation on it. Use below command to login to container via ssh. 72 | 73 | ```shell 74 | docker exec -it my-webserver /bin/bash 75 | ``` 76 | 77 | ## PHP 78 | 79 | #### Extensions 80 | 81 | By default following extensions are installed. 82 | 83 | * mysqli 84 | * mbstring 85 | * zip 86 | * intl 87 | * mcrypt 88 | * curl 89 | * json 90 | * iconv 91 | * xml 92 | * xmlrpc 93 | * gd 94 | 95 | > 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. 96 | > You have to rebuild the docker image by running `docker-compose build` and restart the docker containers. 97 | 98 | ## phpMyAdmin 99 | 100 | phpMyAdmin is configured to run on port 8080. Use following default credentials. 101 | 102 | http://localhost:8080/ 103 | username: root 104 | password: tiger 105 | --------------------------------------------------------------------------------