no message
This commit is contained in:
parent
e4a60ff96c
commit
78b06025c9
|
@ -0,0 +1,18 @@
|
|||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
location / {
|
||||
root /var/www/html;
|
||||
index index.html index.htm index.php;
|
||||
}
|
||||
error_page 500 502 503 504 /50x.html;
|
||||
location = /50x.html {
|
||||
root /var/www/html;
|
||||
}
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass php:9000;
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name;
|
||||
include fastcgi_params;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
version: '3'
|
||||
services:
|
||||
nginx:
|
||||
image: nginx:latest
|
||||
# 端口映射
|
||||
ports:
|
||||
- "80:80"
|
||||
# 依赖关系 先跑php
|
||||
depends_on:
|
||||
- "php"
|
||||
# 数据卷
|
||||
volumes:
|
||||
# 映射主机./conf.d目录到容器/etc/nginx/conf.d目录
|
||||
- "$PWD/conf.d:/etc/nginx/conf.d"
|
||||
- "$PWD/html:/usr/share/nginx/html"
|
||||
networks:
|
||||
- app_net
|
||||
# 容器名称
|
||||
container_name: "compose-nginx"
|
||||
php:
|
||||
build: ./php-mysqli
|
||||
image: php:7.2-fpm-mysqli
|
||||
ports:
|
||||
- "9000:9000"
|
||||
volumes:
|
||||
- "$PWD/html:/var/www/html"
|
||||
networks:
|
||||
- app_net
|
||||
container_name: "compose-php"
|
||||
mysql:
|
||||
image: mysql:5.7
|
||||
ports:
|
||||
- "3306:3306"
|
||||
# 环境变量
|
||||
environment:
|
||||
# mysql密码
|
||||
- MYSQL_ROOT_PASSWORD=123456
|
||||
networks:
|
||||
app_net:
|
||||
# 固定子网ip,网段必须在子网络10.10.*.*
|
||||
ipv4_address: 10.10.10.1
|
||||
container_name: "compose-mysql"
|
||||
networks:
|
||||
# 配置docker network
|
||||
app_net:
|
||||
driver: bridge
|
||||
ipam:
|
||||
config:
|
||||
# 子网络
|
||||
- subnet: 10.10.0.0/16
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
$link = mysqli_connect("172.18.0.2:3306", "root", "123456", "mysql");
|
||||
|
||||
if (!$link) {
|
||||
echo "Error: Unable to connect to MySQL." . PHP_EOL;
|
||||
echo "</br>";
|
||||
|
||||
echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
|
||||
echo "</br>";
|
||||
|
||||
echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
|
||||
exit;
|
||||
}
|
||||
|
||||
echo "Success: A proper connection to MySQL was made! The my_db database is great." . PHP_EOL. "\n";
|
||||
echo "Host information: " . mysqli_get_host_info($link) . PHP_EOL. "\n";
|
||||
|
||||
mysqli_close($link);
|
||||
?>
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
phpinfo();
|
|
@ -0,0 +1,5 @@
|
|||
FROM php:7.2-fpm
|
||||
|
||||
RUN apt-get update \
|
||||
&& apt-get install iputils-ping \
|
||||
&& docker-php-ext-install mysqli && docker-php-ext-enable mysqli
|
Loading…
Reference in New Issue