LAMP install error on Bookworm (Step: Installing PHP)

DietPi version |

  • Distro version | bookworm 0
  • Kernel version | Linux T44 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux
  • Architecture | arm64
  • SBC model | RPi 4 Model B (aarch64)
  • Power supply used | 5V 3A
  • SD card used | SanDisk

Steps to reproduce

choose 76 LAMP

Actual behaviour

Step: Installing PHP

[  OK  ] DietPi-Software | APT install php8.2-fpm php8.2-apcu php8.2-curl php8.2-gd php8.2-mbstring php8.2-xml php8.2-zip php8.2-mysql
[  OK  ] DietPi-Software | systemctl stop php8.2-fpm
[ INFO ] DietPi-Software | APT purge libapache2-mod-php*, please wait...
[ INFO ] DietPi-Software | None of the packages are currently installed. Aborting...
[  OK  ] DietPi-Software | APT purge libapache2-mod-php*
[  OK  ] DietPi-Software | rm -Rf /etc/php/*/apache2 /var/lib/php/modules/*/apache2
[  OK  ] DietPi-Software | Setting in /etc/php/8.2/fpm/pool.d/www.conf adjusted: pm.max_children = 12
[  OK  ] DietPi-Software | Setting in /etc/php/8.2/fpm/pool.d/www.conf adjusted: pm.start_servers = 4
[  OK  ] DietPi-Software | Setting in /etc/php/8.2/fpm/pool.d/www.conf adjusted: pm.min_spare_servers = 4
[  OK  ] DietPi-Software | Setting in /etc/php/8.2/fpm/pool.d/www.conf adjusted: pm.max_spare_servers = 4
[  OK  ] DietPi-Software | Comment in /etc/php/8.2/fpm/pool.d/www.conf converted to setting: env[PATH] = /usr/local/bin:/usr/bin:/bin
[  OK  ] DietPi-Software | mkdir -p /etc/systemd/system/php8.2-fpm.service.d
[  OK  ] DietPi-Software | eval echo -e '[Unit]\nAfter=redis-server.service mariadb.service postgresql.service' > '/etc/systemd/system/php8.2-fpm.service.d/dietpi.conf'
[  OK  ] DietPi-Software | mkdir -p /run/php_sessions
[  OK  ] DietPi-Software | chmod 1733 /run/php_sessions
[  OK  ] DietPi-Software | Added setting session.save_path="/run/php_sessions" to end of file /etc/php/8.2/mods-available/dietpi.ini
[  OK  ] DietPi-Software | Added setting upload_tmp_dir="/tmp" to end of file /etc/php/8.2/mods-available/dietpi.ini
[  OK  ] DietPi-Software | Added setting upload_max_filesize=512M to end of file /etc/php/8.2/mods-available/dietpi.ini
[  OK  ] DietPi-Software | Added setting post_max_size=512M to end of file /etc/php/8.2/mods-available/dietpi.ini
/boot/dietpi/dietpi-software: Zeile 3822: / 30 : Syntaxfehler: Operator erwartet. (Fehlerverursachendes Zeichen ist "/ 30 ").

Extra details

This is a relatively fresh install. Installed packages:

I am able to install php by hand: apt install php8.2-fpm
I can call phpinfo(); and php -v getting 8.2.7
But if I then try to install e.g. phpmyadmin which invokes php install again I get the same error as above.

It’s not an issue of the package install. Seems something with the our script. Need to test this on my demo systems

1 Like

before doing further investigation, can you update to latest version DietPi v8.21.1 and try again

It doesn’t change anything.
But I can’t do that anymore because every try ruins my apache/php installation which I have installed by hand now.

Especially because I have to
a2enmod php8.2
again and end up with
Considering dependency mpm_prefork for php8.2:
Considering conflict mpm_event for mpm_prefork:
ERROR: Module mpm_event is enabled - cannot proceed due to conflicts. It needs to be disabled first!

so I have to
a2dismod mpm_event

and then
#ThreadsPerChild 64
#ThreadLimit 64
#MinSpareThreads 1
#MaxSpareThreads 64
#MaxRequestWorkers 64

