Giter Club home page Giter Club logo

docker-apache2-php-mysql-wordpress's Introduction

Apache PHP MySQL - Docker for Wordpress

Docker running Apache, PHP-Apache, MySQL and PHPMyAdmin.

THIS ENVIRONMENT SHOULD ONLY BE USED FOR DEVELOPMENT!

DO NOT USE IT IN PRODUCTION!

Images to use

Start using it

  1. Download it :

    $ git clone https://github.com/aleix20bcn/docker-apache2-php-mysql-wordpress.git
  2. Configure Apache :

    Create apache file etc/apache/mydomain.com.conf and configure the server section.

    
    <VirtualHost *:80>
        ServerAdmin web@localhost

        ServerName mydomain.com
        ServerAlias www.mydomain.com

        DocumentRoot /CODE/mydomain.com/live/current

        ErrorLog ${APACHE_LOG_DIR}/mydomain.com_error.log

        LogLevel warn
        CustomLog ${APACHE_LOG_DIR}/mydomain.com_access.log combined

        <Directory />
                Options FollowSymLinks
        </Directory>

        <Directory /CODE/mydomain.com/live/current/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
                # New directive needed in Apache 2.4.3: 
                Require all granted
        </Directory>

        RewriteEngine On
    </VirtualHost>
    
  1. Configure .env file :
    #Domain variables
    DOMAIN_NAME=<domain_name>
    
    #Database variables
    DATABASE=<database>
    DATABASE_USER=<user_database>
    DATABASE_PASS=<supersecretpassword_database>
  1. Copy wordpres project to /web

  2. Run :

    $ docker-compose up -d
  3. Add dump database in container :

    $ cat backup.sql | docker exec -i mysql /usr/bin/mysql -u root --password=root MYDATABASE
  4. Configure your "/etc/hosts" file in your computer :

    $ 127.0.0.1       mydomain.com
  5. Open your favorite browser :

Directory tree

├── README.md
├── bin
│   └── linux
│       └── clean.sh
├── data
│   └── db
│       └── mysql
├── docker-compose.yml
├── etc
│   ├── apache
│   │   ├── mydomain.conf
│   ├── php
│   │   └── php.ini
│   └── ssl
│       ├── cacert.pem
│       ├── server.key
│       └── server.pem
└── web

Configure correct connection to Database in wp-config.php

<?php
return array (
  ...
  define('DB_NAME', '<database>');

  /** Tu nombre de usuario de MySQL */
  define('DB_USER', '<user_database>');

  /** Tu contraseña de MySQL */
  define('DB_PASSWORD', '<supersecretpassword_database>');

  /** Host de MySQL (es muy probable que no necesites cambiarlo) */
  define('DB_HOST', 'mysql');
  ...
);
?>

Docker Container shell access

$ docker exec -i -t CONTAINER_NAME /bin/bash

Backup SQL

$ docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql

Restore SQL

$ cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE

Delete all docker containers

$ docker rm -f $(docker ps -aq)

Delete all docker images (IMPORTANT: on new deployment docker need to download newly images)

$ docker rmi $(docker images -q)

Cleaning project

$ ./bin/linux/clean.sh $(pwd)

docker-apache2-php-mysql-wordpress's People

Watchers

Ben Haim avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.