Dietpi: Phpmyadmin not working with Lighttpd Stack

Created on 6 May 2016  路  36Comments  路  Source: MichaIng/DietPi

http://dietpi.com/phpbb/viewtopic.php?f=11&t=401
94cc6cbb-2bce-42e5-8170-fe835eb3cb55-0

Bug Known Issue Not a DietPi issue Solution available

Most helpful comment

Okay PR is up to solve this as above: https://github.com/Fourdee/DietPi/pull/2040

All 36 comments

note: phpMyAdmin is not triggering webserver installation.

WEBSERVER_MYADMINPHP will now trigger webserver + mysql installation

Installed:

  • LLMP
  • PHPMYADMIN

Unable to replicate issue:
image

When i try to uninstall Phpmyadmin it asks me for a password that i never set. The Default Passwords are not working. I uninstalled it through the skip questions option.

Unable to replicate. Used password dietpi.

Go through bug report and check for other causes.

Select PHPMYADMIN , install, reboot, select LLMP = fine

Select LLMP + PHPMYADMIN =

Run /etc/init.d/lighttpd force-reload to enable changes
dpkg: error processing package phpmyadmin (--configure):
 subprocess installed post-installation script returned error exit status 2
Processing triggers for libc-bin (2.19-18+deb8u4) ...
Processing triggers for php5-fpm (5.6.20+dfsg-0+deb8u1) ...
Errors were encountered while processing:
 phpmyadmin
E: Sub-process /usr/bin/dpkg returned an error code (1)
debconf-set-selections <<< "phpmyadminphpmyadmin/dbconfig-install boolean true"
warning: Unknown type true, skipping line 1
echo -e "phpmyadminphpmyadmin/dbconfig-install boolean true" | debconf-set-selections
warning: Unknown type true, skipping line 1

Silly question -- is this a DHCP-based install then proceeding to install LLMP + PHPMYADMIN?

futurewarningformysql
Hrm -- from the command line I found that there is a sort of "cart before horse" issue with MySQL deps and dbconf. Will send logs and will start from build 117 again as this is quite important.

Yeah, I know -- a whole lot of gibberish on my part, but I wanted to emphasize the soon-to-be-deprecated key_buffer_size to be removed from future releases for mysqld 5.5.xx and beyond

is this a DHCP-based install then proceeding to install LLMP + PHPMYADMIN?

Yep, I used DHCP during my testing.

from the command line I found that there is a sort of "cart before horse" issue with MySQL deps and dbconf. Will send logs and will start from build 117 again as this is quite important.

Sounds good :+1:

I shot a bug report and am now slicking a PI as well as my sandbox (well, reverting to a snapshot). This is a sane bug.... at least for now! DHCP for me, also. There was strange bug a ways back with the lighttpd project if I am not mistaken, but until I find it to be so... off to re-test.

Alright --

v117 -- unable to send bugtool after 2 identical tests
1 - Select LLMP & PhpMyAdmin
2 - Select OpenSSH
3 - Begin Install
4 - Receive Error 100 on apt-get for phpmyadmin
5 - Machine sits at last screen shot

Bug can be repro'd at will, however there are three factors I am looking at:

1 - Selecting PhpMyAdmin only (as you did, @Fourdee)
2 - From the main software menu, selecting Lighttpd as my webserver (instead of selecting both under optimized software)
3 - I have seen similar reports and will be documenting those and my next test

llmp0
llmp1
llmp2
llmp3
llmp4

Oh - I used both static and dynamic IPs for my test, as well. Not helpful yet, but phpmyadmin is angry about something.

So last note as I need to grab a pint and some food w/ family. Manually, I can install this. Using the current v117 utils, 1) phpmyadmin database does not get created and 2) it may be an order of operations issue... investigating...

v117 Sandbox. Progress.
Setup hostname, disable IPv6
Install LLMP, reboot.
Install phpmyadmin, it fails (screenshots to be attached and order of steps I took with precision)
Manually ran mysql_secure_install and was able to re-install phpmyadmin with success.

