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!