Find the Best Cosmetic Hospitals

Explore trusted cosmetic hospitals and make a confident choice for your transformation.

โ€œInvest in yourself โ€” your confidence is always worth it.โ€

Explore Cosmetic Hospitals

Start your journey today โ€” compare options in one place.

XAMPP – LAMPP Tutorials: List of Production Files to Cleanup Guide

Hereโ€™s a comprehensive and updated tutorial on which files should be cleaned up regularly in a production environment running XAMPP (under /opt/lampp), what each file/folder is, and how to automate cleanup safely.


XAMPP Production File Cleanup Guide

Keeping Your /opt/lampp Environment Healthy


1. Why Regular Cleanup Is Important

  • Performance: Old logs and cache files fill up disk space and slow down the system.
  • Security: Sensitive info in old logs can be a risk if not managed.
  • Reliability: Overfilled disk can cause XAMPP/MySQL/Apache to crash or refuse new data.

2. Key Locations in /opt/lampp to Clean

The typical XAMPP folder structure on Linux (like /opt/lampp) includes:

  • /opt/lampp/logs/ โ€” Apache and XAMPP logs
  • /opt/lampp/apache/logs/ โ€” Apache server logs
  • /opt/lampp/mysql/data/ or /opt/lampp/var/mysql/ โ€” MySQL data and logs
  • /opt/lampp/php/logs/ โ€” PHP logs
  • /opt/lampp/temp/ or /opt/lampp/tmp/ โ€” Temporary files
  • /opt/lampp/htdocs/ โ€” Website files (may have user/app caches, uploads, sessions)
  • Any storage/ directories for frameworks like Laravel

3. What Files Should Be Cleaned Regularly?

Below are the files and folders to clean, with what they do and how to handle them safely:


A. Apache Log Files

  • Location: /opt/lampp/logs/ and /opt/lampp/apache/logs/
  • Files:
    • access.log
    • error.log
    • Any rotated log files (e.g., error.log.1, access.log.1, .gz, etc.)
  • Why: These logs can get huge, fast.
  • How:
    • Delete old rotated/compressed logs (e.g., *.gz, .1 files)
    • Truncate main logs regularly (to avoid interrupting Apache): > /opt/lampp/logs/access.log > /opt/lampp/logs/error.log

B. PHP Error Logs

  • Location: /opt/lampp/php/logs/
  • Files:
    • php_error_log
  • Why: Captures PHP warnings/errors, can grow large.
  • How:
    • Truncate periodically: > /opt/lampp/php/logs/php_error_log

C. MySQL Log and Error Files

  • Location: /opt/lampp/var/mysql/ or /opt/lampp/mysql/data/
  • Files:
    • hostname.err (e.g., ip-172-31-34-212.err)
    • mysql-bin.* (binary logs, if enabled)
    • Slow query logs (mysql-slow.log, if enabled)
    • Old rotated logs (*.old, *.BAK, etc.)
  • Why: Large logs waste space; old binlogs arenโ€™t needed after backup/replication.
  • How:
    • Truncate the error log (never delete while MySQL is running): > /opt/lampp/var/mysql/ip-172-31-34-212.err
    • Remove old binlogs (only if not needed for recovery/replication): rm /opt/lampp/var/mysql/mysql-bin.00000*
    NEVER delete ibdata1, ib_logfile*, aria_log*, or any database folders/files here.

D. Temporary Files

  • Location: /opt/lampp/temp/, /opt/lampp/tmp/, and project storage/framework/cache, storage/framework/sessions, etc.
  • Files:
    • Upload temp files, session files, cache
  • Why: Safe to delete files not recently accessed (stale session, cache, failed uploads).
  • How:
    • Example to remove files older than 2 days: find /opt/lampp/temp/ -type f -mtime +2 -delete find /opt/lampp/tmp/ -type f -mtime +2 -delete

E. Application/Framework Cache & Session Files

  • Laravel example:
    /opt/lampp/htdocs/your_project/storage/framework/sessions/
    /opt/lampp/htdocs/your_project/storage/framework/cache/
    /opt/lampp/htdocs/your_project/storage/framework/views/
  • Why: Sessions, cache, and compiled views are safe to clear out if old.
  • How: find /opt/lampp/htdocs/your_project/storage/framework/sessions/ -type f -mtime +1 -delete find /opt/lampp/htdocs/your_project/storage/framework/cache/ -type f -mtime +1 -delete find /opt/lampp/htdocs/your_project/storage/framework/views/ -type f -mtime +1 -delete

F. Old Backup Files

  • Location: Wherever you store old .sql, .tar, .gz, etc. (often /backups/ or /opt/lampp/htdocs/backups/)
  • Why: Donโ€™t keep too many old backups.
  • How: find /opt/lampp/htdocs/backups/ -type f -mtime +7 -delete (Deletes backup files older than 7 days.)

4. What Should You NEVER Delete?

  • Database data files (ibdata1, ib_logfile0, etc. in var/mysql/)
  • Anything inside database directories (unless you want to drop/delete a database)
  • Application files, user uploads, etc. (unless verified as junk)
  • XAMPP config files

5. Automating Cleanup With a Cron Job

Hereโ€™s a sample script you could run daily or weekly via cron:

#!/bin/bash

# Clean Apache logs (keep last 7 days)
find /opt/lampp/logs/ -type f -name "*.gz" -mtime +7 -delete
find /opt/lampp/apache/logs/ -type f -name "*.gz" -mtime +7 -delete

# Truncate current log files
> /opt/lampp/logs/access.log
> /opt/lampp/logs/error.log
> /opt/lampp/php/logs/php_error_log

# Truncate MySQL error log
> /opt/lampp/var/mysql/ip-172-31-34-212.err

