-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode
62 lines (52 loc) · 2.46 KB
/
code
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
#
# ******************************************************************************************* #
# * V 1.0.0 * #
# * 26 April 2014 - By AJ Salkeld * #
# ******************************************************************************************* #
#
# TODO: - Add automatic wp-config.php creation (Due V 1.1.0)
# Web version
#
echo "Running..."
# *Query User*
echo -n "Enter desired new MySQL username for Wordpress database (MUST BE NEW), and press [ENTER]:"
read sqlUser # Variable for MySQL username
echo -n "Enter desired password for $sqlUser (MySQL user for Wordpress), and press [ENTER]:"
read sqlPasswd # Variable for MySQL user's password
# *Prep*
MYSQL=`which mysql` # Variable for MySQL set up later
# *Installation*
echo "Installing..."
apt-get update
apt-get remove -y --purge apache2 # Remove Apache JIC
apt-get install -f -y --force-yes nginx php5 php5-fpm mysql-server-5.5 mysql-client php5-mysql # Install packages
# *Nginx Config*
echo "Setting up Nginx..."
rm /etc/nginx/sites-enabled/* # Remove potentially conflicting virtual hosts (*/)
mv wordpress /etc/nginx/sites-available/wordpress # Add ours
ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/wordpress # Enable it
# *Wordpress*
mkdir /var/www # JIC
cd /var/www # Go to www directory
echo "Downloading"
wget http://wordpress.org/latest.zip # Download latest WP stable build
unzip latest.zip # Extract it
rm latest.zip # Delete zip after extraction
chown -R www-data:www-data /var/www # Allow nginx to edit directory files
# *Restart Packages*
echo "Restarting packages..."
service php5-fpm restart # Restart php-fpm
service nginx restart # and Nginx
# *Configure MySQL*
echo "Setting up MySQL"
Q1="CREATE DATABASE IF NOT EXISTS wordpress;" # Make database 'wordpress'
Q2="GRANT ALL ON wordpress.* TO '$sqlUser'@'localhost' IDENTIFIED BY '$sqlPasswd';" # Create user '$sqlUser' + allow it to edit wordpress
Q3="FLUSH PRIVILEGES;"
SQL="${Q1}${Q2}${Q3}" # Add instructions to variable for MySQL prompt
$MYSQL -u root -p -e "$SQL" # Run MySQL instructions
# *Further Instructions*
echo "Now point your browser at the server and follow the Wordpress installation instructions."
echo "The MySQL database is 'wordpress', the user is '$sqlUser' and the password is '$sqlPasswd', as you set earlier."
echo "If all goes well, you now have a Wordpress blog."
echo "That's all folks!"
# *END*