setup LAMP

Linux Apache2 MariaDB PHP7.3

su - root; # become root
apt update; # update system to latest
apt upgrade;

# database first
apt install mariadb-server mariadb-client

# set root pwd for database (can be root on dev test server)
mysql_secure_installation

# install webserver
apt install apache2

# install php
apt install php7.3 libapache2-mod-php7.3

# restart webserver
service apache2 restart

# make sure php works
vim /var/www/html/info.php
# fill with
<?php
phpinfo()

# then point browser to
http://localhost/info.php

one should see something like this:

this just means php works with apache2.

congratulations!

time for one’s first celebration dance!

install more stuff: (might be optional)

apt install php7.3-mysql php7.3-curl php7.3-gd php7.3-intl php-pear php-imagick php7.3-imap php-memcache php7.3-pspell php7.3-recode php7.3-sqlite3 php7.3-tidy php7.3-xmlrpc php7.3-xsl

service apache2 restart

# phpmyadmin is out?
# let's install adminer
cd /var/www/html
wget https://github.com/vrana/adminer/releases/download/v4.7.6/adminer-4.7.6
mv adminer-4.7.6.php adminer.php

# before one can login as root:root
# creditz for this go to https://websiteforstudents.com/manage-mariadb-mysql-databases-with-adminer-and-apache2/

# login into mariadb
# the "new" mysql (that's why it is still called mysql)
mysql -u root

# copy and paste those commands:
use mysql;
update user set plugin='' where User='root';
flush privileges;
exit

# restart mariadb
systemctl restart mariadb.service

xdebug + pdt eclipse for php:

mkdir /software
# download eclipse
wget https://mirrors.dotsrc.org/eclipse//technology/epp/downloads/release/2020-03/R/eclipse-php-2020-03-R-linux-gtk-x86_64.tar.gz;

cd /software
tar fxvz eclipse-php-2020-03-R-linux-gtk-x86_64.tar.gz;

# install xdebug
apt install php-xdebug

# probably optional:
# alternative compile from latest source way of installing xdebug
apt install php-dev
pecl install xdebug

would replace firefox-esr with firefox

mkdir /software
cd /software
wget https://download-installer.cdn.mozilla.net/pub/firefox/releases/76.0/linux-x86_64/en-US/firefox-76.0.tar.bz2
tar fxv firefox-76.0.tar.bz2

cd /usr/bin
# unlink firefox-esr (default debian 10 firefox version)
unlink firefox
# create new link to latest manual download firefox 76
ln -sv /software/firefox/firefox

start and config eclipse:

eclipse is a bit complex. one has been warned X-D

# start eclipse pdt
/software/eclipse/eclipse

let eclipse know where php (go to terminal and type: which php) and php.ini (can be found in info.php) is:

and it shall use xdebug as default debugger:

xdebug settings:

enabling Xdebug:

this is absolutely essential (or eclipse will hang with “waiting for xdebug session…” forever and ever…)

enabling Xdebug in Debian 10: add the following to /etc/php/7.3/mods-available/xdebug.ini:

cat /etc/php/7.3/mods-available/xdebug.ini 
zend_extension=xdebug.so
xdebug.profiler_enable_trigger = 1
xdebug.profiler_enable = 0
xdebug.remote_enable = 1
xdebug.profiler_output_dir = "/tmp"

Restart Apache:

service apache2 restart;

creditz: https://drupaland.eu/article/installing-and-enabling-xdebug-debian-9

pray! and run! X-D

if everything works as planned one can start a debug session like this:

eclipse start firefox with url problem:

if one wants to use external browser firefox, there might be a problem: firefox should launch one’s whateverfilename.php with the ?XDEBUG_SESSION_START parameter…

if not and xdebug “hangs” with “waiting for xdebug session…”

then open a terminal and check if firefox was not starting correctly (starts in background than crashes X-D)

ps uax|grep firefox

(eclipse tries to open firefox via: -openURL(%URL%) but does not seem to work (anymore?), guess it is a eclipse specific problem, eclipse could just start /usr/bin/firefox %URL% should work)

workaround: use the default settings (eclipse’s internal browser)

so instead of: tell eclipse to use firefox external browser

just go with the eclipse internal browser:

in the vm: have added firefox to external tools or manually opening firefox with XDEBUG_DESSION_START=KEY works too.

expected result:

… eclipse should “pause” / report that a debug session has started and freeze at the first line of php code: 🙂 (F5 -> step step, F8 -> keep running)

CONGRATULATIONS! ONE MADE IT!

XDEBUG IS WORKING! 🙂

one can no very very nicely debug all sorts of php requests DIRECTLY on the server.

imho xdebug is ABSOLUTELY FANTASTIC! THANKS ALL INVOLVED! GREAT GREAT JOB!

have nothing seen like this anywhere else! (although it is said that c programs could be remote debugged with gdb, but that is an art in itself X-D)

CELEBRATE!

CELEBRATE!

CELEBRATE!

one can download the whole vm here:

Downloads:

Oracle Virtualbox VM: Debian10 + LAMP + PHP7.3 + XDebug + MariaDB + Adminer + Eclipse PDT

1) install https://www.virtualbox.org/

download:

https://dwaves.de/software/php/devphp_xdebug_Debian10_.tar.xz

https://dwaves.de/software/php/devphp_xdebug_Debian10_.tar.xz.sha512sum.txt

2) simply double click the devphp_xdebug_Debian10_.vbox should import the vm and user should be able to run immediately

so filesize wise xz compresses better than bzip2 which compresses better than gzip, so xz (J) was used:

# archive was created like this
tar fcvJ devphp_xdebug_Debian10_.tar.xz devphp_xdebug_Debian10_;
sha512sum devphp_xdebug_Debian10_.tar.xz > devphp_xdebug_Debian10_.tar.xz.sha512sum.txt;

# check integrity
sha512sum -c devphp_xdebug_Debian10_.tar.xz.sha512sum.txt
# unpack
tar fxvJ devphp_xdebug_Debian10_.tar.xz

project management:

===== project management
all projects are stored on host (directly on hardware) in folder /projects or /home/user/projects

host will do git management (commit)

vm will mount the host’s project folder (it’s a bit complicated, because of access-rights permission problems (webroot default user www-data)

=== project access on vm

1) configure “shared folder” to share host-folder “projects” (where projects shall be stored on host) with vm

2) bindfs to /var/www (default web root apache & xdebug workspace)

two scripts are used (on startup, activate rc.local)

/scripts/batchBindProjects.sh

#!/bin/bash
# bind projects into workspace
/scripts/bindfsProject.sh projectName1
/scripts/bindfsProject.sh projectName2

/scripts/bindfsProject.sh

#!/bin/bash
# mounts PROJECTNAME into apache2 default web root/user's workspace /var/www/html
PROJECT=$1; # specify projectname
# create mountpoint
mkdir -p /var/www/html/$PROJECT;
# bind-mount project as www-data:www-data
bindfs -u 33 -g 33 /media/sf_projects/$PROJECT /var/www/html/$PROJECT/;

Links:

https://xdebug.org/

https://github.com/xdebug/xdebug

buy him many cups of coffee!-> https://derickrethans.nl/

inspiration was also taken from: https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-lamp-on-debian-stretch/

and: https://websiteforstudents.com/manage-mariadb-mysql-databases-with-adminer-and-apache2/

thanks all involved! GREAT JOB!

admin