Ana içeriğe geç
Kategoriye Dön

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.

Okuma süresi: 20 dk Web Hosting / Uygulama
wordpressvpslempnginxphp-fpmmysqlsslopcachegüvenlik
Yazar
REXE Teknoloji Ağ ve Güvenlik Ekibi
Editör
REXE Teknoloji Teknik Yayın Editörü
İlk yayın
Son güncelleme

WordPress Kurulumu ve Optimizasyonu: VPS Rehberi

WordPress, dünya genelinde en yaygın kullanılan içerik yönetim sistemidir. Paylaşımlı hosting yerine VPS üzerinde WordPress çalıştırmak; daha fazla kontrol, daha iyi performans ve özelleştirme imkânı sunar. Bu rehberde LEMP stack üzerinde WordPress kurulumunu, yapılandırmasını ve optimizasyonunu ele alacağız.

Ön Hazırlık: LEMP Stack

WordPress için LEMP stack (Linux + Nginx + MySQL + PHP) önerilir.

hljs bash
# Sistem güncellemesi
sudo apt update && sudo apt upgrade -y

# Nginx kur
sudo apt install nginx -y
sudo systemctl enable nginx

# MariaDB kur
sudo apt install mariadb-server -y
sudo systemctl enable mariadb
sudo mysql_secure_installation

# PHP 8.2 ve WordPress için gerekli eklentiler
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php -y
sudo apt update
sudo apt install php8.2 php8.2-fpm php8.2-mysql php8.2-xml php8.2-curl \
  php8.2-mbstring php8.2-zip php8.2-gd php8.2-imagick php8.2-intl \
  php8.2-bcmath php8.2-soap -y
sudo systemctl enable php8.2-fpm

WordPress Veritabanı Oluşturma

hljs bash
sudo mysql -u root -p
hljs sql
CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'guclu-sifre-buraya';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;

WordPress İndirme ve Kurulum

hljs bash
# WordPress'i indir
cd /tmp
wget https://wordpress.org/latest.tar.gz
tar -xzf latest.tar.gz

# Web dizinine taşı
sudo mv wordpress /var/www/mysite.com

# Dosya izinlerini ayarla
sudo chown -R www-data:www-data /var/www/mysite.com
sudo find /var/www/mysite.com -type d -exec chmod 755 {} \;
sudo find /var/www/mysite.com -type f -exec chmod 644 {} \;

wp-config.php Yapılandırması

hljs bash
# Örnek config dosyasını kopyala
cd /var/www/mysite.com
sudo cp wp-config-sample.php wp-config.php
sudo nano wp-config.php
hljs php
// Veritabanı ayarları
define( 'DB_NAME', 'wordpress' );
define( 'DB_USER', 'wpuser' );
define( 'DB_PASSWORD', 'guclu-sifre-buraya' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8mb4' );
define( 'DB_COLLATE', 'utf8mb4_unicode_ci' );

// Güvenlik anahtarları (https://api.wordpress.org/secret-key/1.1/salt/ adresinden al)
define('AUTH_KEY',         'benzersiz-deger-1');
define('SECURE_AUTH_KEY',  'benzersiz-deger-2');
define('LOGGED_IN_KEY',    'benzersiz-deger-3');
define('NONCE_KEY',        'benzersiz-deger-4');
define('AUTH_SALT',        'benzersiz-deger-5');
define('SECURE_AUTH_SALT', 'benzersiz-deger-6');
define('LOGGED_IN_SALT',   'benzersiz-deger-7');
define('NONCE_SALT',       'benzersiz-deger-8');

// HTTPS arkasında çalışıyorsa
define('FORCE_SSL_ADMIN', true);
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
    $_SERVER['HTTPS'] = 'on';
}

// Dosya düzenlemeyi devre dışı bırak (güvenlik)
define('DISALLOW_FILE_EDIT', true);

// Otomatik güncelleme ayarları
define('WP_AUTO_UPDATE_CORE', 'minor');

// Bellek limiti
define('WP_MEMORY_LIMIT', '256M');

Nginx Yapılandırması (WordPress için)

hljs bash
sudo nano /etc/nginx/sites-available/mysite.com
hljs nginx
server {
    listen 80;
    server_name mysite.com www.mysite.com;
    root /var/www/mysite.com;
    index index.php;

    # WordPress permalink yapısı
    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    # PHP-FPM
    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    # Güvenlik: xmlrpc.php'yi engelle
    location = /xmlrpc.php {
        deny all;
    }

    # Güvenlik: wp-config.php'ye erişimi engelle
    location = /wp-config.php {
        deny all;
    }

    # Gizli dosyalara erişimi engelle
    location ~ /\. {
        deny all;
    }

    # Statik dosyalar için cache
    location ~* \.(jpg|jpeg|png|gif|ico|css|js|woff|woff2|svg)$ {
        expires 1y;
        add_header Cache-Control "public, immutable";
        log_not_found off;
    }

    # Yükleme boyutu
    client_max_body_size 64M;

    access_log /var/log/nginx/mysite.com.access.log;
    error_log /var/log/nginx/mysite.com.error.log;
}
hljs bash
sudo ln -s /etc/nginx/sites-available/mysite.com /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

