Phpstorm docker php74-56 nginx mariadb 发表于 2021-02-10 | 更新于 2025-08-28
| 总字数: 984 | 阅读时长: 5分钟 | 浏览量:
Phpstorm 折磨的我头很大,难受
Docker 配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 version: "3" services: db: hostname: db image: mariadb:latest container_name: db restart: on-failure:3 volumes: - ./server/db:/var/lib/mysql ports: - 31004 :3306 command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW environment: - MYSQL_ROOT_PASSWORD=123456 - MYSQL_PASSWORD=123456 - MYSQL_DATABASE=test - MYSQL_USER=test php: hostname: php build: context: ./server dockerfile: Dockerfile.php56 image: php56 container_name: php56 volumes: - ./www/html:/var/www/html restart: on-failure:3 networks: - default nginx: hostname: nginx container_name: nginx image: nginx:latest restart: on-failure:3 ports: - 31003 :80 links: - php volumes: - ./server/default.conf:/etc/nginx/conf.d/default.conf:rw - ./www:/var/www networks: default:
PHP 配置 docker-php56-xdebug.ini 1 2 3 4 5 zend_extension =/usr/local/lib/php/extensions/no -debug-non-zts-20131226 /xdebug.soxdebug.remote_enable = on xdebug.remote_host = docker.for.mac.localhostxdebug.remote_port = 9003 xdebug.idekey ="PHPSTORM"
docker-php74-xdebug.ini 1 2 3 4 5 6 7 zend_extension =/usr/local/lib/php/extensions/no -debug-non-zts-20190902 /xdebug.soxdebug.mode =debugxdebug.remote_handler =dbgpxdebug.client_host =docker.for.mac.localhostxdebug.start_with_request =yes xdebug.client_port =9003 xdebug.idekey ="PHPSTORM"
Dockerfile.php56 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 FROM php:5.6 -fpmCOPY sources.list /etc/apt/sources.list RUN apt update RUN /usr/local/bin/pecl install xdebug-2.5.5 COPY docker-php56-xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini RUN cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini RUN /usr/local/bin/docker-php-source extract RUN apt install net-tools iputils-ping -y STOPSIGNAL SIGQUITEXPOSE 9000 CMD ["php-fpm" ]
Dockerfile.php74 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 FROM php:7.4 -fpmCOPY sources.list /etc/apt/sources.list RUN apt update RUN /usr/local/bin/pecl install xdebug-3.0.2 COPY docker-php-ext-xdebug.ini /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini RUN cp /usr/local/etc/php/php.ini-development /usr/local/etc/php/php.ini RUN /usr/local/bin/docker-php-source extract RUN apt install net-tools iputils-ping -y STOPSIGNAL SIGQUITEXPOSE 9000 CMD ["php-fpm" ]
sources.list 1 2 3 4 5 6 7 8 9 deb http://mirrors.aliyun.com/debian/ stretch main non-free contrib deb-src http://mirrors.aliyun.com/debian/ stretch main non-free contrib deb http://mirrors.aliyun.com/debian-security stretch/updates main deb-src http://mirrors.aliyun.com/debian-security stretch/updates main deb http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib deb-src http://mirrors.aliyun.com/debian/ stretch-updates main non-free contrib deb http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib deb-src http://mirrors.aliyun.com/debian/ stretch-backports main non-free contrib
Nginx 配置 default.conf 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 server { listen 80 listen [::] :80 server_name localhost root /var/www/html add_header X-Frame-Options "SAMEORIGIN" always add_header X-XSS-Protection "1 add_header X-Content-Type-Options "nosniff" always add_header Referrer-Policy "no-referrer-when-downgrade" always add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always location ~ /\.(?!well-known) { deny all } index index.php location / { try_files $uri $uri/ /index.php?$query_string } location = /favicon.ico { log_not_found off } location = /robots.txt { log_not_found off } location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ { expires 7d } location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ { add_header Access-Control-Allow-Origin "*" expires 7d } gzip on gzip_vary on gzip_proxied any gzip_comp_level 6 gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml location ~ \.php$ { try_files $fastcgi_script_name =404 include fastcgi_params fastcgi_pass php:9000 fastcgi_index index.php fastcgi_buffers 8 16k fastcgi_buffer_size 32k fastcgi_param DOCUMENT_ROOT $realpath_root fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name fastcgi_param PHP_ADMIN_VALUE "open_basedir =/var/www/html/:/usr/lib/php/:/tmp/"; } } # subdomains redirect server { listen 80; listen [::]:80; server_name *.localhost; return 301 http://localhost$request_uri; }
Phpstorm 配置 Bing 一下激活密钥
安装插件
Important 👇
👆Important
讨论 xdebug 参数配置
1 2 3 4 5 6 7 8 9 10 11 12 xdebug.mode =debugxdebug.client_host =docker.for.mac.localhost xdebug.start_with_request =yes xdebug.client_port =9003 xdebug.idekey ="PHPSTORM"
端口问题
php-fpm 默认 9000
不需要映射
php-fpm xdebug 默认 9003 不需要映射,否则端口冲突
nginx 连接 php-fpm 可使用 docker 容器 特性 php:9000
Nginx 配置文件不行 就在线 new 一个
Php 安装其他拓展
pecl install 就几m,一会儿就好了
1 2 3 4 5 6 docker-php-source extract cp xdebug /usr/src/phpdocker-php-ext-configure xdebug docker-php-ext-install xdebug docker-php-ext-enable xdebug ls /usr/local/etc/php/conf.d/
Php.ini 与 docker-php-ext-xdebug.ini 的区别 ?后者好 echo -e ''
XRSec has the right to modify and interpret this article. If you want to reprint or disseminate this article, you must ensure the integrity of this article, including all contents such as copyright notice. Without the permission of the author, the content of this article shall not be modified or increased or decreased arbitrarily, and it shall not be used for commercial purposes in any way