kit/php
mpmc 618f91c335 add files from misc repo 2022-09-14 23:09:19 +01:00
..
7.4/fpm/pool.d add files from misc repo 2022-09-14 23:09:19 +01:00
README.debian.md add files from misc repo 2022-09-14 23:09:19 +01:00
php-7.4-install.sh add files from misc repo 2022-09-14 23:09:19 +01:00

README.debian.md

PHP

Installing PHP on Debian is easy as...

apt install php-fpm php-readline php-mbstring php-gd \
php-curl php-zip php-mysql php-dom php-json php-pdo php-fileinfo \
php-bz2 php-intl php-gmp php-apcu php-pear php-cli php-imagick

If you need a newer version, use the sury.org repos, take a look at this readme or use the php8.1-sury-install.sh script in this directory...

sudo bash php8.1-sury-install.sh

Now you have php installed you need to copy the localhost.conf.example file (See notes 1) in this directory to where your php-fpm pool files are.

If you have multiple PHP versions installed you'll need to pick the version you want your site to run on.

So, for PHP-FPM 7.4 using the example file...

cp -v localhost.conf.example /etc/php/7.4/fpm/pool.d/yoursite.com.conf

For PHP 8.1...

cp -v localhost.conf.example /etc/php/8.1/fpm/pool.d/yoursite.com.conf

You'll need to rename and modify the values (within the copied file) to match your site. I've left the main things to change at the top of the config file.


Got your config modified and sorted? Great! Now we need to restart php-fpm. This varies depending on your version, but just you change the PHP version number in the command below...

For 7.4...

systemctl restart php7.4-fpm

And 8.1...

systemctl restart php8.1-fpm

fpm is now ready to serve your php files via the socket /run/php/yoursite.com.sock. You'll need to configure your webserver to send any PHP requests along to it. If you're using Caddy with my Caddyfile you're already set.

TIP: You can use systemctl status php7.4 to check for errors!

Disabling configurations & what about www.conf?

The included www.conf won't hurt and can be left alone, although if you want to disable it, just rename it to www.conf.disabled. You can do the same for any other configs you don't want used...

cd /etc/php/7.4/fpm/pool.d/
mv -v www.conf www.conf.disabled

And to enable it again...

cd /etc/php/7.4/fpm/pool.d/
mv -v www.conf.disabled www.conf

PHP-FPM needs to be reloaded, you can do that with...

systemctl reload php7.4-fpm

Notes

[1] It's a symlink to the one I use with 7.4. It works fine on PHP 8.1.