liuyuqi-dellpc 4 years ago
parent
commit
2072e2d22a

+ 9 - 0
php-alpine/Dockerfile

@@ -0,0 +1,9 @@
+FROM daocloud.io/library/php:7.1-alpine
+RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
+RUN apk add --no-cache libmcrypt-dev freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev $PHPIZE_DEPS
+RUN docker-php-ext-install pdo_mysql gd opcache pcntl bcmath
+RUN pecl install xdebug redis \
+    && docker-php-ext-enable xdebug \
+    && docker-php-ext-enable redis
+RUN apk del --no-cache libmcrypt-dev freetype-dev libpng-dev libjpeg-turbo-dev
+RUN rm -rf /tmp/* /usr/local/lib/php/doc/* /var/cache/apk/*

+ 5 - 0
php-apache/Dockerfile

@@ -0,0 +1,5 @@
+FROM daocloud.io/php:7.1-apache
+
+WORKDIR /usr/src/myapp
+COPY ./src /usr/src/myapp
+CMD [ "php","/src/index.php" ]

+ 7 - 0
php-apache/README.md

@@ -0,0 +1,7 @@
+## php-apache
+
+```
+docker run -it -rm --name test-php php:php-apache
+
+```
+

+ 2 - 0
php-apache/src/index.php

@@ -0,0 +1,2 @@
+<?
+phpinfo();

+ 21 - 0
php7/Dockerfile

@@ -0,0 +1,21 @@
+FROM daocloud.io/library/php:7.1.5-fpm
+
+RUN pecl install xdebug-2.7.2 \
+    && docker-php-ext-enable xdebug
+
+COPY xdebug.ini /usr/local/etc/php/conf.d/
+
+# # 更新安装源
+# RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories
+
+# # 安装基础库
+# RUN apk add --no-cache libmcrypt-dev freetype libpng libjpeg-turbo freetype-dev libpng-dev libjpeg-turbo-dev $PHPIZE_DEPS
+
+# # 安装PHP扩展
+# RUN docker-php-ext-install pdo_mysql gd opcache pcntl bcmath
+
+# # 安装PECL扩展
+# RUN pecl install xdebug redis \
+#     && docker-php-ext-enable xdebug \
+#     && docker-php-ext-enable redis
+

+ 6 - 0
using-fixed-ip/99-xdebug.ini

@@ -0,0 +1,6 @@
+xdebug.remote_enable=0
+xdebug.remote_host=remotehost
+xdebug.remote_handler=dbgp
+xdebug.remote_port=9009
+xdebug.remote_autostart=0
+xdebug.remote_log=/tmp/xdebug.log

+ 9 - 0
using-fixed-ip/Dockerfile

@@ -0,0 +1,9 @@
+FROM daocloud.io/library/php:5.6-fpm
+
+RUN pecl list-channels
+RUN pecl update-channels
+RUN pecl install xdebug-2.7.2 \
+    && docker-php-ext-enable xdebug
+
+COPY 99-xdebug.ini /usr/local/etc/php/conf.d/
+

+ 21 - 0
using-fixed-ip/app.conf

@@ -0,0 +1,21 @@
+server {
+    index index.php index.html;
+    server_name _;
+    error_log  /var/log/nginx/error.log;
+    access_log /var/log/nginx/access.log;
+    root /var/www/html;
+
+    location ~ \.php$ {
+        try_files $uri =404;
+        fastcgi_split_path_info ^(.+\.php)(/.+)$;
+        fastcgi_pass php-fpm:9000;
+        fastcgi_index index.php;
+        include fastcgi_params;
+        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+        fastcgi_param PATH_INFO $fastcgi_path_info;
+
+        fastcgi_param PHP_VALUE "xdebug.remote_autostart=1
+        xdebug.remote_enable=1 
+        xdebug.remote_host=192.168.0.104";
+    }
+}

+ 15 - 0
using-fixed-ip/docker-compose.yml

@@ -0,0 +1,15 @@
+version: '2'
+services:
+  nginx:
+    image: nginx:latest
+    volumes:
+      - ./app.conf:/etc/nginx/conf.d/app.conf
+      - ./php_testapp:/var/www/html
+    ports:
+      - "8080:80"
+  php-fpm:
+    build: .
+    volumes:
+      - ./php_testapp:/var/www/html
+    
+    

+ 3 - 0
using-fixed-ip/php_testapp/index.php

@@ -0,0 +1,3 @@
+<?
+phpinfo();
+

+ 16 - 0
using-ssh/Dockerfile

@@ -0,0 +1,16 @@
+FROM php:5.6-fpm
+RUN pecl install xdebug-2.5.3 \
+    && docker-php-ext-enable xdebug
+
+COPY 99-xdebug.ini /usr/local/etc/php/conf.d/
+
+RUN apt update && apt install -y openssh-server supervisor
+RUN mkdir /var/run/sshd
+RUN sed -i -e 's/PermitRootLogin without-password/PermitRootLogin yes/' -e '/AuthorizedKeysFile/s/^# *//' -e '/UsePrivilegeSeparation/s/yes/no/' /etc/ssh/sshd_config
+RUN echo 'root:mypassword' | chpasswd
+
+#RUN mkdir /root/.ssh && ssh-keygen -t rsa -P "" -C "SSH Client Key for XDebug" -f /root/.ssh/xdebug_client && cat /root/.ssh/xdebug_client.pub >> /root/.ssh/authorized_keys
+COPY supervisor_app.conf /etc/supervisor/conf.d/
+RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
+EXPOSE 80 443 22
+CMD ["supervisord", "-n"]

+ 21 - 0
using-ssh/app.conf

@@ -0,0 +1,21 @@
+server {
+    index index.php index.html;
+    server_name _;
+    error_log  /var/log/nginx/error.log;
+    access_log /var/log/nginx/access.log;
+    root /var/www/html;
+
+    location ~ \.php$ {
+        try_files $uri =404;
+        fastcgi_split_path_info ^(.+\.php)(/.+)$;
+        fastcgi_pass php-fpm:9000;
+        fastcgi_index index.php;
+        include fastcgi_params;
+        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+        fastcgi_param PATH_INFO $fastcgi_path_info;
+
+        fastcgi_param PHP_VALUE "xdebug.remote_autostart=1
+        xdebug.remote_enable=1 
+        xdebug.remote_host=localhost";
+    }
+}

+ 16 - 0
using-ssh/docker-compose.yml

@@ -0,0 +1,16 @@
+version: '2'
+services:
+  nginx:
+    image: nginx:latest
+    volumes:
+      - ./app.conf:/etc/nginx/conf.d/app.conf
+      - ./php_testapp:/var/www/html
+    ports:
+      - "8080:80"
+  php-fpm:
+    build: .
+    volumes:
+      - ./php_testapp:/var/www/html
+    ports:
+      - "2222:22"
+    

+ 3 - 0
using-ssh/php_testapp/index.php

@@ -0,0 +1,3 @@
+<?
+phpinfo();
+

+ 5 - 0
using-ssh/supervisor_app.conf

@@ -0,0 +1,5 @@
+[program:php-fpm]
+command=php-fpm
+
+[program:sshd]
+command=/usr/sbin/sshd -D

+ 6 - 0
using-ssh/xdebug.ini

@@ -0,0 +1,6 @@
+xdebug.remote_enable=0
+xdebug.remote_host=remotehost
+xdebug.remote_handler=dbgp
+xdebug.remote_port=9009
+xdebug.remote_autostart=0
+xdebug.remote_log=/tmp/xdebug.log