FROM alpine:3.15.0
ADD default.conf /etc/nginx/http.d/
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.ustc.edu.cn/g' /etc/apk/repositories && \
apk update && \
apk add --no-cache nginx php8-fpm php8-sqlite3 php8-pdo php8-pdo_sqlite php8-json \
php8-mysqli php8-pdo_mysql php8-mbstring php8-gd php8-curl php8-session && \
EXPOSE 80/tcp
CMD php-fpm8 && nginx && ash 
VOLUME /var/www/localhost/htdocs
  • 当版本更新时,修改Alpine和PHP的版本号即可
  • 如果不在国内,可以不用修改源,或者可以使用更快的源
  • 可根据需要自行增删PHP扩展

因为默认的nginx配置文件不能正常工作,需要一个能正常工作的配置文件,正是上文需要的default.conf

server {
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/localhost/htdocs;
    index index.html index.htm index.php;
    server_name _;
    location / {
        try_files $uri $uri/ =404;
    }
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        try_files $fastcgi_script_name =404;
        set $path_info $fastcgi_path_info;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_index index.php;
        include fastcgi.conf;
        fastcgi_pass 127.0.0.1:9000;
    }
}

标签: Docker

评论已关闭