Automate your Server Setup for WordPress


Hi, Guys Learner is here again with some shell script.
It’ll help you to automate your WordPress installation on your server as well as local.
You don’t need to do more stuff for installation like entering repetitive commands and all.
Actually, Users will become irritated when they will have to change many types of files for proper configurations.
With the help, this script any newbie can also Install WordPress on his/her own server.
It’s so simple Dude.. (;
Let’s start….

Prerequesite for WordPress Installation

You need LAMP, XAMP, MAMP or WAMP setup on your system.

If you’re Ubuntu 16.04 LTS user, type below command on your terminal for setup:

sudo apt-get install lamp-server^

If you’re Ubuntu 1404 LTS user, go through below video for installation process:

After proper setup of your above stack just fork our code from here.
And run this shell script on your server or where you wanna install WordPress.
Your setup is ready to use for WordPress.

Wanna See Code of that Automated Script?

#!/bin/bash -e
echo “============================================”
echo “WordPress Install Script”
echo “============================================”
echo “Database Name: “
read -e dbname
echo “Database User: “
read -e dbuser
echo “Database Password: “
read -s dbpass
echo “run install? (y/n)”
read -e run
if [ “$run” == n ] ; then
echo “============================================”
echo “A robot is now installing WordPress for you.”
echo “============================================”
#download wordpress
curl -O https://wordpress.org/latest.tar.gz
#unzip wordpress
tar -zxvf latest.tar.gz
#change dir to wordpress
cd wordpress
#copy file to parent dir
cp -rf . ..
#move back to parent dir
cd ..
#remove files from wordpress folder
rm -R wordpress
#create wp config
cp wp-config-sample.php wp-config.php
#set database details with perl find and replace
perl -pi -e “s/database_name_here/$dbname/g” wp-config.php
perl -pi -e “s/username_here/$dbuser/g” wp-config.php
perl -pi -e “s/password_here/$dbpass/g” wp-config.php

#set WP salts
perl -i -pe’
@chars = (“a” .. “z”, “A” .. “Z”, 0 .. 9);
push @chars, split //, “!@#$%^&*()-_ []{}<>~`+=,.;:/?|”;
sub salt { join “”, map $chars[ rand @chars ], 1 .. 64 }
s/put your unique phrase here/salt()/ge
‘ wp-config.php

#create uploads folder and set permissions
mkdir wp-content/uploads
chmod 775 wp-content/uploads
echo “Cleaning…”
#remove zip file
rm latest.tar.gz
#remove bash script
rm wp.sh
echo “=========================”
echo “Installation is complete.”
echo “=========================”

Wanna Contribute?

GO through below link for contribution.
Github Repo
{Code With Code@ter}

Leave a Reply