v117 Raspberry PI 2. Progress
Setup hostname, disable IPv6
Install OpenSSH, LLMP, reboot
Install PhpMyAdmin, it fails
Manually ran mysql_secure_install as well as re-install of phpmyadmin with success

It appears mysql_secure_install is not getting called OR db-config (it is updated during this process) is not taking preemptive steps in correct order to configure phpmyadmin's initial SQL database, etc.

The fourth test was, quite literally, to follow this documentation which I will now dive into the DietPi scripts for... (I had to check my sanity somewhere)

https://www.howtoforge.com/tutorial/install-lighttpd-with-php-fpm-and-mysql-on-debian/

success
1
2
3
6

Due to webserver + stack if conditions in v177, trying to re-create the install (ALL CLI) to ensure I can overcome this effort.

I've come to the conclusion if LLMP is selected + PhpMyAdmin, we need to generate a routine to knock this out in a block (not nested) if condition. This is purely by following install with success from the command line versus our software installer. Albeit, I may be missing something with regards to dbconf and order of operations...

11:00 AM EST & Mother's Day
Updated @Fourdee via email as I will be offline for 4-5 hours today
In comparing the installer for LLMP, WEBSERVER_XXXXXX, etc - the installer is close to these same commands I run (manually).
I want to document them for us all and for when I return from celebrating my Wife!

  • Fresh install of DietPi, hostname specified, and rebooted after update v117 applied
  • Static or Dynamic IPv4 address scheme
  • As root, perform the following in sequence - despite a reboot in the middle - and without installing components from dietpi-software:

Check for any lingering software from lack of coffee/tea

netstat -an | grep "[80|3306]"
dpkg --list | grep -i "[mysql|lighttpd|php|...etc]"

Begin the installation once that is all clear

apt-get install mysql-server mysql-client

If not prompted for root password, etc, please run:

mysql_secure_installation

Install lighttpd

apt-get install lighttpd

cat the following config to lighttpd's conf file, or generic (wheezy/jessie) "/etc/lighttpd/lighttpd.conf":

server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
#       "mod_rewrite",
)

Install what should be bulk of PHP deps, but others can be used/not used

apt-get install php5-fpm php5-cgi php5

Tuning of cache/performance in /etc/php5/fpm/php.ini

but ignore for now

service php5-fpm restart

Enable CGI for light

lighttpd-enable-mod fastcgi
lighttpd-enable-mod fastcgi-php
service lighttpd restart

Some are over-head, but with Maria making

its way as the new postgre ;-) run the following to be safe

apt-get install php5-mysqlnd php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-pspell php5-recode php5-sqlite php5-tidy php5-xmlrpc php5-xsl
apt-get install php5-xcache

Restart php5-fpm

service php5-fpm restart

Lastly....

dbconfig-load-include
apt-get install phpmyadmin

From there, reboot, hit http://x.x.x.x/phpmyadmin/

I have recorded these steps so when I can resume going back in revision history for dietpi/debian, I may catch that unique "gotcha"

Cheers...

No time to be slapdash, but I am still moving on this and keeping a previous comment in this case that is probably the key to something I overlooked:

"WEBSERVER_MYADMINPHP will now trigger webserver + mysql installation" -- @Fourdee, A few days ago

@Fourdee 10 hours ago I wiped an SD card, exploded DietPi onto it, and updated all the way to v117 -- just like I had over the weekend.

Using dietpi-software, I selected LLMP & PhpMyAdmin as I had before. No fatal errors this time (aside from a minor --configure notice) and presto -- this all works.

The confusion comes as this was clearly not working before. I will test again tomorrow, but wow -- sending a bugtool report asap.

configissue
itallworks

@xenfomation

Using dietpi-software, I selected LLMP & PhpMyAdmin as I had before. No fatal errors this time (aside from a minor --configure notice) and presto -- this all works.

Yep, this very strange. Sometimes packages/dependencies have issues and Its not unheard of with apt-get and repos.

I'll run the same test on my C2 and see if it still occurs.

EDIT: still occurs on C2.

Good man, sir. It is 4:21 EST and I leave the office at 6pm. I will have 2 PIs primed and may follow the install order and insert:

