From f82f855f9b51b63739de79bf80095a7ea1f03e18 Mon Sep 17 00:00:00 2001 From: bpetschowitsch Date: Thu, 16 Apr 2026 14:13:59 +0200 Subject: [PATCH] Create 05_php_addressbook.md --- 05_php_addressbook.md | 99 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 05_php_addressbook.md diff --git a/05_php_addressbook.md b/05_php_addressbook.md new file mode 100644 index 0000000..f9a23bb --- /dev/null +++ b/05_php_addressbook.md @@ -0,0 +1,99 @@ +# Enable PHP in Nginx + +run in bash: + +```bash +sudo apt install php-fpm -y +``` + +get php version/sock + +```bash +ls -l /run/php/*.sock +``` + +add to nginx config (server section): + +```nginx +# pass PHP scripts to FastCGI server +# +location ~ \.php$ { + include snippets/fastcgi-php.conf; + fastcgi_pass unix:/run/php/php8.4-fpm.sock; # <-- use version from output above! +} +``` + +validate nginx configuration & restart if ok: + +```bash +sudo nginx -t +sudo systemctl reload nginx +``` + +create Demo-App: + +```bash +sudo vi /var/www/*domain-name*/*webapp*.php +``` + +## Demo Webapp (Addressbook) + +```php + + + + + + Demo: Addressbook + + + +

Einfaches Adressbuch

+ +
+ + +
+ +
+ +

Einträge:

+ +
+ Benutzer: +
+ + +

Liste leeren

+ + + + +``` + +create txt file (as database): + +```bash +cd /var/www/*domain-name* +sudo touch names.txt +sudo chown www-data:www-data names.txt +sudo chown www-data:www-data *webapp* +``` + +testing the webapp: + +``` +http://*domain-name*/*webapp*.php +``` +