caddy
https://caddyserver.com/docs/install#debian-ubuntu-raspbian
sudo apt update
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo tee /etc/apt/trusted.gpg.d/caddy-stable.asc
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy
# the code sits in /var/www
# create link to the local directory
ln -s /var/www/ /home/xxx/myprojects/web
# set the user to be xxx and the group caddy
sudo chown -R xxx:caddy ./www
# add us to caddy groups
sudo usermod -a -G caddy xxx
sudo usermod -a -G www-data xxx
Install php-fpm
sudo apt install php-cli php-fpm php-mysql php-mbstring php-curl
https://www.howtoforge.com/tutorial/ubuntu-caddy-web-server-installation/
configure caddy with php
sudo nano /etc/php/8.1/fpm/pool.d/www.conf
#change users to caddy (user, group, listen.owner, listen.group)
#take the socket name: listen = /run/php/php8.1-fpm.sock
nano php.ini # set E_ALL view all errors
sudo systemctl restart php8.1-fpm
#set socket in Caddyfile: php_fastcgi unix//run/php/php8.1-fpm.sock
sudo service caddy stop && sudo service caddy start
Caddyfile
website.com {
#:80 {
tls /var/www/fullchain.pem /var/www/privkey.pem
# Set this path to your site's directory.
root * /var/www/website.com
php_fastcgi unix//run/php/php7.4-fpm.sock
# Enable the static file server.
# file_server
rewrite /symbol/* s.php?s={path}
# rewrite /symbol/ {
# r ^/(\w+)/?$
# to /symbol.php?symbol={1}
# }
file_server
encode gzip
log {
output file /var/log/caddy/example.com.access.log {
roll_size 3MiB
roll_keep 5
roll_keep_for 48h
}
format console
}
# Another common task is to set up a reverse proxy:
# reverse_proxy localhost:8080
# Or serve a PHP site through php-fpm:
# php_fastcgi localhost:9000
#RewriteRule ^symbol/jscss/([^/]*)\.([^/]*)$ /jscss/$1.$2 [L] # no need for those since we used <base href="../" />
#RewriteRule ^symbol/images/([^/]*)\.([^/]*)$ /images/$1.$2 [L]
#rewrite /symbol/* / symbol.php?symbol={query}
}
I had the same problem whith my docker php-fpm and I fixed it by modifing parameters
in these files: /usr/local/etc/php-fpm.d/www.conf /usr/local/etc/php-fpm.d/www.conf.default
The new parameters are :
pm = dynamic
pm.max_children = 25
pm.start_servers = 10
pm.min_spare_servers = 5
pm.max_spare_servers = 20
pm.max_requests = 500
- ADD how to enabled logs in PHP
Comments
Post a Comment