├── .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 | Options Indexes FollowSymLinks 10 | AllowOverride All 11 | Require all granted 12 | 13 | 14 | 15 | # 16 | # DocumentRoot "${ROOT}" 17 | # ServerName ${SITE} 18 | # ServerAlias *.${SITE} 19 | # 20 | # AllowOverride All 21 | # Require all granted 22 | # Options Indexes FollowSymLinks 23 | # 24 | # 25 | # SSLEngine on 26 | # SSLCertificateFile "/etc/ssl/certs/server.pem" 27 | # SSLCertificateKeyFile "/etc/ssl/private/server-key.pem" 28 | # 29 | -------------------------------------------------------------------------------- /.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 | unixodbc \ 18 | unixodbc-dev \ 19 | freetds-dev \ 20 | freetds-bin \ 21 | tdsodbc 22 | 23 | RUN docker-php-ext-configure gd \ 24 | --with-png-dir=/usr/include/ \ 25 | --with-jpeg-dir=/usr/include/ \ 26 | --with-freetype-dir=/usr/include/ 27 | 28 | RUN docker-php-ext-configure zip --with-libzip 29 | 30 | RUN docker-php-ext-configure pdo_dblib --with-libdir=/lib/x86_64-linux-gnu 31 | 32 | RUN docker-php-ext-configure soap --enable-soap 33 | 34 | RUN docker-php-ext-install gd intl pdo_mysql pdo_pgsql mysqli zip pdo_dblib soap 35 | 36 | RUN pecl install imagick-3.4.3 37 | 38 | RUN pecl install xdebug && docker-php-ext-enable xdebug 39 | 40 | RUN docker-php-ext-enable imagick pdo_dblib 41 | 42 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer 43 | 44 | #upload 45 | RUN echo "file_uploads = On\n" \ 46 | "memory_limit = 500M\n" \ 47 | "upload_max_filesize = 500M\n" \ 48 | "post_max_size = 500M\n" \ 49 | "max_execution_time = 600\n" \ 50 | "max_input_vars=5000\n" \ 51 | > /usr/local/etc/php/conf.d/uploads.ini 52 | 53 | # Clear package lists 54 | RUN apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/* 55 | 56 | # Permissions 57 | RUN chown -R root:www-data /var/www/html 58 | RUN chmod u+rwx,g+rx,o+rx /var/www/html 59 | RUN find /var/www/html -type d -exec chmod u+rwx,g+rx,o+rx {} + 60 | RUN find /var/www/html -type f -exec chmod u+rw,g+rw,o+r {} + 61 | 62 | WORKDIR /var/www/html 63 | 64 | RUN a2enmod rewrite 65 | RUN a2enmod ssl 66 | 67 | EXPOSE 80 68 | EXPOSE 443 69 | -------------------------------------------------------------------------------- /.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 | 4 | #### 1. Run Docker 5 | 6 | Start Server (in background) 7 | 8 | - docker-compose up -d 9 | 10 | Stop Server 11 | 12 | - docker-compose down 13 | 14 | Rebuild Server 15 | 16 | - docker-compose up -d --build 17 | 18 | --- 19 | 20 | ## Installation 21 | 22 | #### 2. Create a Self-Signed SSL Certificate 23 | 24 | Install Certutil 25 | 26 | - sudo apt install libnss3-tools -y 27 | 28 | Install mkcert 29 | 30 | - wget https://github.com/FiloSottile/mkcert/releases/download/v1.1.2/mkcert-v1.1.2-linux-amd64 31 | - mv mkcert-v1.1.2-linux-amd64 mkcert 32 | - chmod +x mkcert 33 | - sudo cp mkcert /usr/local/bin/ 34 | 35 | Generate Local CA 36 | 37 | - mkcert -install 38 | 39 | Generate Local SSL Certificates 40 | 41 | - sudo mkcert example.com '\*.example.com' localhost 127.0.0.1 ::1 42 | 43 | Copy the certificate example.com+4.pem and key example.com+4-key.pem into folder .docker/apache of your project. 44 | 45 | Rename these files to server.pem and server-key.pem and give the permission 644. 46 | 47 | - sudo chmod 644 server.pem 48 | - sudo chmod 644 server-key.pem 49 | 50 | References 51 | 52 | - https://github.com/FiloSottile/mkcert 53 | 54 | --- 55 | -------------------------------------------------------------------------------- /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 |