php学习

  1. 环境搭建
    参考:https://blog.csdn.net/Lichen0196/article/details/137376600
    参考:https://blog.csdn.net/weixin_43766229/article/details/134599682

  2. 环境搭建:docker + php-fpm+nginx 具体步骤

# php容器
docker run -p 9000:9000 -d --name php7 -v ./www:/var/www/html  -v ./php/conf.d/php.ini:/usr/local/etc/php/php.ini php:7.3-fpm

# nginx容器
docker run -p 8100:80 -d --name nginxphp -v ./www:/usr/share/nginx/html -v ./nginx/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf -v ./nginx/logs:/var/log/nginx nginx:latest

# nginx的default.conf
location ~ \.php$ {
        root           /var/www/html;
        fastcgi_pass   172.17.0.2:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    root   /usr/share/nginx/html;
    location / {
        # root   /usr/share/nginx/html;
        # index  index.html index.htm;
        index  index.html index.htm index.php;
    }
  1. docker-compose.yml
version: '3.7'
services:
  php:
    image: php:8.4.0alpha2-fpm-bullseye
    container_name: php
    restart: unless-stopped
    ports:
      - "9000:9000"
    volumes:
      - ./php/php.ini:/usr/local/etc/php/php.ini
      - ./php/conf.d:/usr/local/etc/php/conf.d
      - ./www:/var/www/html
    networks:
      - pn
  nginx:
    image: nginx:latest
    container_name: nginx
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf
      - ./www:/usr/share/nginx/html
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./nginx/logs:/var/log/nginx
    networks:
      - pn
networks:
  pn:
    driver: bridge
  1. 数据库支持
    参考:https://blog.csdn.net/longfeng995/article/details/130704949

  2. 访问宿主机端口
    参考:https://www.jb51.net/server/319306ue4.htm

  3. 其他

posted on 2024-07-19 10:13  朝朝暮Mu  阅读(14)  评论(0)    收藏  举报