-
Notifications
You must be signed in to change notification settings - Fork 0
/
ORH-Build.sh
350 lines (140 loc) · 5.87 KB
/
ORH-Build.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
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
#!/bin/bash
#Author Jim Gogarty
#Description : Scrtipt to automate the creation of ORH servers.
#Version 0.01
###################################################
#Change the server hsot name to Cluster name
#get the new server name and asign to var
#edit the host config files to add the new host name
sudo hostname $servername
echo $ip $servername /etc/hosts
eccho $servernaem >> /etc/hostname
#apache tests and config
sudo apache2ctl configtest
#take return and verify
#curl http://icanhazip.com >> ~/ipaddress.txt
#sudo chown -R ubuntu:www-data /var/www/html
#change the set bit
sudo find /var/www/html -type d -exec chmod g+s {} \;
#####################################################
#MYSQL SETUP
mysql_secure_installation <<<SQL_FILE
#ENTER THE PASSWORD
SQL_FILE
#DROP EXISTING DATABASES
mysql -u root -p <<SQL_FILE
DROP DATABASE wordpress1;
DROP DATABASE wordpress2;
DROP DATABASE wordpress3;
DROP DATABASE wordpress4;
DROP DATABASE wordpress5;
#CREATE NEW DATABASES
CREATE DATABASE wordpress1 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE DATABASE wordpress2 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE DATABASE wordpress3 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE DATABASE wordpress4 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
CREATE DATABASE wordpress5 DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
#GIVE THE WORDPRESS USER ACCESS TO THE NEW DATABASES
GRANT ALL ON wordpress1.* TO 'wordpress_user'@'localhost' IDENTIFIED BY '$new_wp_pswd';
FLUSH PRIVILEGES;
EXIT
SQL_FILE
######################################################
#ENABLE .HTACCESS OVERRIDES
sudo nano /etc/apache2/apache2.conf
#ADD THE FOLLOWING
<Directory /var/www/html/>
AllowOverride All
#more to add
</Directory>
#ENABLE MOD_REWRITE
sudo a2enmod rewrite
#TEST CONFIGURATION OF APACHE
sudo apache2ctl configtest
############################################################
#CREATE VITTUAL HOSTS before installing wordpress
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/example.com.conf
sudo nano /etc/apache2/sits-available/example1.conf
#NEED TO REMOVE OLD SITES FROM THE /etc/apache2/sites-enabled
#this should fix errors when the server is rebooted
#enabale the change
sudo a2ensite EXAMPLE.COM.conf
#disable the default conf
#restart the server
sudo systemctl restart apache2
sudo service apache2 restart
#set the local hosts file
#NEED TO SEND THE DOMAINS TO THE NEW SITES ON GODADDY
#ALLWAYS CHECK THE DOMAIN FIRST !!!!!
# AND COPY THE CURENT IP BEFORE asigning new IP.
##########################################################
#WORDPRESS INSTALLATION
cd /temp/
curl -O https://wordpress.org/latest.tar.gz
#expand the file
tar xzvf latest.tar.gz
touch /tmp/wordpress/.htaccess
chmod 600 /tmp/wordpress/.htaccess
ls -
cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
mkdir /tmp/wordpress/wp-content/upgrade
mkdir /tmp/wordpress/wp-content/upload
#MOVE THE WORDPRESS DIR TO THE WWW DIR UNDER THE SUB-DIR
sudo cp -a /tmp/wordpress/. /var/www/html
#THIS SHOULD BE CHANGED FOR EACH VURTUAL HOST
sudo chown -R ubuntu:www-data /var/www/html
#SET THE SETGID BIT
sudo find /var/www/html -type d -exec chmod g+s {} \;
#CHANGE THE PREMISSIONS ON THE FOLLOWING DIRS
sudo chmod g+w /var/www/html/wp-content
sudo chmod -R g+w /var/www/html/wp-content/themes
sudo chmod -R g+w /var/www/html/wp-content/plugins
sudo chmod -R g+w /var/www/html/wp-content/uploads
#NOW YOU CAN COPY THE WPRODPRES INSTALL TO THE OTHE DOMOANS
sudo cp -rp /tmp/wordpress/. /var/www/html/$DOMAIAN_NAME
#copy the template site to the the html folder
#sudo cp -rp ...
#NEED TO ADD LINE TO TEMPLATE functions.php
#update_option( 'siteurl', 'http://example.com' );
#update_option( 'home', 'http://example.com' );
1
##
# secure and config file edit
curl -s https://api.wordpress.org/secret-key/1.1/salt/
define('AUTH_KEY', 's*y~kM>>C)J<+B.U9{S1%:2R3n:W[<&<-C!b6_8_O:=an,uA#wxs_BV?-N&_#n5g');
define('SECURE_AUTH_KEY', '4B?tt0^Mm|:Bk[?w@3@,I*p3#<i{$2Um8[-3$;>r|[8>`]{u?hTG+qgvr-$!%z55');
define('LOGGED_IN_KEY', '@SVSw?A$[{%p}&Bqxd:)k1p+yVBRiV#O_ijjLpxIq%-^}biYv9|ee:p2]H2<{Yo$');
define('NONCE_KEY', 'm]REX+cCy+AN>`*f-|xHP==fv_KD)JnF9w($&G!=d-f/ii[k&2>>Gp351&BpM+qw');
define('AUTH_SALT', 'q`UA9gBRWo_,I[UT.:]+3qI<ZEyArh:Fzh,BO401EQ|%0dE8<QNl,w;GDY.%|Qe%');
define('SECURE_AUTH_SALT', '03*ZBm:hfjTvKCcBr-`1g6<O1TV*p8Knz:by2Yyl&4WyQtW-Y}.1SH<>bl(I^fc.');
define('LOGGED_IN_SALT', 'Lg=%7VTE$qbQiK+`79u#11=akF|rU-$uD+&Q87R4VxC#P]_b9=p(EKjDtH!O)-Tk');
define('NONCE_SALT', 'dVgnt0^NgCN^YLBGg@dDnn(l`/io%EJzhCA|.BN9,877~D)%7kO;6hJ(|XBG*R%m');
#add this after the salts
define('FS_METHOD', 'direct');
#ADD THE DB CONNECTION DETAILS TO THE WP-CONFIG.PHP FILE
#ALSO ADD THIS TO THE WP-CONFIG.PHP FILE AT THE BOTTOM
define('WP_HOME','https://DOMAIN_OF_SITE/');
define('WP_SITEURL','https://DOMAIN_OF_SITE/');
###############################################################################################
#SSL CERT INSTALLATION
#will i hav to do this 5 times or will the cert to for 5 VHosts
#create a ssl cert for the site useing cert bot on lets crypt
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install python-certbot-apache -y
sudo certbot --apache -d $ADD_URL -d $ADD_WWW._URL
sudo crontab -e
15 3 * * * /usr/bin/certbot renew --quiet
sudo certbot --apache
#auto renew the certs
#test
#sudo certbot renew --dry-run
certbot renew
###########################################################
define( 'WP_DEFAULT_THEME', 'your-theme-name' );
#WORDPRESS UPDATES
#Change the premissions to www-data user
sudo chown -R www-data /var/www/html
#change the premssions back
sudo chown -R ubuntu /var/www/html