1

I'm having trouble installing multiple versions of XAMPP on my machine. I am currently using version 1.7.7 and installed it in /opt/lampp, but I also need to install the previous version which is version 1.7.1. So I downloaded and installed version 1.7.1 in /opt/lampp2.

But when I run /opt/lampp2/lampp startcommand to start 1.7.1 version, why does XAMPP show that the version that is currently running is 1.7.7, when it should be 1.7.1?

  • You should call it "XAMPP for Linux" to avoid confusion with LAMP. – Oli Oct 11 '12 at 11:34
  • is that way we need you put some code as example on the aswers! ALL links are DOWN! – rafaelphp Jul 14 '16 at 23:33
1

The solution is have separate directories and create a sym link to /opt/lampp

Keep 1.7.7 as /opt/lampp.1_7_7 and 1.7.1 as /opt/lampp.1_7_1 you can create a sym link to /opt/lampp. Based on the version choice you can change the sym link.

But the pain is if you have to switch versions you have delete the link and recreate a new one. So to avoid this, I found a script that can do the job.

Refer to this article (dead link, web.archive.org backup) to create the sym link

Script can help you to:

  • gives a choice of available versions of XAMPP (based on folder names containing them, based on the pattern shown above),
  • stops the XAMPP server processes,
  • deletes the existing lampp soft link,
  • creates a new soft link pointing at the folder containing the the chosen version of XAMPP.

Source

| improve this answer | |
  • 1
    is that way we need you put some code as example on the aswers! ALL links are DOWN! – rafaelphp Jul 14 '16 at 23:33
  • links are not working anymore – Rohan Khude Jan 2 '18 at 7:47
  • @devav2 asking for register and login to get the answer. This answer should contain code. – rahul Jun 17 '19 at 4:34
0

Follow the idea to create a link, I try to make this works. Remember that I am not a pro, I was looking for a solution and make this script to my self and share with you.

Just to future questions if you want to install 2 versions of xampp on Linux you have to install: Example: xampp php5 on /opt/lampp then rename it to /opt/lampp5, then do the same with the php7 bin installer (or tar) and rename it to /opt/lampp7. then copy this code into a new script.sh file, make it writable chmod +x script.sh, then run it $ ./script.sh or $ ./script.sh 5 start here is the code example running fine on ubuntu 16.04, its just a simple script to make it work on this kind of problem, since on windows we can do it at the installation steps.

#!/bin/bash

LAMPP_VERSION=$1
LAMPP_ACTION=$2

LAMPP="/opt/lampp"
XAMPP=$LAMPP"/xampp"

function stopall {
    sudo $XAMPP stopapache
    sudo $XAMPP stopmysql
}

function startall {
    sudo $XAMPP startapache
    sudo $XAMPP startmysql
}

function stopmysql {
    sudo $XAMPP stopmysql
}

function stopapache {
    sudo $XAMPP stopapache
}

function startmysql {
    sudo $XAMPP startmysql
}

function startapache {
    sudo $XAMPP startapache
}

function checklampplink {

    # check if exist a link and delete it
    if [[ -L "$LAMPP" && -d "$LAMPP" ]]
        then
            echo "$LAMPP is a symlink to a directory: try DELETE!"
            sudo rm -f $LAMPP
        else
            echo "NO $LAMPP LINK WAS FOUND!"
    fi

    # create a new link
    echo "try to create LAMPP link ..."
    cd /opt
    ln -s "$LAMPP$LAMPP_VERSION" "lampp"

    ## check if is created
    if [[ -L "$LAMPP" && -d "$LAMPP" ]];
        then
            echo $LAMPP "created!"
        else
            echo "LINK not created! exit 1"
            exit 1
    fi
}

function checkservices {

    # check if services exists and try to stop property
    PIDS_MYSQL=$(ps -C mysqld -C mysqld_safe -o pid=)
    PIDS_APACHE=$(ps -C /opt/lampp/bin/ -o pid=)

    if [ -n $PIDS_MYSQL ];
        then
            stopmysql
        else
            echo "NO MYSQL TO KILL"
    fi
    if [ -n "$PIDS_APACHE" ];
        then
            stopapache
        else
            echo "NO APACHE TO KILL"
    fi

}

### begin ###



####
# get an action
if [ -z $LAMPP_ACTION ];
    then
        echo
        echo "ACTION: ( start | stop | restart)?"
        read LAMPP_ACTION
    else
        echo "ACTION SET TO: "$LAMPP_ACTION
fi
# if action is stop exit
if [ "$LAMPP_ACTION" == "stop" ];
    then
        stopall
        exit 0
fi

####
# get a version
if [ -z $LAMPP_VERSION ];
    then
        echo
        echo "VERSION: ( 5 | 7 )? "
        read LAMPP_VERSION
     else
        echo "VERSION SET TO: " $LAMPP_VERSION
fi
if [[ "$LAMPP_VERSION" = "5" || "$LAMPP_VERSION" = "7" ]];
    then
        echo "GOOD version continue ..."
    else
        echo "Wrong version exit 1"
        exit 1
fi

## if action is start or restart do the same
checkservices

# check folder link
checklampplink

echo

echo "Select an option to START:"
echo "1) ALL current installed services on xampp"
echo "2) Apache and Mysql - phpmyadmin"
echo
echo "Type enter to start option default ( 1 ) "
read USER_START
echo
echo "Starting services ..."
echo

if [ -z $USER_START ];
    then
        startapache
        startmysql
     else
        if [ "$USER_START" = "1" ];
            then
                startall
            else
                startapache
                startmysql
        fi
fi

echo "Done";
exit 0

if this code have any syntax problem, sorry I just paste here. good luck!

| improve this answer | |
  • ./script.sh 5 start ACTION SET TO: start VERSION SET TO: 5 GOOD version continue ... ./script.sh: line 67: [: 6557: binary operator expected NO MYSQL TO KILL NO APACHE TO KILL NO /opt/lampp LINK WAS FOUND! try to create LAMPP link ... ln: failed to create symbolic link 'lampp': Permission denied LINK not created! exit 1 getting error like this. – rahul Jun 11 '19 at 8:30
  • 1
    @rahul can u list your opt lamp folders? should be like lampp56, lampp70, then try to create a link manually, sudo ln -s /opt/lampp56 /opt/lamp – rafaelphp Jun 15 '19 at 14:59
  • 1
    do u make the sh script executable? sudo chmod +x lampp_switcher.sh – rafaelphp Jun 22 '19 at 1:19
  • 1
    pls rename the link with 2 p from lamp to lampp – rafaelphp Jun 22 '19 at 1:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.