-
Notifications
You must be signed in to change notification settings - Fork 0
/
nginx_php_docker
executable file
·63 lines (52 loc) · 1.29 KB
/
nginx_php_docker
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
siteDir="/srv/site"
confDir="/srv/config"
owner="aaron"
port=8080
# No need to change anything below this line
mkdir -pv ${siteDir} ${confDir}
chown -v ${owner} ${siteDir} ${confDir}
echo "Create site config..."
cat <<EOF > ${confDir}/default.conf
server {
index index.php index.html;
server_name ${owner}web.local;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
root /var/www/html;
location ~ \.php\$ {
try_files \$uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
fastcgi_pass php:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
fastcgi_param PATH_INFO \$fastcgi_path_info;
}
}
EOF
echo "Create compose file..."
cat <<EOF > ${confDir}/docker-compose.yml
version: "3.9"
services:
web:
image: nginx:latest
ports:
- "${port}:80"
volumes:
- ${siteDir}:/var/www/html
- ${confDir}/default.conf:/etc/nginx/conf.d/default.conf
links:
- php
php:
image: php:8-fpm
volumes:
- ${siteDir}:/var/www/html
EOF
echo "Create index page..."
echo "<?php phpinfo(); ?>" > ${siteDir}/index.php
echo
echo "Put site files in ${siteDir}"
echo
echo "Run :: docker-compose -f ${confDir}/docker-compose.yml up"
exit 0