Skip to content

Denwer5 - docker-flavored environment for PHP-developers (nginx, php-fpm, composer, apcu, mysql, redis, memcached, xdebug)

Notifications You must be signed in to change notification settings

Shcneider/denwer5

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Denwer 5 (Docker-flavored)

About ten years ago Dmitry Koterov created the excellent project under the name Denwer.

Denwer contained all necessary for local development for PHP (Apache, PHP + mods, Mysql, sendmail, etc) and in due time it was very popular and demanded. Over time it, as well as the majority of projects, was abandoned (the latest actual version on the website - PHP 5.3.13), and the approaches offered them in the organization of development for PHP strongly became outdated since then.

This project is an attempt to recreate a complex containing everything you need to develop in PHP, but using modern tools, while maintaining ease of use and ease of installation (hmm ..).

Denwer 5 contains ready-to-work components:

  • nginx
  • php-fpm 7.2 (apcu, curl, mbstring, mysqli, opcache, pdo_mysql, memcached, redis, zip, xdebug)
  • composer
  • git
  • MySQL 5.6
  • adminer
  • redis 4.0
  • memcache 4.6.3
  • something is missing? use pull-request!

Quick links

How to use?

1. Install Docker

Docker Toolbox for Windows - for Windows 7, 8, 10 Home

Select all optional components. (Full Installation):
+ Docker Compose
+ VirtualBox
+ Kitematic
+ Git for Windows

> Create desktop shortcuts!

Docker for Windows - for Windows 10 Professional, Enterprise

Read the instructions carefully!
You will need to enable support for Hyper-V, after which VMs will not be able to start in VirtualBox
before disabling Hyper-V.
If you are not sure or use VirtualBox - use Docker Toolbox for Windows above.

Docker Toolbox for macOS - for macOS

2. Clone the repository

Important for WINDOWS Users

Due to Docker Toolbox for Windows’s access restrictions to the host’s file system,
Work is possible only from the current user's home directory!  
For example, you can clone the repository in [C:/Users/$USER/Denwer],
where $USER is your Windows username.

To simplify further explanations, we will install Denwer into the Denwer folder, and our Windows username is User.
Full installation path: C:/Users/User/Denwer

P.S. There is a way to get around this limitation and install Denwer in an arbitrary directory (see Transfer Denwer to drive D).

3. Run Denwer

  • Launch "Docker Quickstart Terminal" from the desktop.
    The first launch can be long, because VM is created in VirtualBox

  • Go to the Denwer folder

