ssh debian-server
-i
apt update && apt -y install nginx
apt -y install mariadb-server mariadb-client-compat
mysql_secure_installation
cat << 'EOF' > /etc/mysql/mariadb.conf.d/99-performance-tuning.cnf
[mariadbd]
# Performance tuning for 4GB RAM
# Core memory tuning
innodb_buffer_pool_size = 1536M
innodb_log_buffer_size = 32M
max_connections = 50
# Temporary tables
tmp_table_size = 64M
max_heap_table_size = 64M
# Thread and table handling
thread_cache_size = 25
table_open_cache = 512
open_files_limit = 65535
# Query optimization
join_buffer_size = 2M
sort_buffer_size = 2M
read_buffer_size = 1M
read_rnd_buffer_size = 1M
EOF
systemctl restart mariadb
systemctl status mariadb
apt -y install php-fpm
apt install -y php-bcmath php-curl php-gd php-imagick php-intl php-json php-mbstring php-mysql php-xml php-zip
Edit /etc/nginx/sites-available/default.
Add index.php to the line index index.html index.htm index.nginx-debian.html; so it becomes:
index index.html index.htm index.nginx-debian.html index.php;
Add the following under “pass PHP scripts to FastCGI server”:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php-fpm.sock;
}
Restart NGINX and PHP-FPM
systemctl restart nginx
systemctl restart php8.4-fpm.service
Create a simple test file
mkdir -p /var/www/html/testphp
cat << 'EOF' > /var/www/html/testphp/index.php
<?php phpinfo(); ?>
EOF
Visit http://debian-server.domain.test/testphp/
Delete the test
rm -rf /var/www/html/testphp
Install certbot
apt -y install certbot python3-certbot-nginx
Generate certificates
certbot certonly --dry-run --webroot -w /var/www/html -d domain.test,www.domain.test