Category: Shell Scripting

Home / Category: Shell Scripting

1. Introduction

This is a very short post which guides you how to install WordPress on Oracle Virtual box using a automated script.

2. Setup the environment

We will use virtual box as out hypervisor where our WordPress virtual machine is going to hosted.

Download Virtual Box: https://www.virtualbox.org/wiki/Downloads

We will use vagrant to manage and build virtual machines on the hypervisor.

Download Vagrant: https://www.vagrantup.com/downloads

Installation scripts can be found as a git repository. We shall install git to clone this repository.

Git for widows: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

Git for MacOS: https://sourceforge.net/projects/git-osx-installer/files/

A complete guide [optional] to install git: https://www.atlassian.com/git/tutorials/install-git

3. Clone the git Repository

At this point it has been assumed that Oracle virtual box, Vagrant and git applications are installed in your local machine.

git clone https://github.com/krishanthisera/WP-EZY.git

In this case you may use the terminal(on Linux, OSX) or CMD(for windows).

4. Bootstrap the Server

CD in to the cloned directory (WP-EZY).

cd WP-EZY 

Bootstrap the server.

vagrant up

Now you may wait until the bootstrapping process complete it may take some time depending on your internet connection.

5. Verify the installation

URL: http://192.168.5.50/blog/wp-admin/

User Name: admin

Password: password

–Enjoy–

6. Note

You may change the configuration using install.sh file. For an example,

  1. MySQL configuration
  2. IP Configuration
  3. Apache2 Configuration

If you are OSX user, you might encounter an error when you ought to install VirtualBox.

-> Go to your system preference

  • -> Unlock to make the changes
  • -> Allow VIrtual Box as a system app

Install.sh

#Install dependencies
sudo apt-get 
DB_ROOT_PASS=root-pass
DB_WP_PASS=wp-pass

sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password ${DB_PASS}'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password ${DB_PASS}'
sudo apt-get update -y
sudo apt-get install -y wordpress php libapache2-mod-php mysql-server php-mysql apache2 mysql-client ufw

sudo service mysql start
mkdir -p /etc/apache2/sites-available

#Configure mysql 
mysql -u "root" -p'$DB_ROOT_PASS' -e "CREATE DATABASE wordpress;"
mysql -u "root" -p'$DB_ROOT_PASS' -e "GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON wordpress.* TO wordpress@localhost IDENTIFIED BY '${DB_WP_PASS}';"
mysql -u "root" -p'$DB_ROOT_PASS' -e "FLUSH PRIVILEGES;"


#Configure Apache2 server
cat <<EOF | sudo tee /etc/apache2/sites-available/wordpress.conf
Alias /blog /usr/share/wordpress
<Directory /usr/share/wordpress>
    Options FollowSymLinks
    AllowOverride Limit Options FileInfo
    DirectoryIndex index.php
    Order allow,deny
    Allow from all
</Directory>
<Directory /usr/share/wordpress/wp-content>
    Options FollowSymLinks
    Order allow,deny
    Allow from all
</Directory>	
EOF


mkdir -p /etc/wordpress


cat <<EOF | sudo tee /etc/wordpress/config-localhost.php 
<?php
define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', '${DB_WP_PASS}');
define('DB_HOST', 'localhost');
define('DB_COLLATE', 'utf8_general_ci');
define('WP_CONTENT_DIR', '/usr/share/wordpress/wp-content');
?>
EOF



sudo service mysql start
sudo a2ensite wordpress
sudo a2enmod rewrite
sudo service apache2 reload

Thank you 🙂

How-to-Encrypt-a-shell-script
If you’re really concerning about the privacy of your shell scripts(Source),
I have use Ubuntu 14.04 server with the root Privilage. The source of the program ‘SCH’ which I’m using here is from
    http://www.datsi.fi.upm.es/
At first lets download some packeges which required to run our shell encryption program
You will need to download gcc compilers
    root@ubuntu:/usr/src# apt-get install gcc
You will need to install ‘make’ utility if it required (Depend on your system)
    root@ubuntu:/usr/src# apt-get install make
After that lets download our encryption program/ source [from http://www.datsi.fi.upm.es/]
Or you can download the ‘SCH’ source file which I’ve attached to this repository from from http://www.datsi.fi.upm.es/
    root@ubuntu:/usr/src# wget http://www.datsi.fi.upm.es/~frosal/sources/shc-3.8.7.tgz
Lets extract the ‘.tgz’ file
    root@ubuntu:/usr/src# tar xvf shc-3.8.7.tgz
    shc-3.8.7/CHANGES
    shc-3.8.7/Copying
    shc-3.8.7/Makefile
    shc-3.8.7/match
    shc-3.8.7/pru.sh
    shc-3.8.7/shc-3.8.7.c
    shc-3.8.7/shc.1
    shc-3.8.7/shc.README
    shc-3.8.7/shc.c
    shc-3.8.7/shc.html
    shc-3.8.7/test.bash
    shc-3.8.7/test.csh
    shc-3.8.7/test.ksh
Let jump in to the ‘shc’ source folder
    root@ubuntu:/usr/src# cd shc-3.8.7
In here I’m going to encrypt a shell script in the
    /home/encrypt
Let’s look inside the Shell script
    vim /home/encrypt/checksrv.sh
alt tag
Now lets Encrypt our Shell file Note that you always welcome to change password file in the shc-3.8.7 as you desire.
    root@ubuntu:/usr/src/shc-3.8.7# ./shc -f /home/encrypt/checksrv.sh
There will be two additional files
    root@ubuntu:/usr/src/shc-3.8.7# ls  /home/encrypt/
    checksrv.sh  checksrv.sh.x  checksrv.sh.x.c
‘checksrv.sh’ is our original (Unencrypted) shell source ‘checksrv.sh.x’ is the Encrypted Shell source ‘checksrv.sh.x.c’ c files was created in order to perform encryption
Lets check on our encrypted source file
    root@ubuntu:/usr/src/shc-3.8.7# vim  /home/encrypt/checksrv.sh.x
alt tag
Now you can see some binary stuffs instead of the plain shell text.
Now you can share the ‘.sh.x’ so your source will be hidden