[root@mexsvr6 phpnginx]# pwd
/data/phpnginx
[root@mexsvr6 phpnginx]# ls -l
total 12
-rw-r--r-- 1 root root 1272 Apr 23 10:26 _data_phpnginx_dzzoffice.conf
drwxr-xr-x 12 root root 4096 Apr 20 17:55 dzzoffice
-rwxrwxrwx 1 root root 582 Apr 23 10:25 phpng.sh
[root@mexsvr6 phpnginx]# cat phpng.sh
folder=$1
var=$(basename ${folder})
var=$(echo ${folder}|tr -s "/" "_")
dirname=$(dirname ${folder})
docker pull nginx
docker pull bitnami/php-fpm
docker run -d --name myFpm_${var} -P -v ${folder}:/usr/share/nginx/html bitnami/php-fpm
docker run -d --name myNginx_${var} --link myFpm_${var} -P -v ${folder}:/usr/share/nginx/html nginx
pushd ${dirname}
cp /data/dzoffice/dzzoffice.conf ${var}.conf
sed -i "s/myFpm/myFpm_${var}/g" ${var}.conf
docker cp ./${var}.conf myNginx_${var}:/etc/nginx/conf.d/default.conf
docker exec -it myNginx_${var} /bin/bash -ic "service nginx reload"
[root@mexsvr6 phpnginx]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/nginx latest b175e7467d66 3 weeks ago 108.9 MB
docker.io/bitnami/php-fpm latest f21a1ac1f797 4 weeks ago 208.6 MB
[root@mexsvr6 phpnginx]# cat /data/dzoffice/dzzoffice.conf
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass myFpm:9000;
#fastcgi_pass 172.17.0.3:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
index index.html index.htm index.php;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}