forked from jetsung/docker-nginx-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
122 lines (101 loc) · 3.2 KB
/
start.sh
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/bin/sh
#########################################################################
# File Name: start.sh
# Author: Skiychan
# Email: [email protected]
# Version:
# Created Time: 2015/12/13
#########################################################################
# Add PHP Extension
if [ -f "/data/phpext/extension.sh" ]; then
#Add support
yum install -y gcc \
gcc-c++ \
autoconf \
automake \
libtool \
make \
cmake && \
mkdir -p /home/extension && \
sh /data/phpext/extension.sh
mv /data/phpext/extension.sh /data/phpext/extension_back.sh
#Clean OS
yum remove -y gcc \
gcc-c++ \
autoconf \
automake \
libtool \
make \
cmake && \
yum clean all && \
rm -rf /tmp/* /var/cache/{yum,ldconfig} /etc/my.cnf{,.d} && \
mkdir -p --mode=0755 /var/cache/{yum,ldconfig} && \
find /var/log -type f -delete && \
rm -rf /home/extension/*
fi
Nginx_Install_Dir=/usr/local/nginx
DATA_DIR=/data/www
set -e
chown -R www.www $DATA_DIR
if [[ -n "$PROXY_WEB" ]]; then
[ -f "${Nginx_Install_Dir}/conf/ssl" ] || mkdir -p $Nginx_Install_Dir/conf/ssl
[ -f "${Nginx_Install_Dir}/conf/vhost" ] || mkdir -p $Nginx_Install_Dir/conf/vhost
if [ -z "$PROXY_DOMAIN" ]; then
echo >&2 'error: missing PROXY_DOMAIN'
echo >&2 ' Did you forget to add -e PROXY_DOMAIN=... ?'
exit 1
fi
if [ -z "$PROXY_CRT" ]; then
echo >&2 'error: missing PROXY_CRT'
echo >&2 ' Did you forget to add -e PROXY_CRT=... ?'
exit 1
fi
if [ -z "$PROXY_KEY" ]; then
echo >&2 'error: missing PROXY_KEY'
echo >&2 ' Did you forget to add -e PROXY_KEY=... ?'
exit 1
fi
if [ ! -f "${Nginx_Install_Dir}/conf/ssl/${PROXY_CRT}" ]; then
echo >&2 'error: missing PROXY_CRT'
echo >&2 " You need to put ${PROXY_CRT} in ssl directory"
exit 1
fi
if [ ! -f "${Nginx_Install_Dir}/conf/ssl/${PROXY_KEY}" ]; then
echo >&2 'error: missing PROXY_CSR'
echo >&2 " You need to put ${PROXY_KEY} in ssl directory"
exit 1
fi
cat > ${Nginx_Install_Dir}/conf/vhost/website.conf << EOF
server {
listen 80;
server_name $PROXY_DOMAIN;
return 301 https://$PROXY_DOMAIN\$request_uri;
}
server {
listen 443 ssl;
server_name $PROXY_DOMAIN;
ssl on;
ssl_certificate ssl/${PROXY_CRT};
ssl_certificate_key ssl/${PROXY_KEY};
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
keepalive_timeout 70;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
root $DATA_DIR;
index index.php index.html index.htm;
location / {
try_files \$uri \$uri/ /index.php?\$args;
}
location ~ \.php$ {
root /data/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /\$document_root\$fastcgi_script_name;
include fastcgi_params;
}
}
EOF
fi
/usr/bin/supervisord -n -c /etc/supervisord.conf