mysql secure install

Followed by:
apt get install phpmyadmin

It is a bit hackish, but if it works consistently it can afford us time to add sparse debug output to a file as each step is carried out.

OKay -- wrapping up final code tests for WEBSERVER_MYADMINPHP and order of operations to ensure 100% success.

Hey, @Fourdee -- I am including @rhkean in this write-up as well because... I did a lot of work, appreciate the patience, and I have had continued success with one issue. PhpMyAdmin - no matter what I do - throws error 100. So, if either of you have to to look at what I am about to put a pull request in for and give it a go, that would be exceptional (maybe I over looked something in the dietpi-software utility).

APT-GET and ERROR 100

I have worked with Debian for as long as I can recall and this strange error - old Deb, new Deb, Ubuntu, etc - has never been clearly defined. Everything from transient target package permissions during apt's heavy lifting to "we don't know, just install packages individually."

My two favorite odd answers are "low disk space" (not true) and "if apt is updated and then upgraded" (no way).

I've attached screenshots, so moving on....

NOTEABLE CHANGES

When MySQL is installed, the debconf lines have been modified to put the password for MySQL in quotes.

The order of operations - installing lighttpd, php/fastcgi, mysql, and phpmyadmin - have had subtle changes with the inclusion of the MySQL service being restarted (along with php5-fpm) before phpmyadmin is attempted to be installed.

CODE

I will attempt a pull request as I took a fork, etc but reading up on Git and trying to make sure I am proficient, it may be smaller than my last pull request. The key parts are the WEBSERVER stack conditions.

Cheers!
test1
test2
test3
test4
test5

When MySQL is installed, the debconf lines have been modified to put the password for MySQL in quotes.
The order of operations - installing lighttpd, php/fastcgi, mysql, and phpmyadmin - have had subtle changes with the inclusion of the MySQL service being restarted (along with php5-fpm) before phpmyadmin is attempted to be installed.
CODE
I will attempt a pull request as I took a fork, etc but reading up on Git and trying to make sure I am proficient, it may be smaller than my last pull request. The key parts are the WEBSERVER stack conditions.

@xenfomation
Interesting and good find :+1: , looking forward to seeing the pull request when you can.

Crud! I was up late, finally slept with my laptop open and headed into the office without it. Will be added tonight!

Tests from C2:

Creating config file /etc/phpmyadmin/config-db.php with new version
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: Y                                                                 ES).
unable to connect to mysql server.
error encountered creating user:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: Y                                                                 ES)
dbconfig-common: phpmyadmin configure: noninteractive fail.
dbconfig-common: phpmyadmin configure: ignoring errors from here forwards
populating database via sql...  done.
dbconfig-common: flushing administrative password
Enabling phpmyadmin: ok
Enabling auth: ok
Enabling fastcgi: ok
Met dependency: fastcgi
Enabling fastcgi-php: ok
already enabled
Run /etc/init.d/lighttpd force-reload to enable changes
dpkg: error processing package phpmyadmin (--configure):
 subprocess installed post-installation script returned error exit status 2
Processing triggers for libc-bin (2.19-18+deb8u4) ...
Processing triggers for php5-fpm (5.6.20+dfsg-0+deb8u1) ...
Errors were encountered while processing:
 phpmyadmin
E: Sub-process /usr/bin/dpkg returned an error code (1)

Will take a look later today.

Looks like mysql install isnt applying credentials correctly during install:

root@DietPi:~# /DietPi/dietpi/func/create_mysql_db testdb dietpi root dietpi

 DietPi: Creating MySql DB for testdb
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
 Create database testdb | Failed

root@DietPi:~# mysql -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

notes:

