-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwp_install.sh
More file actions
executable file
·113 lines (88 loc) · 3.81 KB
/
wp_install.sh
File metadata and controls
executable file
·113 lines (88 loc) · 3.81 KB
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
#!/bin/bash
# WodPress install require WP Cli
# Colors for the outputs uses tput
GREEN="$(tput setaf 2)"
CLEAR="$(tput sgr0)"
BOLD="$(tput bold)"
# User input path for the installation folder
read -e -p 'Path to install WP (absolute, no / at the end) : ' -i '/home/veiss/historico3/' wppath
# Database creation
echo 'Lest create a database for WordPress'
read -p 'Name of the database : ' dbname
read -p 'User of the database : ' dbuser
read -p 'Password for the database : ' dbpassword
read -p 'Password for mysql root user : ' mysqlpassword
SQL1="CREATE DATABASE $dbname;"
SQL2="CREATE USER '$dbuser'@'localhost' IDENTIFIED BY '$dbpassword';"
SQL3="GRANT ALL PRIVILEGES ON $dbname.* TO '$dbuser'@'localhost' IDENTIFIED BY '$dbpassword';"
SQL4="FLUSH PRIVILEGES;"
mysql -h localhost -u root -p$mysqlpassword -Bse "$SQL1$SQL2$SQL3$SQL4"
echo $BOLD$GREEN'Database created correctly'$CLEAR
# cd in the target folder for the WP installation
cd $wppath
# Download WP
read -e -p 'Locale for the WordPress installation : ' -i 'en_US' wplocale
wp core download --locale=$wplocale
# Generate wp-config.php
PREFIX=$(echo "${dbname}" | head -c2)
read -e -p 'Prefix for the database tables (Do not use wp_) : ' -i "$PREFIX"'_' wpprefix
wp config create --dbname=$dbname --dbuser=$dbuser --dbpass=$dbpassword --locale=$wplocale --dbprefix=$wpprefix
# Install WP
read -p 'URL for the WordPress installation (without http://) : ' wpurl
read -p 'Title for the WordPress installation : ' wptitle
read -p 'User name for admin user : ' wpadmin
read -p 'Email of the admin user : ' wpadminemail
read -p 'Password for the admin user : ' wpadminpassword
wp core install --url=$wpurl --title=$wptitle --admin_user=$wpadmin --admin_password=$wpadminpassword --admin_email=$wpadminemail
echo $BOLD$GREEN'Wordpress installed correctly, lets install some plugins ...'$CLEAR
# WordPress Plugins
# Timber
read -p 'Do you want to install Timber (y/n) : ' installtimber
if [ $installtimber = 'y' ]
then
read -p 'Name for the Timber Starter Theme : ' timbertheme
wp plugin install timber-library --activate
cp -r $wppath'/wp-content/plugins/timber-library/timber-starter-theme' $wppath'/wp-content/themes'
mv $wppath'/wp-content/themes/timber-starter-theme' $wppath'/wp-content/themes/'$timbertheme
sed -i -e 's/My Timber Starter Theme/'$timbertheme'/g' $wppath'/wp-content/themes/'$timbertheme'/style.css'
sed -i -e 's/Starter Theme to use with Timber/'$wptitle'/g' $wppath'/wp-content/themes/'$timbertheme'/style.css'
sed -i -e 's/Upstatement and YOU!/'$wpadminemail'/g' $wppath'/wp-content/themes/'$timbertheme'/style.css'
wp theme activate $timbertheme
fi
# iThemes Security
read -p 'Do you want to install iThemes Security (y/n) : ' installithemes
if [ $installithemes = 'y' ]
then
wp plugin install better-wp-security --activate
fi
# WP Super Cache
read -p 'Do you want to install Wp Super cache (y/n) : ' installcache
if [ $installcache = 'y' ]
then
wp plugin install wp-super-cache --activate
fi
# Contact Form 7
read -p 'Do you want to install Contact Form 7 (y/n): ' installcontactform
if [ $installcontactform = 'y' ]
then
wp plugin install contact-form-7 contact-form-cfdb7 --activate
fi
# Rank Math
read -p 'Do you want to install Rank Math (y/n): ' installrankmath
if [ $installrankmath = 'y' ]
then
wp plugin install seo-by-rank-math --activate
fi
# YOAST
read -p 'Do you want to install YOAST Seo (y/n): ' installyoast
if [ $installyoast = 'y' ]
then
wp plugin install wordpress-seo --activate
fi
# Apache user
APACHE_USER=$(ps axho user,comm|grep -E "httpd|apache"|uniq|grep -v "root"|awk 'END {if ($1) print $1}')
# Fix Permissions
sudo chown -R $USER':'$APACHE_USER .
# File & Folder permissions
find . -type d -exec chmod 775 {} \; && find . -type f -exec chmod 664 {} \;
echo $BOLD$GREEN'All done OK, permissions OK, your site is ready in --> http://'$wpurl$CLEAR