Linux服务器XAMPP启动失败求助:Apache、MySQL无法运行
Let's get your XAMPP stack fully up and running—here's a step-by-step breakdown based on the errors you've shared:
Step 1: Fix the Apache Conflict
The first error clearly states "Another web server is already running"—that’s why Apache fails to start. Let’s track down and stop that conflicting service:
- First, identify which process is using Apache’s default ports (80 for HTTP, 443 for HTTPS) with this command:
Ifsudo netstat -tulpn | grep -E ":80|:443"netstatisn’t installed on your system, uselsofinstead:sudo lsof -i :80 && sudo lsof -i :443 - Look for the
PID(process ID) of the conflicting service—it could benginx, a separate Apache instance, or even a Node.js dev server. - Kill the process directly with:
If it’s a system-managed service (like nginx), stop it cleanly instead:sudo kill -9 <PID>sudo systemctl stop nginx sudo systemctl disable nginx # Optional: Prevents it from auto-starting on boot
Step 2: Resolve MySQL’s Unexpected Shutdown
Your second status check shows MySQL isn’t running, even though it started successfully initially. This usually happens due to leftover process files or permission issues:
- First, stop all running XAMPP services to reset the state:
sudo /opt/lampp/lampp stop - Navigate to XAMPP’s MySQL directory and delete the PID file (this file incorrectly signals that MySQL is still running):
cd /opt/lampp/var/mysql sudo rm localhost.pid # The filename might match your server's hostname, e.g., your-server-name.pid - Ensure MySQL has proper permissions for its data files:
sudo chown -R mysql:mysql /opt/lampp/var/mysql
Step 3: Restart XAMPP and Verify Status
Now start the full XAMPP stack again:
sudo /opt/lampp/lampp start
Check the status to confirm all services are running:
sudo /opt/lampp/lampp status
You should see "Apache is running", "MySQL is running", and "ProFTPD is running" (if you don’t need ProFTPD, you can stop it separately with sudo /opt/lampp/lampp stop proftpd).
If Issues Persist
- Dig into Apache’s error log for specific details:
cat /opt/lampp/logs/error_log - Check MySQL’s error log if it still won’t start:
cat /opt/lampp/logs/mysql_error_log
These logs will give you targeted error messages to troubleshoot further.
内容的提问来源于stack exchange,提问作者Irtaza Waris