# Clean temp files older than 2 days
find /opt/lampp/tmp/ -type f -mtime +2 -delete
find /opt/lampp/temp/ -type f -mtime +2 -delete

# Clean Laravel/Framework session & cache files older than 1 day
find /opt/lampp/htdocs/your_project/storage/framework/sessions/ -type f -mtime +1 -delete
find /opt/lampp/htdocs/your_project/storage/framework/cache/ -type f -mtime +1 -delete
find /opt/lampp/htdocs/your_project/storage/framework/views/ -type f -mtime +1 -delete

# Clean old backup files (older than 7 days)
find /opt/lampp/htdocs/backups/ -type f -mtime +7 -delete
Code language: PHP (php)
  • Save this as cleanup_xampp.sh
  • Make it executable:
    chmod +x cleanup_xampp.sh
  • Add to crontab for daily execution (example at 2:30am): 30 2 * * * /path/to/cleanup_xampp.sh

6. Monitoring Disk Usage

  • Regularly check usage: du -sh /opt/lampp/*
  • Be proactive; if logs grow rapidly, increase cleanup frequency or log rotation.

7. Security and Best Practices

  • Always review before deletingโ€”automate with care.
  • Take regular full backups before aggressive cleaning, especially before touching anything in var/mysql/.
  • Set up logrotate for Apache, PHP, and MySQL logs for better management.
  • Document your cleanup routines for the team.

Summary Table

LocationWhat to CleanCommand ExampleNotes
/opt/lampp/logs/Apache logs> access.logRotate/truncate; donโ€™t delete active logs
/opt/lampp/php/logs/PHP logs> php_error_log
/opt/lampp/var/mysql/MySQL error logs> hostname.errNever delete core DB files
/opt/lampp/tmp/ /opt/lampp/temp/Temp filesfind ... -mtime +2 -deleteOnly old files
/opt/lampp/htdocs/project/storage/Sessions, cachefind ... -mtime +1 -deleteFramework-specific
/opt/lampp/htdocs/backups/Old backupsfind ... -mtime +7 -deleteOptional

Conclusion

Regular cleanup of log, temp, and cache files under /opt/lampp keeps your production XAMPP environment healthy, secure, and reliable.
Never delete database or config files, always backup before cleaning, and automate your routines for peace of mind!


Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals
Iโ€™m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I have worked at <a href="https://www.cotocus.com/">Cotocus</a>. I share tech blog at <a href="https://www.devopsschool.com/">DevOps School</a>, travel stories at <a href="https://www.holidaylandmark.com/">Holiday Landmark</a>, stock market tips at <a href="https://www.stocksmantra.in/">Stocks Mantra</a>, health and fitness guidance at <a href="https://www.mymedicplus.com/">My Medic Plus</a>, product reviews at <a href="https://www.truereviewnow.com/">TrueReviewNow</a> , and SEO strategies at <a href="https://www.wizbrand.com/">Wizbrand.</a> Do you want to learn <a href="https://www.quantumuting.com/">Quantum Computing</a>? <strong>Please find my social handles as below;</strong> <a href="https://www.rajeshkumar.xyz/">Rajesh Kumar Personal Website</a> <a href="https://www.youtube.com/TheDevOpsSchool">Rajesh Kumar at YOUTUBE</a> <a href="https://www.instagram.com/rajeshkumarin">Rajesh Kumar at INSTAGRAM</a> <a href="https://x.com/RajeshKumarIn">Rajesh Kumar at X</a> <a href="https://www.facebook.com/RajeshKumarLog">Rajesh Kumar at FACEBOOK</a> <a href="https://www.linkedin.com/in/rajeshkumarin/">Rajesh Kumar at LINKEDIN</a> <a href="https://www.wizbrand.com/rajeshkumar">Rajesh Kumar at WIZBRAND</a> <a href="https://www.rajeshkumar.xyz/dailylogs">Rajesh Kumar DailyLogs</a>

Related Posts

Terraform Backend Tutorial

Terraform is a popular open-source infrastructure as code tool used to create and manage infrastructure resources. The state of the infrastructure resources managed by Terraform is stored…

Read More

Best Tools for Software Composition Analysis (SCA)

Hereโ€™s a clear and professional explanation of the three related concepts you asked about โ€” all of which are critical parts of secure software development, especially in…

Read More

Top 10 AI Code Review Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, AI code review tools have become essential for developers aiming to enhance code quality, streamline workflows, and accelerate software delivery. These tools leverage advanced…

Read More

Top 10 Expense Management Tools in 2026: Features, Pros, Cons & Comparison

Introduction Expense management tools are critical for businesses of all sizes in 2026 as they help streamline financial processes, improve budgeting, ensure compliance, and enhance financial visibility….

Read More

Top 10 Web Application Firewall (WAF) Tools in 2026: Features, Pros, Cons & Comparison

Introduction In the rapidly evolving landscape of cybersecurity, Web Application Firewalls (WAFs) have become a critical component in defending web applications from malicious attacks such as SQL…

Read More

Top 10 Endpoint Management Tools in 2026: Features, Pros, Cons & Comparison

Introduction In 2026, businesses of all sizes are increasingly reliant on a variety of devicesโ€”laptops, desktops, mobile devices, and other endpointsโ€”that connect to their networks. With the…

Read More
Subscribe
Notify of
guest
1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Jason Mitchell
Jason Mitchell
1 month ago

Very helpful guide! The explanation of which XAMPP/LAMPP files and logs should be cleaned in a production environment is clear and practical. Itโ€™s a useful reference for developers and admins who want to keep their server organized and running smoothly.

1
0
Would love your thoughts, please comment.x
()
x