Linux Server Yönetimi: Web Developer'lar İçin Temel Komutlar

z

zafer ak

Yazar

30 November 2025 3 dakika okuma 2 görüntülenme
Linux Server Yönetimi: Web Developer'lar İçin Temel Komutlar
Linux sunucu yönetimi temelleri. SSH, dosya yönetimi, process kontrol, nginx/apache konfigürasyonu.

SSH Bağlantısı

# Temel bağlantı
ssh user@server-ip

# Key ile bağlantı
ssh -i ~/.ssh/my_key.pem user@server-ip

# Port belirtme
ssh -p 2222 user@server-ip

# SSH config (~/.ssh/config)
Host myserver
    HostName 192.168.1.100
    User deploy
    IdentityFile ~/.ssh/myserver_key

# Kullanım
ssh myserver

Dosya ve Dizin Komutları

# Listeleme
ls -la                    # Detaylı liste
ls -lh                    # Human-readable boyut

# Navigasyon
cd /var/www               # Dizine git
cd ..                     # Üst dizin
cd ~                      # Home dizin
pwd                       # Mevcut dizin

# Dosya işlemleri
cp file.txt backup.txt    # Kopyala
mv old.txt new.txt        # Taşı/yeniden adlandır
rm file.txt               # Sil
rm -rf directory/         # Dizin sil (dikkatli!)

# Dizin işlemleri
mkdir new_folder          # Dizin oluştur
mkdir -p a/b/c            # Nested dizin

# Dosya içeriği
cat file.txt              # Tümünü göster
head -20 file.txt         # İlk 20 satır
tail -f log.txt           # Canlı takip
less file.txt             # Sayfalı görüntüleme
grep "error" file.txt     # Ara

Kullanıcı ve İzin Yönetimi

# Kullanıcı oluştur
sudo adduser username
sudo usermod -aG sudo username  # Sudo yetkisi

# İzinler
chmod 755 file.txt        # rwxr-xr-x
chmod 644 file.txt        # rw-r--r--
chmod -R 755 directory/   # Recursive

# Sahiplik
chown user:group file.txt
chown -R www-data:www-data /var/www/

Process Yönetimi

# Process listele
ps aux                    # Tüm process'ler
ps aux | grep php         # PHP process'leri
top                       # Canlı izleme
htop                      # Gelişmiş izleme

# Process durdur
kill PID                  # Graceful stop
kill -9 PID               # Force kill

# Service yönetimi
sudo systemctl status nginx
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl enable nginx   # Boot'ta başlat

Nginx Konfigürasyonu

# /etc/nginx/sites-available/mysite
server {
    listen 80;
    server_name example.com www.example.com;
    root /var/www/example/public;

    index index.php index.html;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    location ~ /\.ht {
        deny all;
    }
}

# Enable site
sudo ln -s /etc/nginx/sites-available/mysite /etc/nginx/sites-enabled/
sudo nginx -t
sudo systemctl reload nginx

Disk ve Memory

# Disk kullanımı
df -h                     # Disk alanı
du -sh /var/www/*         # Dizin boyutları

# Memory
free -h                   # RAM kullanımı

# Swap
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile

Firewall (UFW)

sudo ufw status
sudo ufw enable
sudo ufw allow 22         # SSH
sudo ufw allow 80         # HTTP
sudo ufw allow 443        # HTTPS
sudo ufw allow from 192.168.1.0/24

Cron Jobs

# Crontab düzenle
crontab -e

# Format: dakika saat gün ay haftanın_günü komut
# Her dakika
* * * * * /usr/bin/php /var/www/artisan schedule:run

# Her gün 02:00'de
0 2 * * * /usr/local/bin/backup.sh

# Laravel scheduler
* * * * * cd /var/www && php artisan schedule:run >> /dev/null 2>&1

Sonuç

Linux sunucu yönetimi, web developer'lar için temel bir beceridir. Bu komutları düzenli pratik ederek ustalık kazanabilirsiniz.

İlgili Yazılar