# Amir Shahamiri (امیر شاه‌امیری) > IT engineer, software developer and business consultant. I build software and help businesses choose the right technology and put it to work properly. Personal site with practical articles on servers and Linux, programming, and technology decisions for businesses. Published in English (under /en) and Persian (at the root); most articles exist in both languages with the same slug. - About: https://amirshahamiri.ir/en/about (Persian: https://amirshahamiri.ir/about) - Contact: https://amirshahamiri.ir/en/contact - Articles: https://amirshahamiri.ir/en/articles (Persian: https://amirshahamiri.ir/articles) - Feeds: https://amirshahamiri.ir/en/feed.xml, https://amirshahamiri.ir/feed.xml ## English articles — Infrastructure - [How to Fix 502 Bad Gateway in Nginx with PHP-FPM](https://amirshahamiri.ir/en/articles/nginx-502-bad-gateway): Fix 502 Bad Gateway in Nginx with PHP-FPM: read error.log, fix socket path and permissions, pm.max_children, timeouts, header buffers and nginx -t. - [Bash Scripting Basics: Automate Repetitive Tasks on Linux](https://amirshahamiri.ir/en/articles/bash-scripting-basics): Bash scripting basics for Linux: shebang, set -euo pipefail, quoting, arguments, conditionals, loops, functions, exit codes, logging and shellcheck. - [Cron Jobs in Linux: Crontab Syntax Explained (and systemd Timers)](https://amirshahamiri.ir/en/articles/cron-jobs-linux): How cron jobs work in Linux: the five crontab time fields with examples, /etc/cron.d, environment pitfalls, logging, flock and systemd timers. - [DNS Records Explained: A, AAAA, CNAME, MX, TXT, NS and CAA](https://amirshahamiri.ir/en/articles/dns-records-explained): DNS records explained with examples: A, AAAA, CNAME, MX, TXT, NS and CAA, what TTL means, why CNAME can't go on the root domain, and checking with dig. - [Docker Compose Explained with a Real Example (Postgres + Redis)](https://amirshahamiri.ir/en/articles/docker-compose-explained): Docker Compose explained: what it is and how it works, with a web app, PostgreSQL and Redis, volumes, healthchecks, depends_on and everyday commands. - [Free SSL Certificate with Let's Encrypt and Certbot on Ubuntu](https://amirshahamiri.ir/en/articles/free-ssl-lets-encrypt): Get a free SSL certificate from Let's Encrypt with Certbot on Ubuntu for Nginx or Apache, for .ir or any domain: auto-renewal, wildcards and common errors. - [How to Install Docker on Ubuntu 24.04 (Docker Engine)](https://amirshahamiri.ir/en/articles/install-docker-ubuntu-24): How to install Docker on Ubuntu 24.04 from the official repository: post-install steps, hello-world test, docker.io vs. docker-ce, and full uninstall. - [Essential Linux Commands for Server Administration](https://amirshahamiri.ir/en/articles/linux-commands-for-servers): Essential Linux commands for managing an Ubuntu server, grouped by task, with real examples and a cheat sheet of the 25 you will use every day. - [Linux Server Disk Full? How to Find and Free Up Space](https://amirshahamiri.ir/en/articles/linux-disk-full): Linux server disk full? Find the culprit with df, du and ncdu, then fix deleted-but-open files, logs, the journal, apt, Docker, inodes and alerting. - [Linux Server Monitoring: What to Watch and Which Tools to Use](https://amirshahamiri.ir/en/articles/linux-server-monitoring): Linux server monitoring made simple: what to watch (CPU, load average, memory, disk, services), built-in tools, Netdata, and a cron health-check script. - [rsync Command in Linux: Copy and Sync Files Between Servers](https://amirshahamiri.ir/en/articles/rsync-guide): The rsync command in Linux with examples: -avzh, the trailing slash rule, dry-run, the risks of --delete, exclude, custom SSH ports and resuming transfers. - [How to Create SSH Keys and Connect to a Server (Windows & Linux)](https://amirshahamiri.ir/en/articles/ssh-keys-and-connecting): Generate SSH keys (ed25519) on Windows, Linux and macOS, copy them to a server, use ~/.ssh/config, add a key to GitHub and fix common SSH errors. - [How to Create a systemd Service on Linux (Unit File Guide)](https://amirshahamiri.ir/en/articles/systemd-service): Create a systemd service on Linux: write a unit file with User, WorkingDirectory, Restart and EnvironmentFile, enable it and read logs with journalctl. - [What Is tmux? A Beginner's Guide to Keeping SSH Sessions Alive](https://amirshahamiri.ir/en/articles/tmux-guide): What is tmux and how does it work? A tmux guide from scratch: sessions, windows and panes, the prefix key, detach and attach, tmux.conf and a cheat sheet. - [What Is a VPS? VPS vs. Shared vs. Dedicated Hosting](https://amirshahamiri.ir/en/articles/vps-vs-shared-hosting): What is a VPS, what is it used for, and how does it compare with shared hosting and a dedicated server? Find out which one fits your website or app. - [The 3-2-1 Backup Rule in Practice: Backups You Can Restore](https://amirshahamiri.ir/en/articles/backups-3-2-1): The 3-2-1 backup rule in practice: consistent MySQL and PostgreSQL dumps, a bash script with rsync, scheduling with cron, and regular restore tests. - [Ubuntu 24.04 Server Hardening: The First Hour, Step by Step](https://amirshahamiri.ir/en/articles/linux-server-first-hour): Ubuntu 24.04 server hardening in the first hour: a non-root user, SSH key-only login, ufw, automatic security updates, fail2ban and time sync. ## English articles — Programming - [AI for Programming: Where It Helps and Where It Fails](https://amirshahamiri.ir/en/articles/ai-for-programmers): AI for programming: where coding assistants genuinely help, where they get things wrong, and how to use them safely, from beginner to senior developer. - [Backend Developer Roadmap: What Backend Is and Where to Start](https://amirshahamiri.ir/en/articles/backend-programming-roadmap): A realistic backend developer roadmap: what backend programming is and where to start, from one language, HTTP and SQL to Git, Linux and deployment. - [MySQL vs. PostgreSQL vs. SQLite: Which Database to Choose](https://amirshahamiri.ir/en/articles/choosing-a-database): MySQL vs. PostgreSQL vs. SQLite compared on use cases, concurrency, JSON, maintenance and hosting, plus when NoSQL actually makes sense. - [What Is CI/CD? Your First Pipeline with GitHub Actions](https://amirshahamiri.ir/en/articles/ci-cd-github-actions): What is CI/CD, and how to build your first GitHub Actions pipeline: automated Laravel and Python tests, secrets, branch protection and tag-based deploys. - [Essential Git Commands: A Beginner's Guide with Cheat Sheet](https://amirshahamiri.ir/en/articles/git-essential-commands): Essential Git commands from scratch: what Git is, the daily workflow from init to push, safe ways to undo changes, .gitignore and a cheat sheet. - [PHP vs. Python for Backend Development: Which Should You Choose?](https://amirshahamiri.ir/en/articles/php-or-python-backend): PHP vs. Python for backend development: frameworks, hosting, real-world performance, the job market and learning curve, and when each one is the better fit. - [What Affects Website Speed? 7 Factors and How to Fix Them](https://amirshahamiri.ir/en/articles/website-speed-factors): What affects website speed: server response time, hosting location, images, caching, scripts, fonts and database queries. How to test it and what to fix. - [What Is an API? A Simple Explanation with REST API Examples](https://amirshahamiri.ir/en/articles/what-is-an-api): What is an API? A plain-English explanation of REST APIs: HTTP methods, status codes, JSON, authentication, and calling an API with curl, PHP and Python. - [What Is Redis and When Should You Use It?](https://amirshahamiri.ir/en/articles/what-is-redis): What is Redis? Use cases for caching, sessions, queues and rate limiting, redis-cli examples, RDB vs. AOF persistence, Docker setup and security basics. - [Laravel Queues: Move Slow Tasks Out of the Request](https://amirshahamiri.ir/en/articles/laravel-queues-slow-work): A hands-on guide to Laravel queues in Laravel 13: creating jobs, retries and backoff, unique and failed jobs, idempotency and running workers with systemd. - [Laravel Caching: What to Cache, Where and for How Long](https://amirshahamiri.ir/en/articles/laravel-cache-where-and-how-long): A practical guide to Laravel caching in Laravel 13: what to cache, remember vs. flexible, choosing a TTL, versioned keys, invalidation and cache stampedes. ## English articles — Business - [WordPress vs. Custom Website Development: Which to Choose?](https://amirshahamiri.ir/en/articles/wordpress-or-custom): WordPress vs. custom website development, compared: time to launch, long-term cost, security, performance, flexibility and which one fits your business. - [Build vs. Buy vs. SaaS: Choosing Software for a Small Business](https://amirshahamiri.ir/en/articles/build-buy-or-subscribe): Build vs. buy vs. SaaS for a small business: three-year total cost of ownership, vendor lock-in, maintenance, security and questions to ask vendors. - [How to Write a Problem Statement Before Building Software](https://amirshahamiri.ir/en/articles/write-the-problem-before-the-code): How to write a one-page problem statement before you commission or build software: who is affected, what happens today, what it costs, and what done means. ## Persian articles (فارسی) — زیرساخت - [رفع خطای 502 Bad Gateway در Nginx (با PHP-FPM)](https://amirshahamiri.ir/articles/nginx-502-bad-gateway): رفع خطای 502 Bad Gateway در Nginx با PHP-FPM: خواندن error.log، مسیر و دسترسی سوکت، pm.max_children، تایم‌اوت‌ها، بافر هدر و nginx -t. - [کرون جاب در لینوکس: crontab به زبان ساده (و systemd timer)](https://amirshahamiri.ir/articles/cron-jobs-linux): کرون جاب در لینوکس چطور کار می‌کند: پنج فیلد زمان crontab با مثال، /etc/cron.d، دام‌های محیط، لاگ، flock و جایگزین systemd timer. - [رکوردهای DNS به زبان ساده: A، CNAME، MX، TXT و بقیه](https://amirshahamiri.ir/articles/dns-records-explained): انواع رکورد DNS با مثال: A، AAAA، CNAME، MX، TXT، NS و CAA، معنای TTL، چرا CNAME روی دامنه‌ی اصلی نمی‌نشیند و بررسی رکوردها با dig. - [داکر کامپوز به زبان ساده، با یک مثال واقعی](https://amirshahamiri.ir/articles/docker-compose-explained): docker compose چیست و چطور کار می‌کند؛ یک برنامه‌ی وب با PostgreSQL و Redis، با volume، healthcheck، depends_on و دستورهای روزمره. - [SSL رایگان با Let's Encrypt (برای دامنه‌ی ir هم)](https://amirshahamiri.ir/articles/free-ssl-lets-encrypt): گرفتن گواهی SSL رایگان از Let's Encrypt برای دامنه‌ی ir و هر دامنه‌ی دیگر با certbot روی اوبونتو، تمدید خودکار و رفع خطاهای رایج. - [نصب داکر روی اوبونتو ۲۴.۰۴ (Docker Engine)](https://amirshahamiri.ir/articles/install-docker-ubuntu-24): نصب داکر روی اوبونتو ۲۴.۰۴ از مخزن رسمی: کارهای بعد از نصب، تست با hello-world، تفاوت docker.io و docker-ce و حذف کامل Docker Engine. - [دستورات ضروری لینوکس برای مدیریت سرور](https://amirshahamiri.ir/articles/linux-commands-for-servers): دستورات لینوکس در ترمینال که برای مدیریت سرور اوبونتو هر روز لازم دارید، دسته‌بندی‌شده بر اساس کار، با مثال و جدول خلاصه‌ی ۲۵ دستور پرکاربرد. - [اتصال SSH به سرور و ساخت کلید SSH در ویندوز و لینوکس](https://amirshahamiri.ir/articles/ssh-keys-and-connecting): اتصال SSH به سرور، ساخت کلید ed25519 در ویندوز، لینوکس و مک، کپی کلید روی سرور، فایل config، اضافه‌کردن کلید به GitHub و رفع خطاهای رایج. - [سرور مجازی چیست؟ فرق هاست اشتراکی، سرور مجازی و سرور اختصاصی](https://amirshahamiri.ir/articles/vps-vs-shared-hosting): سرور مجازی چیست و چه کاربردی دارد، چه فرقی با هاست اشتراکی و سرور اختصاصی دارد و برای سایت یا اپلیکیشن شما کدام مناسب‌تر است. - [اسکریپت‌نویسی bash برای خودکارسازی کارهای تکراری](https://amirshahamiri.ir/articles/bash-scripting-basics): آموزش اسکریپت‌نویسی bash در لینوکس: shebang، set -euo pipefail، متغیر و کوتیشن، آرگومان، شرط، حلقه، تابع، کد خروج، لاگ و shellcheck با یک مثال کامل. - [دیسک سرور لینوکس پر شده؛ قدم‌به‌قدم چه کنیم؟](https://amirshahamiri.ir/articles/linux-disk-full): پر شدن دیسک سرور لینوکس: پیدا کردن مقصر با df و du و ncdu، فایل‌های پاک‌شده‌ی باز، لاگ‌ها و journal، apt، داکر، inode و هشدار پیش از پر شدن. - [مانیتورینگ ساده‌ی سرور لینوکس: از کجا بفهمیم مشکل دارد؟](https://amirshahamiri.ir/articles/linux-server-monitoring): مانیتورینگ سرور لینوکس چیست و چه چیزی را باید پایید: CPU، load average، حافظه، دیسک و سرویس‌ها؛ از ابزارهای داخلی تا Netdata و اسکریپت سلامت با cron. - [rsync: کپی و همگام‌سازی فایل‌ها بین سرورها](https://amirshahamiri.ir/articles/rsync-guide): دستور rsync در لینوکس با مثال: گزینه‌های -avzh، قاعده‌ی اسلش آخر مسیر، dry-run، خطر --delete، exclude، پورت غیراستاندارد SSH و ادامه‌ی انتقال. - [ساخت سرویس systemd برای اجرای برنامه روی لینوکس](https://amirshahamiri.ir/articles/systemd-service): ساخت سرویس systemd در لینوکس: نوشتن unit file با User، WorkingDirectory، Restart و EnvironmentFile، فعال‌سازی، لاگ با journalctl و خطاهای رایج. - [tmux چیست؟ کار روی سرور بدون ترس از قطع شدن اتصال](https://amirshahamiri.ir/articles/tmux-guide): tmux چیست و چطور کار می‌کند؟ آموزش tmux از صفر: نشست، پنجره و پنل، کلید prefix، جداشدن و برگشتن به نشست، فایل tmux.conf و جدول کلیدها. - [پشتیبانی که واقعاً بازگردانی شود: قاعده‌ی ۳-۲-۱ در عمل](https://amirshahamiri.ir/articles/backups-3-2-1): پشتیبان‌گیری با قاعده‌ی ۳-۲-۱ در عمل: dump درست از MySQL و PostgreSQL، اسکریپت bash با rsync، زمان‌بندی با cron و آزمودن منظم بازگردانی. - [ساعت اول یک سرور تازه: امن‌کردن Ubuntu 24.04 قدم‌به‌قدم](https://amirshahamiri.ir/articles/linux-server-first-hour): امن‌کردن سرور Ubuntu 24.04 در ساعت اول: کاربر غیر root، ورود فقط با کلید SSH، ufw، به‌روزرسانی امنیتی خودکار، fail2ban و تنظیم ساعت. ## Persian articles (فارسی) — برنامه‌نویسی - [کدام دیتابیس؟ MySQL، PostgreSQL یا SQLite](https://amirshahamiri.ir/articles/choosing-a-database): کدام دیتابیس را انتخاب کنیم؟ مقایسه‌ی MySQL و PostgreSQL و SQLite از نظر کاربرد، هم‌زمانی، JSON، نگه‌داری و میزبانی، و اینکه کی NoSQL منطقی است. - [دستورات مهم گیت، از صفر](https://amirshahamiri.ir/articles/git-essential-commands): دستورات مهم گیت از صفر: گیت چیست، دستورات روزمره از init تا push، راه‌های امن برگرداندن تغییرات، فایل gitignore و جدول خلاصه. - [PHP یا پایتون برای بک‌اند؟](https://amirshahamiri.ir/articles/php-or-python-backend): PHP یا پایتون برای بک‌اند؟ فرق این دو در فریم‌ورک‌ها، میزبانی، کارایی در عمل، بازار کار و سختی یادگیری، و اینکه کی کدام بهتر است. - [API چیست به زبان ساده؟ و REST API چطور کار می‌کند](https://amirshahamiri.ir/articles/what-is-an-api): API چیست؟ توضیح به زبان ساده و با مثال: REST API، متدهای HTTP، کدهای وضعیت، JSON، احراز هویت و فراخوانی API با curl، PHP و Python. - [هوش مصنوعی در برنامه‌نویسی: کجا کمک می‌کند و کجا نه](https://amirshahamiri.ir/articles/ai-for-programmers): دستیارهای هوش مصنوعی در برنامه‌نویسی کجا واقعاً کمک می‌کنند، کجا اشتباه می‌کنند، و چطور امن و درست از آن‌ها استفاده کنیم؛ از تازه‌کار تا حرفه‌ای. - [برنامه‌نویسی بک‌اند چیست و از کجا شروع کنیم؟](https://amirshahamiri.ir/articles/backend-programming-roadmap): برنامه‌نویسی بک‌اند چیست و از کجا شروع کنیم؟ مسیر یادگیری واقع‌بینانه: یک زبان، HTTP، SQL، فریم‌ورک، git، لینوکس و استقرار با پروژه‌ی تمرینی. - [CI/CD چیست؟ اولین خط تولید خودکار با GitHub Actions](https://amirshahamiri.ir/articles/ci-cd-github-actions): CI/CD چیست و چطور با GitHub Actions اولین pipeline را بسازیم: تست خودکار Laravel و Python، secrets، محافظت از شاخه و استقرار با تگ. - [سرعت سایت به چه عواملی بستگی دارد؟ (و چطور سریع‌ترش کنیم)](https://amirshahamiri.ir/articles/website-speed-factors): سرعت سایت به سرور، محل میزبانی، تصاویر، کش، اسکریپت‌ها، فونت‌ها و پایگاه‌داده بستگی دارد. چطور تستش کنیم و از کجا شروع کنیم. - [Redis چیست و چه زمانی لازمش داریم؟](https://amirshahamiri.ir/articles/what-is-redis): Redis چیست به زبان ساده: کاربردها در کش، سشن، صف و محدودیت نرخ، انواع داده با مثال redis-cli، ماندگاری RDB و AOF، اجرا با Docker و نکته‌های امنیتی. - [صف در لاراول: کارهای کند را از دل درخواست بیرون بکشید](https://amirshahamiri.ir/articles/laravel-queues-slow-work): راهنمای عملی صف در لاراول ۱۳: ساخت Job، تلاش دوباره و backoff، کارهای یکتا، Job‌های شکست‌خورده، idempotency و اجرای worker با systemd. - [کش در لاراول: چه چیزی را، کجا و برای چه مدت](https://amirshahamiri.ir/articles/laravel-cache-where-and-how-long): راهنمای عملی کش در لاراول ۱۳: انتخاب داده برای کش، remember و flexible، تعیین TTL، کلیدهای نسخه‌دار، پاک‌کردن کش و جلوگیری از هجوم هم‌زمان. ## Persian articles (فارسی) — کسب‌وکار - [طراحی سایت: وردپرس یا کدنویسی اختصاصی؟](https://amirshahamiri.ir/articles/wordpress-or-custom): مقایسه‌ی صادقانه‌ی طراحی سایت با وردپرس و کدنویسی اختصاصی: سرعت راه‌اندازی، هزینه در طول زمان، امنیت، کارایی، انعطاف و اینکه کدام برای شما مناسب است. - [بسازیم، بخریم یا اشتراک بگیریم؟ انتخاب نرم‌افزار برای کسب‌وکار کوچک](https://amirshahamiri.ir/articles/build-buy-or-subscribe): مقایسه‌ی ساخت، خرید و اشتراک نرم‌افزار برای کسب‌وکار کوچک: هزینه‌ی سه‌ساله، وابستگی، نگهداری، امنیت و فهرست سؤال از فروشنده. - [اول مسئله را بنویسید، بعد سراغ کد بروید](https://amirshahamiri.ir/articles/write-the-problem-before-the-code): پیش از سفارش یا ساخت نرم‌افزار، شرح مسئله را در یک صفحه بنویسید: چه کسی، امروز چه می‌شود، چقدر هزینه دارد و «تمام‌شده» یعنی چه.