-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-install.sh
127 lines (120 loc) · 3.14 KB
/
wp-install.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
#!/bin/bash
# Skripta za instaliranje WordPress na Ubuntu
#
# Kreiraj nova baza
function create_new_db {
echo -n "Enter password for the MySQL root account: "
read -s rootpass
echo ""
Q00="CREATE DATABASE $dbname;"
Q01="USE $dbname;"
Q02="CREATE USER $dbuser@localhost IDENTIFIED BY '$dbpass';"
Q03="GRANT ALL PRIVILEGES ON $dbname.* TO $dbuser@localhost;"
Q04="FLUSH PRIVILEGES;"
SQL0="${Q00}${Q01}${Q02}${Q03}${Q04}"
mysql -v -u "root" -p$rootpass -e"$SQL0"
}
# Download na WordPress, modifikacija na wp-config.php i menuvanje permisii
function install_wp {
wget http://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
cp -rf wordpress/** ./
rm -R wordpress
cp wp-config-sample.php wp-config.php
sed -i "s/database_name_here/$dbname/g" wp-config.php
sed -i "s/username_here/$dbuser/g" wp-config.php
sed -i "s/password_here/$dbpass/g" wp-config.php
wget -O wp.keys https://api.wordpress.org/secret-key/1.1/salt/
sed -i '/#@-/r wp.keys' wp-config.php
sed -i "/#@+/,/#@-/d" wp-config.php
mkdir wp-content/uploads
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
chown -R :www-data wp-content/uploads
chown -R $USER: *
chmod 640 wp-config.php
rm -f latest.tar.gz
rm -f wp-install.sh
rm -f wp.keys
}
# Kreiranje na .htaccess
function generate_htaccess {
touch .htaccess
chown :www-data .htaccess
chmod 644 .htaccess
bash -c "cat > .htaccess" << _EOF_
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
<Files wp-config.php>
order allow,deny
deny from all
</Files>
Options All -Indexes
_EOF_
}
# Kreiranje na robots.txt
function generate_robots {
touch robots.txt
bash -c "cat > robots.txt" << _EOF_
# Sitemap: absolute url
User-agent: *
Disallow: /cgi-bin/
Disallow: /wp-admin/
Disallow: /wp-includes/
Disallow: /wp-content/plugins/
Disallow: /wp-content/cache/
Disallow: /wp-content/themes/
Disallow: /trackback/
Disallow: /comments/
Disallow: */trackback/
Disallow: */comments/
Disallow: wp-login.php
Disallow: wp-signup.php
_EOF_
}
##### Prasanja za user
echo "Please insert the information required for the WordPress installation."
echo -n "WordPress database name: "
read dbname
echo -n "WordPress database user: "
read dbuser
echo -n "WordPress database password: "
read -s dbpass
echo ""
echo -n "Install Wordpress? [Y/n] "
read instwp
echo -n "Create a NEW database with entered info? [Y/n] "
read newdb
##### Proces i proverka
if [ "$newdb" = y ] || [ "$newdb" = Y ]
then
create_new_db
install_wp
generate_htaccess
generate_robots
download_plugins
else
if [ "$instwp" = y ] || [ "$instwp" = Y ]
then
install_wp
generate_htaccess
generate_robots
fi
fi
echo -n "Now, go to your new WordPress and finish the installation!"
echo ""