forked from aliaskov/bashscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAmazon_Linux_LAMP_Wordpress
More file actions
44 lines (40 loc) · 1.76 KB
/
Amazon_Linux_LAMP_Wordpress
File metadata and controls
44 lines (40 loc) · 1.76 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
#!/bin/bash
sudo yum update -y
sudo yum install -y httpd mariadb-server mariadb php php-xml php-intl php-gd php-mbstring php-mysql php-fpm
sudo systemctl start mariadb
sudo systemctl enable mariadb
systemctl start httpd
sudo systemctl enable httpd
# Make sure that NOBODY can access the server without a password
mysql -e "UPDATE mysql.user SET Password = PASSWORD('rootroot') WHERE User = 'root'"
# Kill the anonymous users
mysql -e "DROP USER ''@'localhost'"
# Because our hostname varies we'll use some Bash magic here.
mysql -e "DROP USER ''@'$(hostname)'"
# Kill off the demo database
mysql -e "DROP DATABASE test"
# Make our changes take effect
mysql -e "FLUSH PRIVILEGES"
# Any subsequent tries to run queries this way will get access denied because lack of usr/pwd param
usermod -a -G apache ec2-user
chown -R ec2-user:apache /var/www
chmod 2775 /var/www
find /var/www -type d -exec chmod 2775 {} \;
find /var/www -type f -exec chmod 0664 {} \;
echo "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php
mysql -u root -prootroot -e "CREATE DATABASE wordpress"
mysql -u root -prootroot -e "CREATE USER wordpressuser@localhost IDENTIFIED BY 'wordpresspassword'"
mysql -u root -prootroot -e "GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'wordpresspassword'"
mysql -u root -prootroot -e "FLUSH PRIVILEGES"
cd ~
wget http://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
sudo rsync -avP ~/wordpress/ /var/www/html/
mkdir /var/www/html/wp-content/uploads
sudo chown -R apache:apache /var/www/html/*
cd /var/www/html
cp wp-config-sample.php wp-config.php
sed -i -e 's/database_name_here/wordpress/g' wp-config.php
sed -i -e 's/username_here/wordpressuser/g' wp-config.php
sed -i -e 's/password_here/wordpresspassword/g' wp-config.php
sudo service httpd restart