update php dockerize

This commit is contained in:
xfy
2024-06-23 10:04:40 +08:00
parent fc30b31c11
commit 90ea0cb8f7
5 changed files with 39 additions and 33 deletions

View File

@ -7,28 +7,7 @@ server {
index index.php index.html;
root /var/www/html/public;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
}
# index index.php;
# try_files $uri $uri/ $uri.php;
}
# location / {
# root /usr/share/nginx/html;
# index index.html index.htm;
# }
root /var/www/html/;
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
@ -46,13 +25,20 @@ server {
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
# root html;
# fastcgi_pass php-fpm:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one

View File

@ -4,19 +4,21 @@ services:
web:
image: nginx:alpine
ports:
- "4001:80"
- "4000:80"
volumes:
- ./src:/var/www/html
- ./conf.d/:/etc/nginx/conf.d/
- ./nginx.conf:/etc/nginx/nginx.conf
links:
- php-fpm
db:
image: mysql
image: mysql:5.7
platform: linux/amd64
environment:
MYSQL_ROOT_PASSWORD: qwer1234
php-fpm:
image: php:7-fpm
image: php:7-fpm-alpine
volumes:
- ./src:/var/www/html

View File

@ -26,7 +26,7 @@ http {
keepalive_timeout 65;
#gzip on;
gzip on;
include /etc/nginx/conf.d/*.conf;
}

15
dockerfiles/php/src/index.html Executable file
View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<h1>Hello, World</h0>
</body>
</html>

3
dockerfiles/php/src/index.php Normal file → Executable file
View File

@ -0,0 +1,3 @@
<?php
echo phpinfo();