in /etc/apache2/conf-available/dietpi.conf

means the PHP8.2 install done by dietpi-software is still failing?

yes, unfortunately

And still same error message? Because I’m not able to replicate this.

If I recall correctly it was the same yes

Should be this line in the script.

# Cache settings
			local cache_size=$(( $RAM_PHYS / 30 ))
			(( $cache_size < 16 )) && cache_size=16

and in dietpi-software we have:

$RAM_PHYS = $(free -m | mawk '/^Mem:/{print $2;exit}')

Which just gives you your total RAM in MiB. In my case 902. Devided by 30 is 30, which the installer used in my case:

Added setting opcache.memory_consumption=30 to end of file /etc/php/8.2/mods-available/dietpi.ini

So I fiddled a bit around with it and when I execute echo local cache_size=$(( $RAM_PHYS / 30 )) I get

-bash: / 30 : syntax error: operand expected (error token is "/ 30 ")

echo $((902 / 30)) works, gives 30
echo $(($RAM_PHYS / 30)) works not

I made script

$RAM_PHYS = $(free -m | mawk '/^Mem:/{print $2;exit}')
local cache_size=$(( $RAM_PHYS / 30 ))
echo $cache_size

And when I run it I get:

./ line 2: =: command not found
./ line 3: / 30 : syntax error: operand expected (error token is "/ 30 ")

So the part of getting RAM size already fails, but when I run it from CLI it works? What is going on here?

only works if locale is en
in my case it is de and the output is empty because free -m looks like this
~# free -m
gesamt benutzt frei gemns. Puffer/Cache verfügbar
Speicher: 3794 583 2673 93 681 3211

Yes, that’s it!
@MichaIng you need to see this.
On my other system I use also de_DE and of course “Mem:” gets translated to “Speicher:” and the mawk command can’t find anything.

This sould work anytime:

free -m | mawk 'NR==2' | mawk '{print $2;exit}'

Maybe the two mawk can be shortened to one?

EDIT: it can:

free -m | mawk 'NR==2 {print $2;exit}'

Same problem here:
and here
and probably in other scripts too.

localization was never a problem and I would expect way more reports :thinking:

You have two syntax error in your script (which is not in dietpi-software), the spaces around the = sign and the $ in front of the variable name. Looks more like PHP syntax :stuck_out_tongue_winking_eye:. Change it to the way it is assigned in dietpi-software, then it should work:

RAM_PHYS=$(free -m | mawk '/^Mem:/{print $2;exit}')

In all our scripts we enforce C.UTF-8 as locale, so as long as this is compiled (it is even shipped as binary via libc-bin package), within scripts all output should be English/default.

Can you create/run this script?

cat << '_EOF_' >
. /boot/dietpi/func/dietpi-globals
readonly G_PROGRAM_NAME='DietPi-Software'
free -m
free -m | mawk '/^Mem:/{print $2;exit}'
chmod +x
# respectively
sudo ./

gesamt benutzt frei gemns. Puffer/Cache verfügbar
Speicher: 3794 597 2650 93 690 3197
Swap: 0 0 0

looks good

Nope, looks not good, as it is in German, while G_INIT should have enforced C.UTF-8. Can you show the output of:

locale -a
ls -l /usr/lib/locale

Now that you say it … I have changed locale (via dietpi-config) from de to en_US an hour ago because I wanted to test Jappe’s results and I didn’t change back…
The only thing I remeber I did during first setup was update-locale ‘LC_NUMERIC=en_US.UTF-8’ because I needed the . instead of the , for floats.

However, here are the results:

# locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
# ls -l /usr/lib/locale
total 2932
drwxr-xr-x  3 root root    4096 Aug 30 18:15 ./
drwxr-xr-x 65 root root    4096 Aug 30 02:09 ../
drwxr-xr-x  3 root root    4096 Jul 31 20:27 C.utf8/
-rw-r--r--  1 root root 3054672 Aug 30 18:15 locale-archive

after changing back to de_de I have a different output for

# locale -a

Okay, C.UTF-8 is there. Does this switch the output to English?

export LC_ALL='C.UTF-8' LANG='C.UTF-8'
free -m