# absolute path is similar to unix format /drive/dir1/dir2/....
cd /c/Users/User/Denwer
# or
cd ~/Denwer
  • run Denwer (the first start will be long, the custom docker's PHP-image is built)
docker-compose up -d

4. Check Denwer's status

  • Launch "Docker Quickstart Terminal" from the desktop.
  • Go to the Denwer folder
cd /c/Users/User/Denwer
  • Check status of the containers
docker-compose ps
  • All containers are up and running. (State = Up).
      Name                    Command               State           Ports
----------------------------------------------------------------------------------
denwer_adminer     entrypoint.sh docker-php-e ...   Up      0.0.0.0:8080->8080/tcp
denwer_memcached   docker-entrypoint.sh memcached   Up      11211/tcp
denwer_mysql       docker-entrypoint.sh --inn ...   Up      3306/tcp, 33060/tcp
denwer_nginx       nginx -g daemon off;             Up      0.0.0.0:80->80/tcp
denwer_php         docker-php-entrypoint php-fpm    Up      9000/tcp
denwer_redis       docker-entrypoint.sh redis ...   Up      6379/tcp

If something is not working - see troubleshooting

5. Open the project in the browser

  • Go to http://192.168.99.100 in the browser
  • We see the output of the test PHP script, which is trying to connect MySQL, Redis and Memcache
/var/www/projects/default/public/index.php:8:string '2018-10-03 12:42:33' (length=19)
/var/www/projects/default/public/index.php:14:int 1538570553
/var/www/projects/default/public/index.php:20:string '1538570553' (length=10)

Denwer 5 supports multi-project!
Read more about Denwer's multi-project

6. Stop Denwer

  • Launch "Docker Quickstart Terminal" from the desktop.
  • Go to the Denwer folder
cd /c/Users/User/Denwer
  • Stop Denwer
docker-compose down
  • Check status of the containers
docker-compose ps
  • None running container
Name   Command   State   Ports
------------------------------

Denwer 5 structure

  • ./etc
    Here are the configs of components that are forwarded to the inside of the container (for example, nginx.conf, php.ini).
    After configs change you need to restart Denwer!

  • ./var
    Permanent storage for stateful containers (DB). You can safely delete all files (except the .gitkeep file) inside the mysql or redis folders, it will reset the database and force Denwer initialize it empty again (first stop Denwer, then delete files, then start Denwer).

  • ./env
    Environment files that are bound in containers.

  • ./home
    Here are your PHP projects. (see. How to place and run php code)

  • ./docker-compose.yml
    Description of all project containers for Docker Compose.

How to place and run PHP code

Denwer offers two approaches for placing PHP code inside:

  • Multiple-projects with domain support for each project
  • Single-project with IP access

One project, access via IP

  • Put all your files in ./home/default
  • Your site will be accessible by IP http://192.168.99.100 (if not working - Denwer got another IP, see how to find the Denwer's external IP )
  • Note that index.php should be located in the public subfolder, not at the root! (good: ./home/default/public/index.php)

Multiple-projects with domain support for each project

  • Each folder inside ./home is a project and is available by the name of the form *.denwer (for example, the default project default, which is located in ./home/default is available at http://default.denwer/)
  • You need to add an entry for the default.denwer domain to the file C:\Windows\System32\drivers\etc\hosts on your PC
192.168.99.100 default.denwer
192.168.99.100 project1.denwer
192.168.99.100 project2.denwer
  • Instead of 192.168.99.100 use your Denwer external IP (how to find the Denwer's external IP)
  • By default, the file C:\Windows\System32\drivers\etc\hosts is write-protected. Use google to unlock :)

Transfer Denwer to drive D

  • Stop Denwer
  • Switch off default docker machine
docker-machine stop default
  • Copy Denwer to new location:
    • Old location: C:\Users\User\Denwer
    • New location: D:\Denwer (you can choose any location)
  • Open VirtualBox, go to Settings of Docker VM (named default)
  • Go to Shared folders config and add a new Shared folder:
    • Path: D:\Denwer
    • Name: d/Denwer
    • Auto mount: yes
  • Note that Name must repeat Path considering the features of mapping the path of Windows to Linux:
    • E:\Work\PurpleGames\Denwer => e/Work/PurpleGames/Denwer
    • D:\SomeFolder\DENWER => d/SomeFolder/DENWER
  • Start default Docker Machine
docker-machine start default

F.A.Q

How to find Denwer external IP?

  • Launch "Docker Quickstart Terminal" from the desktop.
  • Display a list of docker-machines
docker-machine ls
  • Look at the IP in the URL column (in my case IP = 192.168.99.100):
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM   DOCKER        ERRORS
default   *        virtualbox   Running   tcp://192.168.99.100:2376           v18.06.1-ce
  • Go to http://192.168.99.100

How to run Composer?

@todo

Where is Adminer?

Where is PhpMyAdmin?

Nowhere. Use Adminer.

How to connect to MySQL, Redis, Memcache from PHP?

  • See ./home/default/index.php, is an example to connect for MySQL, Redis and Memcached.
  • If example is lost, use credentials:
Mysql:
    host=mysql
    port=3306
    user=root
    pass=root
    
Redis:
    host=redis
    port=6379
    
Memcached:
    host=memcached
    port=11211        

How to connect to MySQL, Redis, Memcache from PC?

@todo

How to enable PHP extension?

  • mkdir ./build/php
  • Clone repository https://github.com/Shcneider/denwer5-php7.2-docker-image into ./build/php
  • Add custom extensions in Dockerfile
  • Edit docker-compose.yml: comment image section of service php, uncomment build of service php
  • Run docker-compose build
  • Run Denwer
  • Your custom php image is ready and work!

How to change PHP version?

  • mkdir ./build/php
  • Clone repository https://github.com/Shcneider/denwer5-php7.2-docker-image into ./build/php
  • Change PHP version in Dockerfile (first line)
  • Edit docker-compose.yml: comment image section of service php, uncomment build of service php
  • Run docker-compose build
  • Run Denwer
  • Your custom php image is ready and work!

Troubleshooting

@todo

Русская документация

About

Denwer5 - docker-flavored environment for PHP-developers (nginx, php-fpm, composer, apcu, mysql, redis, memcached, xdebug)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published