├── .docker
├── apache
│ └── 000-default.conf
└── php
│ └── Dockerfile
├── .gitignore
├── LICENSE
├── README.md
├── docker-compose.yml
└── src
└── index.php
/.docker/apache/000-default.conf:
--------------------------------------------------------------------------------
1 | define ROOT "/var/www/html"
2 | define SITE "localhost"
3 |
4 |
5 | DocumentRoot "${ROOT}"
6 | ServerName ${SITE}
7 | ServerAlias *.${SITE}
8 |
9 | AllowOverride All
10 | Require all granted
11 |
12 |
13 |
14 |
15 | DocumentRoot "${ROOT}"
16 | ServerName ${SITE}
17 | ServerAlias *.${SITE}
18 |
19 | AllowOverride All
20 | Require all granted
21 | Options Indexes FollowSymLinks
22 |
23 |
24 | SSLEngine on
25 | SSLCertificateFile "/etc/ssl/certs/server.pem"
26 | SSLCertificateKeyFile "/etc/ssl/private/server-key.pem"
27 |
--------------------------------------------------------------------------------
/.docker/php/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM php:7.3.7-apache
2 |
3 | RUN apt-get update && apt-get install -y --no-install-recommends \
4 | autoconf \
5 | build-essential \
6 | apt-utils \
7 | zlib1g-dev \
8 | libzip-dev \
9 | unzip \
10 | zip \
11 | libmagick++-dev \
12 | libmagickwand-dev \
13 | libpq-dev \
14 | libfreetype6-dev \
15 | libjpeg62-turbo-dev \
16 | libpng-dev
17 |
18 | RUN docker-php-ext-configure gd \
19 | --with-png-dir=/usr/include/ \
20 | --with-jpeg-dir=/usr/include/ \
21 | --with-freetype-dir=/usr/include/
22 |
23 | RUN docker-php-ext-configure zip --with-libzip
24 |
25 | RUN docker-php-ext-install gd intl pdo_mysql pdo_pgsql mysqli zip
26 |
27 | RUN pecl install imagick-3.4.3
28 |
29 | RUN pecl install xdebug && docker-php-ext-enable xdebug
30 |
31 | RUN docker-php-ext-enable imagick
32 |
33 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
34 |
35 | # Clear package lists
36 | RUN apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
37 |
38 | # Permissions
39 | RUN chown -R root:www-data /var/www/html
40 | RUN chmod u+rwx,g+rx,o+rx /var/www/html
41 | RUN find /var/www/html -type d -exec chmod u+rwx,g+rx,o+rx {} +
42 | RUN find /var/www/html -type f -exec chmod u+rw,g+rw,o+r {} +
43 |
44 | WORKDIR /var/www/html
45 |
46 | RUN a2enmod rewrite
47 | RUN a2enmod ssl
48 |
49 | EXPOSE 80
50 | EXPOSE 443
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .docker/db
2 | .docker/apache/server.pem
3 | .docker/apache/server-key.pem
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Willian Robert
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Docker | Apache 2.4 | PHP 7.3.7 | Mysql 5.7 | Phpmyadmin | SSL
2 |
3 | ## Installation
4 |
5 | #### 1. Create a Self-Signed SSL Certificate
6 |
7 | Install Certutil
8 |
9 | - sudo apt install libnss3-tools -y
10 |
11 | Install mkcert
12 |
13 | - wget https://github.com/FiloSottile/mkcert/releases/download/v1.1.2/mkcert-v1.1.2-linux-amd64
14 | - mv mkcert-v1.1.2-linux-amd64 mkcert
15 | - chmod +x mkcert
16 | - sudo cp mkcert /usr/local/bin/
17 |
18 | Generate Local CA
19 |
20 | - mkcert -install
21 |
22 | Generate Local SSL Certificates
23 |
24 | - sudo mkcert example.com '\*.example.com' localhost 127.0.0.1 ::1
25 |
26 | Copy the certificate example.com+4.pem and key example.com+4-key.pem into folder .docker/apache of your project.
27 |
28 | Rename these files to server.pem and server-key.pem and give the permission 644.
29 |
30 | - sudo chmod 644 server.pem
31 | - sudo chmod 644 server-key.pem
32 |
33 | References
34 |
35 | - https://github.com/FiloSottile/mkcert
36 |
37 | ---
38 |
39 | #### 2. Run Docker
40 |
41 | Start Server (in background)
42 |
43 | - docker-compose up -d
44 |
45 | Stop Server
46 |
47 | - docker-compose down
48 |
49 | Rebuild Server
50 |
51 | - docker-compose up -d --build
52 |
53 | ---
54 |
--------------------------------------------------------------------------------
/docker-compose.yml:
--------------------------------------------------------------------------------
1 | version: "3"
2 | services:
3 | php:
4 | build: .docker/php
5 | container_name: "apache-srv"
6 | image: server-apache
7 | volumes:
8 | - .docker/apache/server.pem:/etc/ssl/certs/server.pem
9 | - .docker/apache/server-key.pem:/etc/ssl/private/server-key.pem
10 | - .docker/apache/000-default.conf:/etc/apache2/sites-enabled/000-default.conf
11 | - ./src:/var/www/html
12 | ports:
13 | - 80:80
14 | - 443:443
15 | restart: always
16 | networks:
17 | - mynetwork
18 |
19 | mysql:
20 | image: mysql:5.7.26
21 | container_name: "mysql-srv"
22 | volumes:
23 | - .docker/db:/var/lib/mysql
24 | ports:
25 | - 3306:3306
26 | environment:
27 | MYSQL_USER: root
28 | MYSQL_PASSWORD: root
29 | MYSQL_ROOT_PASSWORD: root
30 | restart: always
31 | networks:
32 | - mynetwork
33 |
34 | phpmyadmin:
35 | image: phpmyadmin/phpmyadmin
36 | container_name: "phpmyadmin-srv"
37 | ports:
38 | - 8080:80
39 | environment:
40 | - PMA_ARBITRARY=1
41 | - PMA_HOST=mysql
42 | - PMA_USER=root
43 | - PMA_PASSWORD=root
44 | links:
45 | - mysql
46 | restart: always
47 | networks:
48 | - mynetwork
49 |
50 | networks:
51 | mynetwork:
52 | driver: bridge
53 |
--------------------------------------------------------------------------------
/src/index.php:
--------------------------------------------------------------------------------
1 |