|
| 1 | +# Apache Won't Start After Switching |
| 2 | + |
| 3 | +## Problem |
| 4 | + |
| 5 | +Apache service fails to start after switching PHP versions. |
| 6 | + |
| 7 | +## Cause |
| 8 | + |
| 9 | +Apache processes may still be running in the background, or there might be configuration issues with the new PHP version. |
| 10 | + |
| 11 | +## Solutions |
| 12 | + |
| 13 | +### Step 1: Check for Running Apache Processes |
| 14 | + |
| 15 | +```powershell |
| 16 | +Get-Process -Name httpd -ErrorAction SilentlyContinue |
| 17 | +``` |
| 18 | + |
| 19 | +### Step 2: Kill Any Remaining Apache Processes |
| 20 | + |
| 21 | +```powershell |
| 22 | +Get-Process -Name httpd | Stop-Process -Force |
| 23 | +``` |
| 24 | + |
| 25 | +### Step 3: Try Switching Again |
| 26 | + |
| 27 | +```powershell |
| 28 | +phat switch [version] |
| 29 | +``` |
| 30 | + |
| 31 | +## Additional Troubleshooting |
| 32 | + |
| 33 | +### Check Apache Error Logs |
| 34 | + |
| 35 | +Look for detailed error messages in: |
| 36 | + |
| 37 | +``` |
| 38 | +C:\xampp\apache\logs\error.log |
| 39 | +``` |
| 40 | + |
| 41 | +### Verify PHP DLL Files |
| 42 | + |
| 43 | +Ensure the correct PHP DLL files exist in the PHP directory: |
| 44 | +- For PHP 7.x: `php7ts.dll` and `php7apache2_4.dll` |
| 45 | +- For PHP 8.x: `php8ts.dll` and `php8apache2_4.dll` |
| 46 | + |
| 47 | +### Verify Apache Configuration |
| 48 | + |
| 49 | +Check that `httpd-xampp.conf` has the correct PHP module configuration: |
| 50 | + |
| 51 | +``` |
| 52 | +C:\xampp\apache\conf\extra\httpd-xampp.conf |
| 53 | +``` |
| 54 | + |
| 55 | +Look for lines like: |
| 56 | +```apache |
| 57 | +LoadFile "C:/xampp/php/php8ts.dll" |
| 58 | +LoadModule php_module "C:/xampp/php/php8apache2_4.dll" |
| 59 | +``` |
| 60 | + |
| 61 | +## Manual Apache Control |
| 62 | + |
| 63 | +If automatic switching fails, you can manually control Apache: |
| 64 | + |
| 65 | +**Stop Apache:** |
| 66 | +```powershell |
| 67 | +C:\xampp\apache_stop.bat |
| 68 | +``` |
| 69 | + |
| 70 | +**Start Apache:** |
| 71 | +```powershell |
| 72 | +C:\xampp\apache_start.bat |
| 73 | +``` |
| 74 | + |
| 75 | +## Related Resources |
| 76 | + |
| 77 | +- [XAMPP Documentation](https://www.apachefriends.org/docs/) |
| 78 | +- [Back to Troubleshooting Index](TROUBLESHOOTING.md) |
0 commit comments