GNU-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.4 libapache2-mod-php7.4 # 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.
time for one’s first celebration dance!
install more stuff: (might be optional)
# search what packages are there for this version of php apt search php7.3 apt search php7.4 apt search php8 # install only those php addons, that are absolutely needed apt install php7.4-mysql php7.4-curl php7.4-gd php7.4-intl php-pear php-imagick php7.4-imap php-memcache php7.4-pspell php7.4-sqlite3 php7.4-tidy php7.4-xmlrpc php7.4-xsl php7.4-mbstring # php7.4-recode does not exist anymore service apache2 restart # phpmyadmin is still a pretty nice web based # mysql-mariadb management gui # before one can login as root:root (creditz) # login into mariadb # the "new" mysql (that's why it is still called mysql) mysql -u root # if that fails try (and give root pwd) mysql -u root -p # copy and paste those commands: use mysql; update user set plugin='' where User='root'; flush privileges; exit # restart mariadb systemctl restart mariadb.service # based on this cd /var/www/html wget https://files.phpmyadmin.net/phpMyAdmin/5.1.0/phpMyAdmin-5.1.0-all-languages.zip (sha512sum ded55db84f54e51429cf6463a5ade5b5b1859d6b917d340ccf265e6860381d80f6d62eacc29672280574c21f95d77cb14c649b1f8e000d34cd9a85514d06765e) unzip phpMyAdmin-5.1.0-all-languages.zip mv -v phpMyAdmin-5.1.0-all-languages phpmyadmin cd phpmyadmin mv -v config.sample.inc.php config.inc.php # setup config vim config.inc.php # search for this line and change this value cfg['blowfish_secret'] = 'root'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */ chmod 660 /var/www/html/phpmyadmin/config.inc.php chown -R www-data:www-data /var/www/html/phpmyadmin systemctl restart apache; # debian10 restart apache 2 service service apache2 restart; # ubuntu20 restart apache 2 service # point browser at http://localhost/phpmyadmin, should be greeted with this login: # btw did the dev-user know, one can create user+database in "one go" like this: # or try the alternative: "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
xdebug + pdt eclipse for php:
mkdir /software cd /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; # 2022-03 wget -O eclipse-php-2020-06-R-linux-gtk-x86_64.tar.gz https://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/2020-06/R/eclipse-php-2020-06-R-linux-gtk-x86_64.tar.gz tar fxvz eclipse-php-*.tar.gz; # set user rights, so non-root user can use /software chown -R user: /software # 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:
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"
service apache2 restart;
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)
# example, firefox 78.7.0esr (64-bit) does not seem to like to start like this anymore firefox-esr -remote openURL(http://localhost/project/index.php?XDEBUG_SESSION_START=ECLIPSE_DBGP&KEY=16136735518102)
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.
… 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 now very nicely step 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)
hereby creditz shall be given to Larry_Ewing for creating the Tux Logo https://en.wikipedia.org/wiki/Larry_Ewingone can download the whole vm here:
once it runs: get meaningful php debug error warning output
it is not always “clear” where php will output the errors & warnings…
for example: the function split is DEPRECATED in PHP 5.3.0, and REMOVED in PHP 7.0.0
and needs to be replaced with “explode” (this is kind of the annoying stuff about php updates… they keep changing function names, but usually only minor changes to “has worked before” php code have to be made)
the file.php simply “quits” without warning or error when split is called
so there is per default no error output in the browser unless…
# put this on the very top of file.php to enable errors & warnings in browser ini_set('display_startup_errors', 1); ini_set('display_errors', 1); error_reporting(-1);
- the developer puts at the very top of the file.php
- the developer modifies php.ini
- but then still… it does not output in browser but in log file! (this script is very helpful in finding that log file)
- so… if the developer runs GNU Linux Debian 10 + apache2 + PHP7 the /var/log/apache2/error.log is the file where errors and warnings are written to/logged
- a simple tail -f /var/log/apache2/error.log does the job too 🙂
- (but it is usually more convenient having development & errors displayed all in the same window… not having to switch back and forth… okay here come two-monitor solution in to play (have browser on right monitor, and eclipse dev environment on left monitor)
improving handling: shortcuts & hotkeys
when tasks have to be repeated very often… clicking around in menus and sub-menus costs a lot of time (every millisecond counts 🙂
to start debug session:
to stop debug session:
note: want to work with firefox?
the developer does not need to restart (Ctrl+F2, wait, complicated hotkey) the debug session, after code changes, just hit F5 in firefox (it is basically a “hot reload”)
Downloads READY 2 GO VirtualBox VM 🙂
neat service for you, virtualbox has the advantage of running cross platform, windows, osx, GNU Linux so all vms can be run on all (major) OS:
Oracle Virtualbox VM: Debian10 + LAMP + PHP7.3 + XDebug + MariaDB + Adminer + Eclipse PDT
1) install https://www.virtualbox.org/
2) simply double click the devphp_xdebug_Debian10_.vbox should import the vm and user should be able to run immediately
# 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
all projects are stored on host (directly on hardware) in folder /projects or /home/user/projects
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)
#!/bin/bash # bind projects into workspace /scripts/bindfsProject.sh projectName1 /scripts/bindfsProject.sh projectName2
#!/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/;
inspiration was also taken from: https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-lamp-on-debian-stretch/
thanks all involved! GREAT JOB!
- only together we can create a truly free world
- plz support dwaves to keep it up & running!
- (yes the info on the internet is (mostly) free but beer is still not free (still have to work on that))
- really really hate advertisement
- contribute: whenever a solution was found, blog about it for others to find!
- talk about, recommend & link to this blog and articles
- thanks to all who contribute!