How to Install aaPanel Free Version + Nginx 1.19 + PHP 8.2/7.4 + Redis 7.2 + MySQL 8.0 on Debian 12.6 (with Memcached) for Low-Config Servers

Rey Posted on 24 days ago 33 Views


This comprehensive guide is designed for low-config VPS (2C2G). It walks you through installing the aaPanel free version, Nginx 1.19, PHP 8.2/7.4, Redis 7.2, MySQL 8.0, and Memcached 1.6, along with memory optimization to run a website with up to 5,000 daily IPs smoothly.

  1. Preparation
  2. One-Click Installation of aaPanel Free Version
  3. Environment Installation & Version Selection
  4. Memory Optimization (Complete Configuration Code)
  5. Common Issues & Tips

1. Preparation

# Update system & install common tools
apt update -y
apt install -y curl wget socat htop vim

# Enable BBR (must-have for 2C2G)
wget -N --no-check-certificate https://raw.githubusercontent.com/chiakge/Linux-NetSpeed/master/tcp.sh && bash tcp.sh
# Select option 4 to enable BBR and reboot to take effect

2. One-Click Installation of aaPanel Free Version

wget -O install.sh https://www.aapanel.com/script/install_7.0_en.sh && bash install.sh aapanel

After installation, it will prompt you with the external IP address, username, and password. Save these details in a notepad!


3. Environment Installation & Version Selection

  • Nginx 1.19 (compatible with aaPanel free WAF)
  • PHP 8.2 + 7.4 (use 8.2 for new projects, 7.4 for legacy projects)
  • MySQL 8.0
  • Redis 7.2
  • Memcached 1.6

Go to aaPanel dashboard → App Store → One-Click LNMP, select the versions mentioned above, and click "Fast Install".


4. Memory Optimization (Complete Configuration Code)

4.1 Nginx 1.19 Optimization Configuration

# /www/server/nginx/conf/nginx.conf
user  www www;
worker_processes 2;
worker_cpu_affinity 01 10;
pid /www/server/nginx/logs/nginx.pid;
error_log /www/wwwlogs/nginx_error.log warn;
worker_rlimit_nofile 65535;

events {
    use epoll;
    multi_accept on;
    worker_connections 2048;
    accept_mutex on;
}

http {
    include mime.types;
    default_type application/octet-stream;

    server_names_hash_bucket_size 128;
    client_header_buffer_size 8k;
    large_client_header_buffers 2 16k;
    client_max_body_size 20m;

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;

    keepalive_timeout 30s;
    keepalive_requests 100;

    fastcgi_connect_timeout 3s;
    fastcgi_send_timeout 30s;
    fastcgi_read_timeout 30s;
    fastcgi_buffer_size 8k;
    fastcgi_buffers 4 8k;
    fastcgi_busy_buffers_size 16k;
    fastcgi_temp_file_write_size 32k;
    fastcgi_intercept_errors on;

    gzip on;
    gzip_vary on;
    gzip_min_length 1024;
    gzip_comp_level 2;
    gzip_types text/plain text/css text/xml text/javascript application/javascript application/json application/xml+rss image/svg+xml;
    gzip_disable "msie6";

    limit_conn_zone $binary_remote_addr zone=perip:2m;
    limit_conn perip 30;
    limit_req_zone $binary_remote_addr zone=req:2m rate=10r/s;
    limit_req zone=req burst=20 nodelay;

    log_format main '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$gzip_ratio"';
    access_log off;
    server_tokens off;

    server {
        listen 888 default_server;
        server_name _;
        root /www/server/phpmyadmin;
        index index.php;
        location ~* \.(gif|jpg|jpeg|png|ico|svg|woff|woff2)$ { expires 30d; add_header Cache-Control "public, immutable"; }
        location ~* \.(css|js)$ { expires 7d; add_header Cache-Control "public"; }
        location ~ \.php$ {
            try_files $uri =404;
            fastcgi_pass unix:/run/php/php8.2-fpm.sock;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        }
        location ~ /\. { deny all; }
    }

    include /www/server/panel/vhost/nginx/*.conf;
}

4.2 PHP-FPM 8.2 / 7.4 Optimization Configuration

# /etc/php/8.2/fpm/pool.d/www.conf
[www]
listen = /tmp/php-cgi-82.sock
listen.backlog = 1024
listen.owner = www
listen.group = www
listen.mode = 0660
user = www
group = www

pm = ondemand
pm.max_children = 10
pm.process_idle_timeout = 10s
pm.max_requests = 500

request_terminate_timeout = 30s
request_slowlog_timeout = 2s
slowlog = /www/server/php/82/var/log/slow.log

4.3 PHP 8.2 / 7.4 ini Optimization

# /etc/php/8.2/fpm/php.ini  (7.4 is similar)
memory_limit = 128M
max_execution_time = 30
max_input_time = 30
post_max_size = 50M
upload_max_filesize = 50M
expose_php = Off
error_reporting = E_ALL & ~E_NOTICE
display_errors = Off
log_errors = On
session.save_handler = memcached
session.save_path = "127.0.0.1:11211"
extension = mysqli
extension = pdo_mysql
extension = redis
extension = opcache
extension = memcached

4.4 MySQL 8.0 Optimization Configuration (Disable Binlog)

# /etc/mysql/mysql.conf.d/mysqld.cnf
[client]
port = 3306
socket = /tmp/mysql.sock

[mysqld]
port = 3306
socket = /tmp/mysql.sock
datadir = /www/server/data

# Basic
default_storage_engine = InnoDB
lower_case_table_names = 1
sql_mode = STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION
skip_name_resolve = 1

# Connections
max_connections = 200
max_connect_errors = 1000
open_files_limit = 65535
thread_cache_size = 16
max_allowed_packet = 64M

# Session Buffers
sort_buffer_size = 256K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
join_buffer_size = 256K
tmp_table_size = 32M
max_heap_table_size = 32M

# InnoDB
innodb_buffer_pool_size = 512M
innodb_log_buffer_size = 16M
innodb_flush_log_at_trx_commit = 2
innodb_flush_method = O_DIRECT
innodb_file_per_table = 1
innodb_lock_wait_timeout = 50
innodb_data_file_path = ibdata1:10M:autoextend

# Disable Binlog

This author has not provided a description.
Last updated on 2025-08-18