WordPress için En İyi Sunucu Yapılandırması
WordPress için optimal sunucu yapılandırması: LEMP stack, PHP-FPM, Nginx FastCGI cache, Redis, MariaDB tuning, OPcache ve CDN kurulumu. Farklı trafik seviyeleri için önerilen özellikler.
İçindekiler
WordPress için En İyi Sunucu Yapılandırması
WordPress, dünyanın en popüler içerik yönetim sistemidir. Ancak varsayılan yapılandırmayla çalıştırıldığında performans sorunları yaşanabilir. Bu rehber, WordPress sitenizi hızlı ve güvenilir şekilde çalıştırmak için optimal sunucu yapılandırmasını adım adım açıklar.
Trafik Seviyesine Göre Önerilen Sunucu Özellikleri
| Trafik Seviyesi | Aylık Ziyaretçi | CPU | RAM | Depolama | Önerilen Plan |
|---|---|---|---|---|---|
| Küçük | < 10.000 | 2 vCPU | 2 GB | 20 GB NVMe | VPS Başlangıç |
| Orta | 10.000 - 100.000 | 4 vCPU | 4-8 GB | 50 GB NVMe | VDS Başlangıç |
| Büyük | 100.000 - 500.000 | 8 vCPU | 16 GB | 100 GB NVMe | VDS Pro |
| Kurumsal | 500.000+ | 16+ vCPU | 32+ GB | 200+ GB NVMe | Dedicated |
LEMP Stack Kurulumu
WordPress için en iyi performansı LEMP stack (Linux + Nginx + MariaDB + PHP-FPM) sağlar. Apache'ye göre daha az bellek kullanır ve daha yüksek eş zamanlı bağlantıyı destekler.
# Sistemi güncelle
sudo apt update && sudo apt upgrade -y
# Nginx kur
sudo apt install nginx -y
# MariaDB kur
sudo apt install mariadb-server mariadb-client -y
# PHP ve gerekli uzantıları kur
sudo apt install php8.2-fpm php8.2-mysql php8.2-xml php8.2-gd \
php8.2-curl php8.2-mbstring php8.2-zip php8.2-intl \
php8.2-bcmath php8.2-imagick php8.2-redis -y
PHP-FPM Pool Yapılandırması
PHP-FPM'i WordPress için optimize etmek, bellek kullanımını ve yanıt sürelerini iyileştirir.
sudo nano /etc/php/8.2/fpm/pool.d/wordpress.conf
[wordpress]
user = www-data
group = www-data
listen = /run/php/php8.2-fpm-wordpress.sock
listen.owner = www-data
listen.group = www-data
; Dinamik process yönetimi
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
; PHP ayarları
php_admin_value[memory_limit] = 256M
php_admin_value[upload_max_filesize] = 64M
php_admin_value[post_max_size] = 64M
php_admin_value[max_execution_time] = 300
php_admin_value[max_input_vars] = 3000
; OPcache
php_admin_flag[opcache.enable] = on
php_admin_value[opcache.memory_consumption] = 128
php_admin_value[opcache.max_accelerated_files] = 10000
php_admin_value[opcache.revalidate_freq] = 2
Nginx Yapılandırması ve FastCGI Cache
Nginx FastCGI cache, PHP işlemlerini atlayarak statik içerik gibi hızlı yanıt verir.
sudo nano /etc/nginx/nginx.conf
# FastCGI cache zone tanımla
fastcgi_cache_path /var/cache/nginx/wordpress
levels=1:2
keys_zone=WORDPRESS:100m
inactive=60m
max_size=1g;
fastcgi_cache_key "$scheme$request_method$host$request_uri";
sudo nano /etc/nginx/sites-available/wordpress
server {
listen 443 ssl http2;
server_name example.com www.example.com;
root /var/www/wordpress;
index index.php;
# SSL
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
# FastCGI cache ayarları
set $skip_cache 0;
# POST isteklerini ve query string'leri cache'leme
if ($request_method = POST) { set $skip_cache 1; }
if ($query_string != "") { set $skip_cache 1; }
# WordPress özel URL'leri cache'leme
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap") {
set $skip_cache 1;
}
# Giriş yapmış kullanıcıları cache'leme
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") {
set $skip_cache 1;
}
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php/php8.2-fpm-wordpress.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# FastCGI cache
fastcgi_cache WORDPRESS;
fastcgi_cache_valid 200 60m;
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_cache_bypass $skip_cache;
fastcgi_no_cache $skip_cache;
add_header X-FastCGI-Cache $upstream_cache_status;
}
# Statik dosyalar için uzun cache süresi
location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff|woff2|ttf|svg)$ {
expires 1y;
add_header Cache-Control "public, immutable";
access_log off;
}
# WordPress güvenlik
location ~ /\.ht { deny all; }
location = /xmlrpc.php { deny all; }
location ~* /wp-config.php { deny all; }
}
Redis Object Cache
Redis, WordPress veritabanı sorgularını önbelleğe alarak sayfa yükleme sürelerini önemli ölçüde azaltır.
# Redis kur
sudo apt install redis-server -y
# Redis yapılandırması
sudo nano /etc/redis/redis.conf
# Bellek limiti
maxmemory 256mb
maxmemory-policy allkeys-lru
# Kalıcılık (WordPress için gerekli değil)
save ""
# Unix socket (daha hızlı)
unixsocket /var/run/redis/redis-server.sock
unixsocketperm 770
# Redis'i yeniden başlat
sudo systemctl restart redis-server
# www-data kullanıcısını redis grubuna ekle
sudo usermod -aG redis www-data
WordPress Redis Entegrasyonu
# wp-config.php'ye ekle
define('WP_REDIS_HOST', '/var/run/redis/redis-server.sock');
define('WP_REDIS_PORT', 0);
define('WP_REDIS_DATABASE', 0);
define('WP_REDIS_TIMEOUT', 1);
define('WP_REDIS_READ_TIMEOUT', 1);
WordPress admin panelinden "Redis Object Cache" eklentisini kurun ve etkinleştirin.
MariaDB Optimizasyonu
sudo nano /etc/mysql/mariadb.conf.d/99-wordpress.cnf
[mysqld]
# InnoDB ayarları
innodb_buffer_pool_size = 1G # RAM'in %50-70'i
innodb_buffer_pool_instances = 4
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 2 # Performans için (1 = tam güvenlik)
innodb_flush_method = O_DIRECT
# Query cache (MariaDB 10.1+)
query_cache_type = 1
query_cache_size = 64M
query_cache_limit = 2M
# Bağlantı ayarları
max_connections = 150
wait_timeout = 60
interactive_timeout = 60
# Geçici tablolar
tmp_table_size = 64M
max_heap_table_size = 64M
# Slow query log
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow.log
long_query_time = 2
# MariaDB'yi yeniden başlat
sudo systemctl restart mariadb
# Performans analizi
mysqlcheck -u root -p --all-databases --optimize
OPcache Yapılandırması
OPcache, PHP kodunu derlenmiş bytecode olarak önbelleğe alır ve her istekte yeniden derleme ihtiyacını ortadan kaldırır.
sudo nano /etc/php/8.2/fpm/conf.d/10-opcache.ini
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=256
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=10000
opcache.max_wasted_percentage=10
opcache.validate_timestamps=1
opcache.revalidate_freq=2
opcache.fast_shutdown=1
opcache.jit=1255
opcache.jit_buffer_size=128M
CDN Kurulumu
CDN (Content Delivery Network), statik dosyalarınızı dünya genelindeki sunuculara dağıtarak yükleme sürelerini azaltır.
Cloudflare Entegrasyonu
- Cloudflare'e kaydolun ve domain'inizi ekleyin
- DNS kayıtlarını Cloudflare'e taşıyın
- SSL/TLS modunu "Full (Strict)" olarak ayarlayın
- WordPress'te Cloudflare eklentisini kurun
// wp-config.php'ye ekle (Cloudflare arkasında)
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
$_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
$_SERVER['HTTPS'] = 'on';
}
WordPress Güvenlik Yapılandırması
// wp-config.php güvenlik ayarları
define('DISALLOW_FILE_EDIT', true); // Tema/eklenti editörünü kapat
define('DISALLOW_FILE_MODS', false); // Eklenti güncellemelerine izin ver
define('FORCE_SSL_ADMIN', true); // Admin HTTPS zorunlu
define('WP_DEBUG', false); // Debug kapalı (production)
define('WP_DEBUG_LOG', false);
define('AUTOMATIC_UPDATER_DISABLED', false); // Otomatik güncellemeler açık
// Güvenlik anahtarları (https://api.wordpress.org/secret-key/1.1/salt/ adresinden alın)
define('AUTH_KEY', 'benzersiz-anahtar-buraya');
define('SECURE_AUTH_KEY', 'benzersiz-anahtar-buraya');
// ... diğer anahtarlar
Yedekleme Stratejisi
# WordPress dosyaları ve veritabanı yedekleme scripti
#!/bin/bash
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/backup/wordpress"
WP_DIR="/var/www/wordpress"
DB_NAME="wordpress"
DB_USER="wpuser"
DB_PASS="sifre"
# Dizin oluştur
mkdir -p $BACKUP_DIR
# Veritabanı yedekle
mysqldump -u $DB_USER -p$DB_PASS $DB_NAME | \
gzip > $BACKUP_DIR/db_$DATE.sql.gz
# Dosyaları yedekle (uploads hariç büyük dosyalar)
tar -czf $BACKUP_DIR/files_$DATE.tar.gz \
--exclude=$WP_DIR/wp-content/cache \
$WP_DIR
# 30 günden eski yedekleri sil
find $BACKUP_DIR -mtime +30 -delete
echo "Yedekleme tamamlandı: $DATE"
Performans Test Araçları
# Apache Benchmark ile yük testi
ab -n 1000 -c 50 https://example.com/
# wrk ile gelişmiş yük testi
wrk -t12 -c400 -d30s https://example.com/
# PHP-FPM durumu
curl http://localhost/fpm-status
# Nginx cache durumu
curl -I https://example.com/ | grep X-FastCGI-Cache
WordPress performansını artırmak için önce en büyük etkiyi yapan optimizasyonları uygulayın: 1) OPcache, 2) FastCGI cache, 3) Redis object cache, 4) CDN. Bu dört adım çoğu WordPress sitesini 5-10 kat hızlandırır.
İlgili Makaleler
Node.js Uygulaması Deploy Etme: PM2 ve Nginx
Node.js uygulamasını VPS'e deploy etme rehberi. nvm ile Node.js kurulumu, PM2 process manager, Nginx reverse proxy, SSL sertifikası ve environment variables yönetimi.
PHP Uygulaması Deploy Etme: LAMP ve LEMP Stack
PHP uygulamasını VPS'e deploy etme rehberi. LAMP ve LEMP stack karşılaştırması, Apache/Nginx + PHP-FPM + MySQL kurulumu, sanal host yapılandırması ve PHP sürüm yönetimi.
WordPress Kurulumu ve Optimizasyonu: VPS Rehberi
VPS'te WordPress kurulumu ve optimizasyonu rehberi. LEMP stack, wp-config.php ayarları, dosya izinleri, SSL, OPcache performans optimizasyonu ve güvenlik sertleştirme.