-
Notifications
You must be signed in to change notification settings - Fork 34
/
Dockerfile
421 lines (421 loc) · 11.9 KB
/
Dockerfile
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
FROM centos:7
ADD * /root/
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done);\
rm -f /etc/systemd/system/*.wants/*;\
rm -f /lib/systemd/system/basic.target.wants/*;\
rm -f /lib/systemd/system/anaconda.target.wants/*;\
rm -f /lib/systemd/system/local-fs.target.wants/*;\
rm -f /lib/systemd/system/multi-user.target.wants/*;\
rm -f /lib/systemd/system/sockets.target.wants/*udev*;\
rm -f /lib/systemd/system/sockets.target.wants/*initctl*;\
\cp -rfn /root/cgroup/* /sys/fs/cgroup/;\
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime;\
mkdir /www;\
\cp /root/index.php /www/;\
\cp /root/index.html /www/;\
mkdir /data;\
mkdir /data/mysql;\
useradd www;\
useradd mysql;\
chown -R www:www /www;\
chown -R mysql:mysql /data/mysql;\
# 全局准备
\cp /root/epel-7.repo /etc/yum.repos.d/epel-ali.repo;\
yum install yum-fastestmirror git zip cmake3 unzip expect crontabs -y;\
ln -s /usr/bin/cmake3 /usr/bin/cmake;\
# 安装Nginx
## 1准备工作
yum install gcc-c++ make perl -y;\
## 2安装pcre
cd /root/pcre-8.45;\
./configure;\
make;\
make install;\
## 3安装zlib
cd /root/zlib-1.2.11;\
./configure;\
make;\
make install;\
## 4安装openssl
## (已经通过ADD解压,无需操作)
## 5安装nginx
cd /root/nginx-1.21.4;\
./configure \
--prefix=/usr/local/nginx/ \
--with-http_v2_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-pcre=/root/pcre-8.45/ \
--with-zlib=/root/zlib-1.2.11/ \
--with-openssl=/root/openssl-1.1.1m;\
make;\
make install;\
\cp /root/nginx.conf /usr/local/nginx/conf/nginx.conf;\
\cp /root/nginx.service /etc/systemd/system/nginx.service;\
ln -s /etc/systemd/system/nginx.service /etc/systemd/system/multi-user.target.wants/nginx.service;\
chown -R www:www /usr/local/nginx;\
# 安装php7
## 1准备工作
yum install autoconf sqlite-devel libxml2-devel openssl-devel re2c -y;\
## 2安装php
cd /root/php-7.4.27;\
./configure \
--prefix=/usr/local/php7 \
--enable-mysqlnd \
--enable-sockets \
--with-openssl \
--enable-fpm;\
make;\
make install;\
\cp /root/composer7 /usr/local/php7/bin/composer;\
ln -s /usr/local/php7/bin/composer /usr/local/php7/bin/composer7;\
\cp /root/cacert7.pem /usr/local/php7/lib/cacert.pem;\
\cp /root/php7.ini /usr/local/php7/lib/php.ini;\
\cp /root/php7-fpm.conf /usr/local/php7/etc/php-fpm.conf;\
\cp /root/www7.conf /usr/local/php7/etc/php-fpm.d/www.conf;\
\cp /root/php7.service /etc/systemd/system/php7.service;\
ln -s /etc/systemd/system/php7.service /etc/systemd/system/multi-user.target.wants/php7.service;\
ln -s /usr/local/php7/bin/php /usr/local/php7/bin/php7;\
chmod -R 755 /usr/local/php7/bin/composer;\
## 3扩展安装
### bcmath
cd /root/php-7.4.27/ext/bcmath;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### curl
yum install curl-devel -y;\
cd /root/php-7.4.27/ext/curl;\
/usr/local/php7/bin/phpize;\
./configure CC=c99 --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### gd
yum install libXpm-devel libpng-devel libjpeg-devel libwebp-devel freetype-devel -y;\
cd /root/php-7.4.27/ext/gd;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config \
--with-xpm \
--with-jpeg \
--with-webp \
--with-freetype;\
make;\
make install;\
### calendar
cd /root/php-7.4.27/ext/calendar;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### intl
yum install libicu-devel -y;\
cd /root/php-7.4.27/ext/intl;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### mbstring
yum install oniguruma-devel -y;\
cd /root/php-7.4.27/ext/mbstring;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### mcrypt
yum install libmcrypt-devel -y;\
cd /root/mcrypt-1.0.4;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### mysqli
cd /root/php-7.4.27/ext/mysqli;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### pdo_mysql
cd /root/php-7.4.27/ext/pdo_mysql;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### sockets
# cd /root/php-7.4.27/ext/sockets;\
# /usr/local/php7/bin/phpize;\
# ./configure --with-php-config=/usr/local/php7/bin/php-config;\
# make;\
# make install;\
### bz2
yum install bzip2-devel -y;\
cd /root/php-7.4.27/ext/bz2;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### zip
yum remove libzip-devel -y;\
cd /root/libzip-1.8.0;\
mkdir build;\
cd /root/libzip-1.8.0/build;\
cmake ..;\
make;\
make install;\
cd /root/php-7.4.27/ext/zip;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config PKG_CONFIG_PATH=/usr/local/lib64/pkgconfig/;\
make;\
make install;\
### zlib
cd /root/php-7.4.27/ext/zlib;\
\cp config0.m4 config.m4;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### opcache
cd /root/php-7.4.27/ext/opcache;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### redis
cd /root/redis-5.3.5;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### memcache
cd /root/memcache-4.0.5.2;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### memcached
yum install libmemcached-devel -y;\
cd /root/memcached-3.1.5;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### mongodb
cd /root/mongodb-1.12.0;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### pcntl
cd /root/php-7.4.27/ext/pcntl;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config;\
make;\
make install;\
### swoole
cd /root/nghttp2-1.46.0;\
./configure;\
make;\
make install;\
cd /root/swoole-4.8.5;\
/usr/local/php7/bin/phpize;\
./configure --with-php-config=/usr/local/php7/bin/php-config --enable-sockets --enable-http2 --enable-openssl --enable-mysqlnd;\
make;\
make install;\
## 4目录权限
chown -R www:www /usr/local/php7;\
# 安装php5
## 1准备工作
yum install autoconf libxml2-devel openssl-devel re2c -y;\
## 2安装php
cd /root/php-5.6.40;\
./configure \
--prefix=/usr/local/php5 \
--with-mysqli=mysqlnd \
--with-mysql=mysqlnd \
--enable-mysqlnd \
--enable-sockets \
--with-openssl \
--enable-fpm;\
make;\
make install;\
\cp /root/composer5 /usr/local/php5/bin/composer;\
ln -s /usr/local/php5/bin/composer /usr/local/php5/bin/composer5;\
\cp /root/cacert5.pem /usr/local/php5/lib/cacert.pem;\
\cp /root/php5.ini /usr/local/php5/lib/php.ini;\
\cp /root/php5-fpm.conf /usr/local/php5/etc/php-fpm.conf;\
\cp /root/php5.service /etc/systemd/system/php5.service;\
ln -s /usr/local/php5/bin/php /usr/local/php5/bin/php5;\
chmod -R 755 /usr/local/php5/bin/composer;\
## 3扩展安装
### bcmath
cd /root/php-5.6.40/ext/bcmath;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### curl
yum install curl-devel -y;\
cd /root/php-5.6.40/ext/curl;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### gd
yum install libXpm-devel libpng-devel libjpeg-devel libwebp-devel freetype-devel -y;\
cd /root/php-5.6.40/ext/gd;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config \
--with-png-dir \
--with-xpm-dir \
--with-jpeg-dir \
--with-zlib-dir \
--with-freetype-dir;\
make;\
make install;\
### calendar
cd /root/php-5.6.40/ext/calendar;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### intl
yum install libicu-devel -y;\
cd /root/php-5.6.40/ext/intl;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### mbstring
cd /root/php-5.6.40/ext/mbstring;\
/usr/local/php5/bin/phpize;\
./configure CC=c99 --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### mcrypt
yum install libmcrypt-devel -y;\
cd /root/php-5.6.40/ext/mcrypt;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### pdo_mysql
cd /root/php-5.6.40/ext/pdo_mysql;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### sockets
# cd /root/php-5.6.40/ext/sockets;\
# /usr/local/php5/bin/phpize;\
# ./configure --with-php-config=/usr/local/php5/bin/php-config;\
# make;\
# make install;\
### bz2
yum install bzip2-devel -y;\
cd /root/php-5.6.40/ext/bz2;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### zip
yum remove libzip-devel -y;\
cd /root/libzip-1.8.0;\
mkdir build;\
cd /root/libzip-1.8.0/build;\
cmake ..;\
make;\
make install;\
cd /root/php-5.6.40/ext/zip;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### zlib
cd /root/php-5.6.40/ext/zlib;\
\cp config0.m4 config.m4;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### opcache
cd /root/php-5.6.40/ext/opcache;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### redis
cd /root/redis-4.3.0;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### memcache
cd /root/memcache-3.0.8;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### memcached
yum install libmemcached-devel -y;\
cd /root/memcached-2.2.0;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### mongodb
cd /root/mongodb-1.5.5;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### pcntl
cd /root/php-5.6.40/ext/pcntl;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config;\
make;\
make install;\
### swoole
yum install libnghttp2-devel -y;\
cd /root/swoole-2.0.12;\
/usr/local/php5/bin/phpize;\
./configure --with-php-config=/usr/local/php5/bin/php-config --enable-sockets --enable-http2 --enable-openssl --enable-mysqlnd;\
make;\
make install;\
## 4目录权限
chown -R www:www /usr/local/php5;\
# 安装Nodejs
## 1安装Nodejs
cd /root;\
mv node-v16.13.1-linux-x64 /usr/local/node;\
## 2更新npm
/usr/local/node/bin/npm config set registry https://registry.npm.taobao.org -g;\
/usr/local/node/bin/npm install npm -g;\
## 3目录权限
chown -R www:www /usr/local/node;\
# 安装MySQL
## 1安装MySQL
\cp /root/limits.conf /etc/security/limits.conf;\
cd /root/;\
rpm -i mysql57-el7-10.noarch.rpm;\
yum install mysql-server -y;\
\cp /root/my.cnf /etc/my.cnf;\
\cp /root/mysqld.service /usr/lib/systemd/system/mysqld.service;\
ln -s /usr/lib/systemd/system/mysqld.service /etc/systemd/system/multi-user.target.wants/mysqld.service;\
# 快捷脚本
\cp /root/pvm /usr/bin;\
chmod -R 755 /usr/bin/pvm;\
\cp /root/owner /usr/bin;\
chmod -R 755 /usr/bin/owner;\
\cp /root/mysql_init /usr/bin;\
chmod -R 755 /usr/bin/mysql_init;\
\cp /root/owner.service /usr/lib/systemd/system/owner.service;\
ln -s /usr/lib/systemd/system/owner.service /etc/systemd/system/multi-user.target.wants/owner.service;\
# 删除所有安装包
rm -rf /root/*
# 环境变量
ENV PATH $PATH:/usr/local/php7/bin:/usr/local/php7/sbin:/usr/local/php5/bin:/usr/local/php5/sbin:/usr/local/nginx/sbin:/usr/local/node/bin
# 创建卷
VOLUME ["/sys/fs/cgroup","/www","/data/mysql"]
# 初始化
CMD ["/usr/sbin/init"]