SSL Sertifikası

hljs bash
sudo apt install certbot python3-certbot-nginx -y
sudo certbot --nginx -d mysite.com -d www.mysite.com

PHP Optimizasyonu (OPcache)

hljs bash
sudo nano /etc/php/8.2/fpm/php.ini
hljs ini
; OPcache ayarları
opcache.enable = 1
opcache.memory_consumption = 256
opcache.interned_strings_buffer = 16
opcache.max_accelerated_files = 10000
opcache.revalidate_freq = 2
opcache.save_comments = 1

; WordPress için önerilen ayarlar
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_vars = 3000
hljs bash
sudo systemctl restart php8.2-fpm

WordPress Güvenlik Sertleştirme

hljs bash
# wp-login.php için IP kısıtlaması (Nginx)
# /etc/nginx/sites-available/mysite.com içine ekle:
location = /wp-login.php {
    allow 1.2.3.4;  # Kendi IP adresiniz
    deny all;
    include snippets/fastcgi-php.conf;
    fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;
}
hljs bash
# Dosya izinlerini kontrol et
sudo find /var/www/mysite.com -type f -name '*.php' -exec chmod 644 {} \;
sudo chmod 600 /var/www/mysite.com/wp-config.php

wp-config.php dosyasının izinlerini 600 olarak ayarlayın. Bu dosya veritabanı şifrenizi içerir.

Performans Optimizasyonu

Nginx FastCGI Cache

hljs nginx
# /etc/nginx/nginx.conf içine http bloğuna ekle:
fastcgi_cache_path /var/cache/nginx levels=1:2 keys_zone=WORDPRESS:100m inactive=60m;
fastcgi_cache_key "$scheme$request_method$host$request_uri";

# Site yapılandırmasına ekle:
set $skip_cache 0;

# POST istekleri ve giriş yapmış kullanıcılar için cache'i atla
if ($request_method = POST) { set $skip_cache 1; }
if ($query_string != "") { set $skip_cache 1; }
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php") { set $skip_cache 1; }
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { set $skip_cache 1; }

location ~ \.php$ {
    fastcgi_cache WORDPRESS;
    fastcgi_cache_valid 200 60m;
    fastcgi_cache_bypass $skip_cache;
    fastcgi_no_cache $skip_cache;
    add_header X-FastCGI-Cache $upstream_cache_status;
    # ... diğer fastcgi ayarları
}

REXE sunucularında WordPress için en az 2 GB RAM önerilir. Yüksek trafikli siteler için 4 GB+ RAM ve SSD disk tercih edin.

Sonuç

WordPress siteniz artık VPS üzerinde LEMP stack ile çalışıyor, SSL ile güvenli ve OPcache ile optimize edilmiş durumda. Düzenli yedekleme, güvenlik güncellemeleri ve performans izleme ile sitenizi sağlıklı tutun.

Sık Sorulan Sorular

WordPress kurulumunda 'Error establishing a database connection' hatası alıyorum.

wp-config.php dosyasındaki DB_NAME, DB_USER, DB_PASSWORD ve DB_HOST değerlerini kontrol edin. MySQL'in çalıştığını 'sudo systemctl status mariadb' ile doğrulayın. Kullanıcının veritabanına erişim yetkisi olduğunu 'SHOW GRANTS FOR wpuser@localhost;' SQL komutuyla kontrol edin.

WordPress yönetici paneline giremiyorum, ne yapmalıyım?

Nginx yapılandırmasında try_files direktifinin doğru olduğunu kontrol edin. PHP-FPM'in çalıştığını 'sudo systemctl status php8.2-fpm' ile doğrulayın. Nginx error logunu 'sudo tail -f /var/log/nginx/mysite.com.error.log' ile inceleyin. wp-login.php için IP kısıtlaması varsa kendi IP'nizi whitelist'e ekleyin.

WordPress'te resim yükleyemiyorum, dosya boyutu hatası alıyorum.

php.ini dosyasında upload_max_filesize ve post_max_size değerlerini artırın (örn: 64M). Nginx'te client_max_body_size değerini de aynı şekilde artırın. PHP-FPM ve Nginx'i yeniden başlatın. wp-config.php'ye 'define("WP_MAX_MEMORY_LIMIT", "256M");' ekleyin.

WordPress siteniz yavaş, nasıl hızlandırabilirim?

OPcache'i etkinleştirin, Nginx FastCGI cache kullanın. W3 Total Cache veya WP Super Cache eklentisi kurun. CDN (Cloudflare) kullanın. Görsel optimizasyonu için Smush veya ShortPixel eklentisi ekleyin. Veritabanını düzenli olarak optimize edin: 'wp db optimize' (WP-CLI ile).

İ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.

15 dk
nodejspm2nginx

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.

18 dk
phplamplemp

Python/Django Deploy: Gunicorn ve Nginx ile Üretim

Python/Django uygulamasını VPS'e deploy etme rehberi. Virtualenv kurulumu, Django üretim ayarları, Gunicorn WSGI sunucusu, Nginx reverse proxy, systemd servisi ve statik dosya yönetimi.

18 dk
pythondjangogunicorn
Ağ TrafiğiGelen GbpsGiden Gbps