Skip to content

Instantly share code, notes, and snippets.

@heyseus1
Created August 5, 2017 05:14
Show Gist options
  • Save heyseus1/e7524fce43d8f9c435c77b80f3b36561 to your computer and use it in GitHub Desktop.
Save heyseus1/e7524fce43d8f9c435c77b80f3b36561 to your computer and use it in GitHub Desktop.
#!/bin/bash
checkroot() {
if [ $UID -ne 0 ] ; then
echo "User has insufficient privilege."
exit 4
fi
}
install_deps () {
apt-get update
apt-get upgrade
apt-get -y install \
vim curl apache2 mysql-server mysql-client php5 php5-mysql libapache2-mod-php5 php5-curl php5-mcrypt php-pear
}
configure_php () {
echo '<?php
phpinfo();
?>' >> /var/www/html/test.php
}
configure_wordpress () {
cd /tmp/
curl -O https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
touch /tmp/wordpress/.htaccess
chmod 660 /tmp/wordpress/.htaccess
cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
mkdir /tmp/wordpress/wp-content/upgrade
cp -a /tmp/wordpress/. /var/www/html
sleep 5s
clear
echo "open the WordPress configuration file: vim /var/www/html/wp-config.php"
sleep 5s
echo "Find the section that contains the dummy values for those settings. It will look something like this:"
echo "define('AUTH_KEY', 'put your unique phrase here');
define('SECURE_AUTH_KEY', 'put your unique phrase here');
define('LOGGED_IN_KEY', 'put your unique phrase here');
define('NONCE_KEY', 'put your unique phrase here');
define('AUTH_SALT', 'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT', 'put your unique phrase here');
define('NONCE_SALT', 'put your unique phrase here');"
sleep 5s
echo "paste the content below to replace the key configs"
curl -s https://api.wordpress.org/secret-key/1.1/salt/
echo "run the command below if you need the regenerate key config"
echo "curl -s https://api.wordpress.org/secret-key/1.1/salt/"
sleep 10s
clear
echo "last step"
echo "find the section that contains these settings in /var/www/html/wp-config.php"
echo "define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'wordpressuser');
/** MySQL database password */
define('DB_PASSWORD', 'password');"
echo "replace with sql credentials"
}
checkroot
install_deps
configure_php
configure_wordpress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment