enlt commited on
Commit
f193979
·
1 Parent(s): 18b5132

基础php文件

Browse files
Files changed (2) hide show
  1. Dockerfile +9 -11
  2. default.conf +0 -20
Dockerfile CHANGED
@@ -1,16 +1,14 @@
1
- FROM php:8.0-apache
2
-
3
- RUN apt-get update && apt-get install -y nginx
4
 
 
5
  COPY ./FILES/ /var/www/html/
6
 
7
- RUN mkdir -p /var/cache/nginx && \
8
- chown -R www-data:www-data /var/cache/nginx /var/run /var/log/nginx /var/www/html
9
-
10
- COPY default.conf /etc/nginx/conf.d/
11
-
12
- RUN docker-php-ext-install mysqli pdo pdo_mysql
13
 
14
- EXPOSE 80
 
15
 
16
- CMD service nginx start && apache2-foreground
 
 
1
+ # 使用官方的 PHP CLI 镜像
2
+ FROM php:8.0-cli
 
3
 
4
+ # 将当前目录的所有内容复制到容器内的 /var/www/html 目录
5
  COPY ./FILES/ /var/www/html/
6
 
7
+ # 设置工作目录
8
+ WORKDIR /var/www/html/
 
 
 
 
9
 
10
+ # 暴露容器的 7860 端口,以便外部可以访问
11
+ EXPOSE 7860
12
 
13
+ # 启动 PHP 内置服务器,并将标准错误输出重定向到 /dev/null
14
+ CMD ["sh", "-c", "php -S 0.0.0.0:7860 -t /var/www/html/ 2>/dev/null"]
default.conf DELETED
@@ -1,20 +0,0 @@
1
- server {
2
- listen 80;
3
- server_name localhost;
4
-
5
- root /var/www/html;
6
- index index.php index.html;
7
-
8
- location / {
9
- try_files $uri $uri/ /index.php?$query_string;
10
- }
11
-
12
- location ~ \.php$ {
13
- include snippets/fastcgi-php.conf;
14
- fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
15
- }
16
-
17
- location ~ /\.ht {
18
- deny all;
19
- }
20
- }