Dokerfile
FROM php:7.4-fpm # php 版本低于8的话安装swoole建议指定版本 RUN apt-get update && apt-get install -y \ libfreetype6-dev \ libjpeg62-turbo-dev \ libpng-dev \ libzip-dev \ libssl-dev \ git \ unzip \ && docker-php-ext-install -j$(nproc) mysqli pdo_mysql gd zip opcache bcmath \ && docker-php-ext-configure gd --with-freetype=/usr/include/ --with-jpeg=/usr/include/ docker-php-ext-install gd \ # && pecl install swoole-4.7.1 redis \ # && docker-php-ext-enable swoole redis \ && curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
运行容器
docker run --name run-php-74-fpm -p 9002:9000 -v /Users/macos/Documents/Project/Env/Log/Php7:/var/www/html -v /Users/macos/Documents/Project/PHP:/usr/local/etc -v /Users/macos/Documents/Project/Env/Php7.4:/var/log/php -d php-7.4-fpm
nginx配置
server { listen 80; server_name local.admin.com; # php-fpm容器中的项目位置 root /var/www/html/fastadmin/public; # aHjdVpIXqe为安装fastadmin生成的admin入口文件 index index.php aHjdVpIXqe.php index.html index.htm; client_max_body_size 120M; error_log /opt/homebrew/var/log/nginx/8090error.log; location / { if (!-e $request_filename) { rewrite ^(.*)$ /aHjdVpIXqe.php?s=/$1 last; break; } } # 解决nginx访问静态资源404的问题,如下地址为宿主机项目地址 location /assets { alias /Users/macos/Documents/Project/PHP/fastadmin/public/assets/; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { # docker php-fpm容器运行的端口 fastcgi_pass 127.0.0.1:9002; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
标签:index,MacOS,&&,--,Nginx,html,fastadmin,docker,php From: https://www.cnblogs.com/chenjiangbin/p/17520064.html