Skip to content

Instantly share code, notes, and snippets.

@maurorappa
Created February 10, 2017 13:13
Show Gist options
  • Save maurorappa/9cef7f572ba9954768b8d39165a520b3 to your computer and use it in GitHub Desktop.
Save maurorappa/9cef7f572ba9954768b8d39165a520b3 to your computer and use it in GitHub Desktop.
Interview lab: simple bootstrap file to create a WP machine with some error to fix
#!/bin/sh
yum update
yum install -y unzip php httpd mysql-server mysql php-mysql vim telnet
conf=" \n
[mysqld] \n
port=3307 \n
datadir=/var/lib/mysql \n
socket=/var/lib/mysql/mysql.sock\n
user=mysql \n
symbolic-links=0 \n
\n
[mysqld_safe] \n
log-error=/var/log/mysqld.log \n
"
echo -e $conf > /etc/my.cnf
curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer
cd /var/www/html
wget -q https://wordpress.org/latest.zip
unzip latest.zip
chown -R apache:apache /var/www/html/
mysql <<SQL
FLUSH PRIVILEGES;
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
create database wordpress;
GRANT ALL PRIVILEGES ON wordpress.* TO 'username'@'localhost';
FLUSH PRIVILEGES;
SQL
conf=" \n
<Location /status> \n
SetHandler server-status \n
Order allow,deny \n
Allow from all \n
</Location> \n
"
echo -e $conf >> /etc/httpd/conf.d/welcome.conf
service httpd restart
service mysqld restart
# We break stuff now
#mysql <<SQL
#REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'username'@'localhost';
#FLUSH PRIVILEGES;
#SQL
# change permissions of default background
chmod 000 /var/www/html/wordpress/wp-content/themes/twentyseventeen/assets/images/header.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment