-
Notifications
You must be signed in to change notification settings - Fork 153
/
Copy pathAmazon_Linux_LAMP_MediaWIKI
40 lines (33 loc) · 1.55 KB
/
Amazon_Linux_LAMP_MediaWIKI
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
#!/bin/bash
sudo yum update -y
# amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
sudo yum install -y httpd24 mysql-server mysql php73 php73-xml php73-intl php73-gd php73-mbstring php73-mysql
sudo service mysqld start
sudo service httpd start
sudo chkconfig mysqld on
sudo chkconfig httpd on
sudo usermod -a -G apache ec2-user
sudo chown -R ec2-user:apache /var/www
sudo 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
curl -O https://releases.wikimedia.org/mediawiki/1.34/mediawiki-1.34.0.tar.gz
tar xvzf mediawiki-*.tar.gz
sudo mv mediawiki-*/* /var/www/html
# 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
echo “DB”
mysql -u root -prootroot -e "CREATE DATABASE my_wiki"
mysql -u root -prootroot -e "CREATE USER sammy@localhost IDENTIFIED BY 'rootroot'"
mysql -u root -prootroot -e "GRANT INDEX, CREATE, SELECT, INSERT, UPDATE, DELETE, ALTER, LOCK TABLES ON my_wiki.* TO 'sammy'@'localhost' IDENTIFIED BY 'password'"
mysql -u root -prootroot -e "FLUSH PRIVILEGES"