├── .gitignore ├── Dockerfile ├── README.md └── files └── root ├── entrypoint.sh ├── etc ├── nginx │ └── sites-enabled │ │ └── default └── supervisor │ └── conf.d │ ├── mysql.conf │ ├── nginx.conf │ └── php-fpm.conf ├── run └── php │ └── .gitkeep └── var ├── log └── php │ ├── cgi.log │ └── cli.log ├── run └── mysqld │ └── .gitkeep └── www └── index.php /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by http://www.gitignore.io 2 | 3 | ### Emacs ### 4 | # -*- mode: gitignore; -*- 5 | *~ 6 | \#*\# 7 | /.emacs.desktop 8 | /.emacs.desktop.lock 9 | *.elc 10 | auto-save-list 11 | tramp 12 | .\#* 13 | 14 | # Org-mode 15 | .org-id-locations 16 | *_archive 17 | 18 | # flymake-mode 19 | *_flymake.* 20 | 21 | # eshell files 22 | /eshell/history 23 | /eshell/lastdir 24 | 25 | # elpa packages 26 | /elpa/ 27 | 28 | # reftex files 29 | *.rel 30 | 31 | # AUCTeX auto folder 32 | /auto/ 33 | 34 | *.pyc 35 | 36 | # ssh key 37 | id_rsa* 38 | 39 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:17.10 2 | 3 | ENV DEBIAN_FRONTEND noninteractive 4 | 5 | ## Install php nginx mysql supervisor 6 | RUN apt update && \ 7 | apt install -y php7.1-fpm php7.1-mysql php7.1-gd php7.1-mcrypt php7.1-mysql php7.1-curl \ 8 | nginx \ 9 | curl \ 10 | supervisor && \ 11 | echo "mysql-server mysql-server/root_password password" | debconf-set-selections && \ 12 | echo "mysql-server mysql-server/root_password_again password" | debconf-set-selections && \ 13 | apt install -y mysql-server && \ 14 | rm -rf /var/lib/apt/lists/* 15 | 16 | ## Configuration 17 | RUN sed -i 's/^listen\s*=.*$/listen = 127.0.0.1:9000/' /etc/php/7.1/fpm/pool.d/www.conf && \ 18 | sed -i 's/^\;error_log\s*=\s*syslog\s*$/error_log = \/var\/log\/php\/cgi.log/' /etc/php/7.1/fpm/php.ini && \ 19 | sed -i 's/^\;error_log\s*=\s*syslog\s*$/error_log = \/var\/log\/php\/cli.log/' /etc/php/7.1/cli/php.ini && \ 20 | sed -i 's/^key_buffer\s*=/key_buffer_size =/' /etc/mysql/my.cnf 21 | 22 | COPY files/root / 23 | 24 | WORKDIR /var/www/ 25 | 26 | VOLUME ["/var/www/", "/var/lib/mysql/"] 27 | 28 | EXPOSE 80 29 | 30 | ENTRYPOINT ["/entrypoint.sh"] 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | docker-lemp [DEPRECATED] 2 | =========== 3 | 4 | [![Docker Stars](https://img.shields.io/docker/stars/stenote/docker-lemp.svg)](https://hub.docker.com/r/stenote/docker-lemp/) 5 | [![Docker Pulls](https://img.shields.io/docker/pulls/stenote/docker-lemp.svg)](https://hub.docker.com/r/stenote/docker-lemp/) 6 | 7 | 8 | We suppose this is a develop environment for phpers. 9 | 10 | Don't use it in product environment. 11 | 12 | # Usage 13 | 14 | docker run -d --name=lemp \ 15 | -v /path/to/www/:/var/www/ \ 16 | -v /path/to/mysql:/var/lib/mysql \ 17 | -p port_of_nginx:80 \ 18 | stenote/docker-lemp:latest 19 | 20 | # Detail 21 | 22 | ## MySQL 23 | * user: root 24 | * (No password) 25 | 26 | ## SSH 27 | We don't support SSH right now. You can use `docker exec` to enter the docker container. 28 | -------------------------------------------------------------------------------- /files/root/entrypoint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | 5 | chown -R www-data:www-data /var/www /var/log/php 6 | 7 | # init mysql db if necessary 8 | if [ ! -d /var/lib/mysql/mysql ];then 9 | mysqld --initialize-insecure --user=root --datadir=/var/lib/mysql 10 | fi 11 | 12 | chown -R mysql:mysql /var/lib/mysql /var/run/mysqld 13 | 14 | exec /usr/bin/supervisord --nodaemon -c /etc/supervisor/supervisord.conf 15 | -------------------------------------------------------------------------------- /files/root/etc/nginx/sites-enabled/default: -------------------------------------------------------------------------------- 1 | server { 2 | listen 80; 3 | 4 | index index.php; 5 | 6 | root /var/www/; 7 | charset utf8; 8 | 9 | location / { 10 | 11 | gzip on; 12 | try_files $uri/index.php $uri /index.php; 13 | 14 | if (!-f $request_filename) { 15 | rewrite (.*) /index.php; 16 | } 17 | 18 | } 19 | 20 | location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { 21 | expires 30d; 22 | gzip on; 23 | } 24 | 25 | location ~ .*\.(js|css)?$ { 26 | expires 1h; 27 | 28 | } 29 | 30 | # php fastcgi setting 31 | location ~ \.php$ { 32 | fastcgi_pass 127.0.0.1:9000; 33 | fastcgi_index index.php; 34 | fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name; 35 | include fastcgi_params; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /files/root/etc/supervisor/conf.d/mysql.conf: -------------------------------------------------------------------------------- 1 | [program:mysql] 2 | command=/usr/bin/pidproxy /var/run/mysqld/mysqld.pid /usr/bin/mysqld_safe 3 | autorestart=true 4 | -------------------------------------------------------------------------------- /files/root/etc/supervisor/conf.d/nginx.conf: -------------------------------------------------------------------------------- 1 | [program:nginx] 2 | command=/usr/sbin/nginx -g "daemon off;" 3 | -------------------------------------------------------------------------------- /files/root/etc/supervisor/conf.d/php-fpm.conf: -------------------------------------------------------------------------------- 1 | [program:php-fpm] 2 | command=/usr/sbin/php-fpm7.1 --nodaemonize --fpm-config /etc/php/7.1/fpm/php-fpm.conf 3 | -------------------------------------------------------------------------------- /files/root/run/php/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stenote/docker-lemp/2baaf7e6015429940bd7c8bbac860415bedeb8cb/files/root/run/php/.gitkeep -------------------------------------------------------------------------------- /files/root/var/log/php/cgi.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stenote/docker-lemp/2baaf7e6015429940bd7c8bbac860415bedeb8cb/files/root/var/log/php/cgi.log -------------------------------------------------------------------------------- /files/root/var/log/php/cli.log: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stenote/docker-lemp/2baaf7e6015429940bd7c8bbac860415bedeb8cb/files/root/var/log/php/cli.log -------------------------------------------------------------------------------- /files/root/var/run/mysqld/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stenote/docker-lemp/2baaf7e6015429940bd7c8bbac860415bedeb8cb/files/root/var/run/mysqld/.gitkeep -------------------------------------------------------------------------------- /files/root/var/www/index.php: -------------------------------------------------------------------------------- 1 |