Web Developer Security Guide: Real-World Linux Server Problems and Practical Fixes
Web Developer Security Guide: Real-World Linux Server Problems and Practical Fixes
If you build or deploy websites on Linux servers, security isn’t optional — it’s your responsibility. And unlike theory-heavy security guides, this article focuses on real problems that web developers actually face, along with clear, practical fixes you can apply right away.
Let’s jump straight in 👇
🧩 Problem #1 — Your Website Is Still Using HTTP (Not HTTPS)
Why this is a problem
If your site loads over HTTP, anyone on the same network can intercept:
• logins
• cookies
• admin sessions
And modern browsers will even warn users that your site is “Not Secure.”
Not a great first impression.
✅ How To Fix It (Enable HTTPS with Let’s Encrypt)
If you use NGINX:
Install Certbot:
Request the certificate:
Enable auto-renew:
Done. Your site now uses HTTPS.
✔ data is encrypted
✔ browser warnings disappear
✔ SEO improves
🧩 Problem #2 — Your SSH Login Is Getting Brute-Forced
How you know this is happening
Check your auth log:
If you see something like this:
over and over again — congratulations, bots have found you.
✅ Fix #1 — Disable Root + Password Login
Open your SSH config:
Set:
Restart SSH:
Now only SSH keys can log in.
✅ Fix #2 — Install Fail2Ban
Start and enable:
Now repeated failed logins = automatic ban.
🧩 Problem #3 — People Can See Your Folder Contents
The problem
If someone visits:
And they see a file list?
That’s bad. Really bad.
They can discover:
✔ hidden files
✔ backups
✔ scripts
✔ sensitive data
✅ Fix It — Disable Directory Listing
NGINX
Add:
Restart:
Apache
Add:
Problem solved.
🧩 Problem #4 — Your Server Version Is Publicly Visible
Why this matters
If your headers say:
or
Hackers immediately know which vulnerabilities to try.
✅ Fix
NGINX
Add:
Apache
Add:
Restart your server.
🧩 Problem #5 — PHP Errors Are Shown to Users
Why this is dangerous
Error output can reveal:
• paths
• queries
• system details
• code structure
Great for debugging.
Terrible for production.
✅ Fix — Disable PHP Display Errors
Edit php.ini:
Restart PHP-FPM:
Now errors go to logs, not users.
🧩 Problem #6 — Your File Permissions Are Too Loose
If you see permissions like:
That means:
✔ anyone can read
✔ anyone can modify
✔ anyone can execute
This is practically an invitation.
✅ Fix — Use Safe Defaults
Folders:
Files:
Sensitive files (.env):
Run:
🧩 Problem #7 — Your Database Is Accessible From the Internet
Why this is a disaster waiting to happen
If MySQL or PostgreSQL is listening on:
Anyone can try connecting. And people will.
✅ Fix — Bind to Localhost Only
Restart DB service.
Now only local connections work.
🧩 Problem #8 — Admin Tools Are Publicly Accessible
Examples:
Bots scan for these constantly.
✅ Fix — Restrict Access
Example (UFW firewall):
Or protect with basic auth / VPN.
🧩 Problem #9 — Debug Mode Is Enabled in Production
This leaks things like:
• stack traces
• queries
• API keys
• env values
✅ Fix — Separate Environments
Laravel:
Node.js:
Never deploy with debug mode on.
🧩 Problem #10 — You Don’t Have Backups
And you only realize when it’s too late.
✅ Fix — Automate Backups
Database:
Files:
Store backups:
✔ off-server
✔ off-cloud
✔ somewhere safe
✅ Final Security Checklist for Web Developers
Before going live, make sure:
✔ HTTPS enabled
✔ SSH hardened
✔ Firewall active
✔ Fail2Ban installed
✔ PHP errors hidden
✔ Safe file permissions
✔ Database not public
✔ Admin access restricted
✔ Debug mode disabled
✔ Backups running
✔ System updated
✔ CDN / WAF enabled