root@DietPi:~# debconf-get-selections | grep mysql
mysql-server    mysql-server/root_password      password
mysql-server-5.5        mysql-server/root_password      password
mysql-server    mysql-server/root_password_again        password
mysql-server-5.5        mysql-server/root_password_again        password
mysql-server-5.5        mysql-server/password_mismatch  error
mysql-server-5.5        mysql-server/error_setting_password     error
mysql-server-5.5        mysql-server-5.5/postrm_remove_databases        booleanfalse
mysql-server-5.5        mysql-server-5.5/start_on_boot  boolean true
mysql-server-5.5        mysql-server/no_upgrade_when_using_ndb  error
mysql-server-5.5        mysql-server-5.5/nis_warning    note
mysql-server-5.5        mysql-server-5.5/really_downgrade       boolean false

Issue is quotes gets sent as password. So in this case, password is actually set to 'dietpi'

echo -e "mysql-server mysql-server/root_password password 'dietpi'" | debconf-set-selections

Now back to phpmyadmin:

As a test, I installed LLMP, rebooted, then manually installed phpmyadmin with apt-get:

Creating config file /etc/phpmyadmin/config-db.php with new version
granting access to database phpmyadmin for phpmyadmin@localhost: success.
verifying access for phpmyadmin@localhost: success.
creating database phpmyadmin: success.
verifying database phpmyadmin exists: success.
populating database via sql...  done.
dbconfig-common: flushing administrative password
Enabling phpmyadmin: ok
Enabling auth: ok
already enabled
already enabled
Run /etc/init.d/lighttpd force-reload to enable changes
dpkg: error processing package phpmyadmin (--configure):
 subprocess installed post-installation script returned error exit status 2
Processing triggers for libc-bin (2.19-18+deb8u4) ...
Processing triggers for php5-fpm (5.6.20+dfsg-0+deb8u1) ...
insserv: warning: current start runlevel(s) (empty) of script `php5-fpm' overrid                                                                 es LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `php5-fpm'                                                                  overrides LSB defaults (0 1 6).
insserv: warning: current start runlevel(s) (empty) of script `php5-fpm' overrid                                                                 es LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `php5-fpm'                                                                  overrides LSB defaults (0 1 6).
Errors were encountered while processing:
 phpmyadmin
E: Sub-process /usr/bin/dpkg returned an error code (1)

Same issues.

Did what it asked, now installed fine:

root@DietPi:~# /etc/init.d/lighttpd force-reload
[ ok ] Reloading lighttpd configuration (via systemctl): lighttpd.service.
root@DietPi:~# dpkg --configure phpmyadmin
Setting up phpmyadmin (4:4.2.12-2+deb8u1) ...
dbconfig-common: writing config to /etc/dbconfig-common/phpmyadmin.conf
Replacing config file /etc/phpmyadmin/config-db.php with new version
granting access to database phpmyadmin for phpmyadmin@localhost: already exists.
creating database phpmyadmin: already exists.
populating database via sql...  done.
dbconfig-common: flushing administrative password
[ ok ] Reloading web server configuration: lighttpd.

I just wanted to see if this is a specific DietPi issue, its not.

I did a manual apt-get installation of mysql-server, lighttpd and phpmyadmin, same issues. So the cause lies with the apt-get packages and their installation scripts. It is not related to DietPi in any way.

I'am personally not going to spend anymore time on this issue.
For now, we just need to make users aware they cant select LLMP and Phpmyadmin at the same time for installation.

@xenfomation @rhkean Unless you guys have any ideas or suggestions, I'll mark this as a nofix and remove it from v118 milestone.

No - I agree as the conf packages and my research (for sanity) shows this to be an on/off issue... I merely attempted to apply the manual order I always had success with + debconf for automation, so I concur with your ideas, @Fourdee

Can we add a check in the code for phpmyadmin that verifies that mariadb or mysql = 2 (not 1) and pop up a message?

that way...
we can set mariadb=1 if the user just selects phpmyadmin w/out selecting a database
Then, pop up a message that says, "please install phpmyadmin after the database is installed"

I do like that idea very much. I can use this to reconfigure stupid git desktop :) and the warning is easy enough to pop up.

Whatever is decided on and who should do it, I support is my point. My personal backlog is living, adjusting my personal lab, and reconfiguring git desktop tonight / installing a rack for SBCs I will begin to acquire :)

