php

php-fpm under Nginx

Install
sudo apt install -y php-fpm nginx #mariadb-server php-mysql php-gd php-curl

Configure php-fpm
# /etc/php/7.2/fpm/pool.d/www.conf
[www]
user = www-data
group = www-data
listen = /run/php/php7.2-fpm.sock
;listen = 127.0.0.1:9000
listen.owner = www-data
listen.group = www-data
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

Configure Nginx
# /etc/nginx/sites-enabled/default
server {
...
# pass PHP scripts to FastCGI server
location ~ \.php$ {

Magento: Add upload field to contact form

<?php
$URL="http://dl.panticz.de/magento/contact_attachment/form.phtml.diff";
echo "wget -q $URL -O - | patch -p2 \
/var/www/app/design/frontend/default/default/template/contacts/form.phtml";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

<?php
$URL="http://dl.panticz.de/magento/contact_attachment/IndexController.php.diff";
echo "wget -q $URL -O - | patch -p2 \
/var/www/app/code/core/Mage/Contacts/controllers/IndexController.php";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

<?php
$URL="http://dl.panticz.de/magento/contact_attachment/Mage_Contacts.csv.diff";
echo "wget -q $URL -O - | patch -p2 \
/var/www/app/locale/de_DE/Mage_Contacts.csv";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

Links
http://www.blog.magepsycho.com/adding-upload-field-in-contact-form-and-send-as-attachment/
http://www.magentocommerce.com/boards/viewthread/440759/

Puppet: PHP5 module

create module structure
mkdir -p /etc/puppet/modules/php5/manifests
mkdir -p /etc/puppet/modules/php5/files

download module definiction
<?php
$URL="https://raw.githubusercontent.com/panticz/puppet/master/modules/php5/init.pp";
echo "wget -q $URL -O /etc/puppet/modules/php5/manifests/init.pp";
echo "

";
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $URL);
curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
echo htmlspecialchars(curl_exec($c));
curl_close($c);
echo "

";
?>

add include to your client in /etc/puppet/manifests/site.pp
node "client1.local" inherits default {
...
include php5
...
}

Example: index.html

Links

PHP

Supported Versions
http://php.net/supported-versions.php

show PHP information
php -i

list loaded PHP modules
php -m

enable PHP Module
php5enmod amqp
/etc/init.d/apache2 reload

Show includes
php --ini

Run PHP built-in web server
php -S 192.168.1.100:8080 -t /var/www/

PHP syntax check
php -l FILE.php

# define parameter
php -d date.timezone="Europe/Berlin" -f

Error reporting
# report all errors except notices