I always had problems when i upgraded my wordpress.
So I made ​one script that automatically does this for me and i’ll share that with you.
With this script you can install or upgrade your wordpress install.


# Homepage: http://www.debian-tutorials.com
# Email: contact@debian-tutorials.com
# Bash script to download and install or upgrade wordpress to specified directory.
install_wp ()
cd ~</pre>
mkdir wordpress
cd wordpress
wget https://wordpress.org/latest.tar.gz –no-check-certificate;
echo "Where would you like your new WordPress install to be located? Please Type the location(Eg:/var/www/) and press [ENTER]: "
read wordpress_dir
echo "Installing WordPress to $wordpress_dir";
if [ ! -d "$wordpress_dir" ]; then
mkdir $wordpress_dir
tar -zxvf latest.tar.gz -C $wordpress_dir

clean_up ()
cd ~/wordpress
rm latest.tar.gz
cd ~
rmdir wordpress
cd $wordpress_dir/wordpress
mv *.* $wordpress_dir
mv wp-admin $wordpress_dir
mv wp-content $wordpress_dir
mv wp-includes $wordpress_dir/
rmdir $wordpress_dir/wordpress
cd $wordpress_dir/wp-content
mkdir uploads
chmod 777 uploads -R
cd $wordpress_dir
touch $wordpress_dir/.htaccess
chmod -v 666 .htaccess
echo "Wordpress is now Installed to" . $wordpress_dir . "Enjoy!"

update_wp ()
day=`date +%Y_%m_%d`
cd ~
mkdir wordpress_tmp
cd wordpress_tmp
wget https://wordpress.org/latest.tar.gz –no-check-certificate;
echo "In what directory does WordPress already exist, that you would like updated? Please Type the location(Eg:/var/www/) and press [ENTER]: "
read update_dir
tar -zxvf latest.tar.gz -C $update_dir
cd ~/wordpress_tmp
rm latest.tar.gz
cd ~
rmdir wordpress_tmp

cd $update_dir
cp $update_dir/ $update_dir/../wordpress_backup_$day -R
cp $update_dir/../wordpress_backup_$day/wp-config.php $update_dir

# Go to backup directory and remove the new install of WP
cd $update_dir/../wordpress_backup_$day
rm wordpress -rf

# back to the update directory
cd $update_dir/wordpress

#remove wp-admin and wp-includes
cd $update_dir
rm wp-admin -rf
rm wp-includes -rf

cd $update_dir/wordpress
mv wp-admin $update_dir
mv wp-includes $update_dir
#remove the extra updated directoroies
rm $update_dir/wordpress/ -rf

echo "Upgrade complete! Backup can be found in $update_dir/../$update_dir_backup_$day"
if ["$(id -u)" = "0"]; then {
echo "You are root we will continue" 2>&1

read -p "If the location you want to install wordpress to requires Root access, Please press ‘N’ and run this script again as root, or ‘Y’ to run the script without root (y/n)? "
[ "$REPLY" == "n" ] & exit ||
[ "$REPLY" == "y" ] &
echo "Do you wish to install WordPress [Yes] or update [No]? Type 1 or 2 and press [ENTER]"
select yn in "Yes" "No"; do
case $yn in
Yes ) install_wp && clean_up && break;;
No ) update_wp && break;;
exit 1;


You can download the script from here: Install or Upgrade wordpress bash script


There is a simple way to call a simple bash script inside php script page:

– Below is a simple bash script called script.sh

echo “Successful call test script“
exit 0

You will need to set chmod 700 to  be root executable. Then  save the script to your apache root folder.

There is a simple php script called testing.php

< ?php $script = “/var/www/script.sh”; $ver1 = system($script, $retval); if ($retval == 0 ) { echo “Returned 0″; } else { echo “Returned not zero”; } die; ?>

Continue Reading…

Virtual hosts are used to run more than one web site on a single machine.
Virtual hosts can be “IP-based”, meaning that you have a different IP address for every web site, or “name-based”, meaning that you have multiple names running on each IP address.

I want to show you one of mine scripts for easy create virtual hosts in Debian Squeeze or ubuntu.


# Check if is root
if [ “$UID” -ne “$ROOT_UID” ]
echo “You must be root to run this script.”

if [ -n “$1” ]
echo “You must provide a full domain name for this site, i.e. ‘example.com’ ”
echo -n “Run this script like ./script example.com .”

#Create document root site folder
mkdir -p $WWW_ROOT/$DOMAIN

Continue Reading…

In Bash Shell Scripting the variables do not need to  be declared.

However, if the variable is not declared it will only produce an empty string.  When you declare variables you are telling the shell what value the variable contains.  In this example, the variable $var, note that it can be lower case, has a value of “time”.

Each time the variable is called it will have this value.  You can also declare variables with the declare command.



declare var=time

If you had a variable constructed without declaring the value it would look like this:


Or you may call a variable that has no value attached with something like this:

echo $VAR

If the VAR variable has not been declared you just get an empty string.

Page 2 of 212