@rhkean
As per your suggestion :+1: , this should do it: https://github.com/Fourdee/DietPi/commit/4d87e824bc9d5a151b12473c24e7881cd7902cf3

reconfiguring git desktop tonight / installing a rack for SBCs I will begin to acquire :)
@xenfomation Add a glass of wine and you've got yourself a good night in lol :)

Indeed, sir! However, being in a working mood, I will make it a goal tonight!

Just rechecked the error on fresh VirtualBox Stretch v158:

dpkg: error processing package phpmyadmin (--configure):
 subprocess installed post-installation script returned error exit status 2

So issue persists.

But workaround with user notification, cancelling phpmyadmin installation to rechoose after reboot, works well.
I manually removed the prevention code to force parallel installation. Reboot and reselecting phpmyadmin for installation via dietpi-software also worked without issue.
Also it recognizes mariadb unix_socket authentication (as mariadb will be actually installed on Stretch by mysql-server package) and deals great with it.

Leaving state as it is, NoFix is actually not really true, as the workaround represents a simple but effective solution 馃槈.

  • [ ] Reckeck+Solve as well for automated installs

Error still exists:

Setting up phpmyadmin (4:4.6.6-4) ...
Determining localhost credentials from /etc/mysql/debian.cnf: succeeded.
dbconfig-common: writing config to /etc/dbconfig-common/phpmyadmin.conf

Creating config file /etc/dbconfig-common/phpmyadmin.conf with new version

Creating config file /etc/phpmyadmin/config-db.php with new version
checking privileges on database phpmyadmin for phpmyadmin@localhost: user creation needed.
granting access to database phpmyadmin for phpmyadmin@localhost: success.
verifying access for phpmyadmin@localhost: success.
creating database phpmyadmin: success.
verifying database phpmyadmin exists: success.
populating database via sql...  done.
dbconfig-common: flushing administrative password
Enabling phpmyadmin: ok
Enabling auth: ok
Enabling fastcgi: ok
Met dependency: fastcgi
Enabling fastcgi-php: ok
already enabled
Run "service lighttpd force-reload" to enable changes
dpkg: error processing package phpmyadmin (--configure):
 subprocess installed post-installation script returned error exit status 2
Errors were encountered while processing:
 phpmyadmin
E: Sub-process /usr/bin/dpkg returned an error code (1)

But, it goes on when hitting "Retry":

[FAILED] DietPi-Software | G_AGI: phpmyadmin
[  OK  ] DietPi-Software | APT installation for: phpmyadmin, please wait...
Setting up phpmyadmin (4:4.6.6-4) ...
Determining localhost credentials from /etc/mysql/debian.cnf: succeeded.
dbconfig-common: writing config to /etc/dbconfig-common/phpmyadmin.conf
phpmyadmin already exists and has privileges on phpmyadmin.
creating database phpmyadmin: already exists.
populating database via sql...  done.
dbconfig-common: flushing administrative password
[....] Reloading web server configuration: lighttpddaemonized server failed to start; check error log for details
 failed!
invoke-rc.d: initscript lighttpd, action "reload" failed.
W: APT had planned for dpkg to do more than it reported back (0 vs 4).
   Affected packages: phpmyadmin:amd64
  • Lighttpd startup fails first, which makes sense, as fastcgi-php is still configured for php-cgi instead of php-fpm. On Lighttpd configuration step we adjust this, afterwards Lighttpd starts up successfully.
  • Perhaps this is also the reason for initial failure? Lighttpd failing to start up because of missing php-cgi binary/socket respectively missing php-fpm configuration? Maybe we can move fastcgi-php module edit it to Lighttpd install step?
    ... testing 馃埡 ... Temporary startup failure is not reason for phpmyadmin APT error. Simple retry fixes issue.

@Fourdee
Okay, can we somehow force a retry on APT error? Maybe we could add an automated apt-get -f install step to G_AGI in case of error?

Okay PR is up to solve this as above: https://github.com/Fourdee/DietPi/pull/2040

@MichaIng

Great work fixing a 2year+ ticket 馃憤 馃

Marking as resolved.

Was this page helpful?
0 / 5 - 0 ratings