Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk10 min

How to Fix Apache Not Restarting After Installing PHP

A command-led guide to diagnosing Apache restart failures after PHP installation, including configtest, stale module cleanup, Ubuntu/Debian module setup, RHEL 9 PHP-FPM, port collisions and safe verification.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When Apache will not restart after a PHP installation or update, do not keep retrying systemctl restart. First run Apache’s configuration test, read the exact file and line it reports, then correct the PHP integration for your distribution. On Ubuntu and Debian that commonly means the libapache2-mod-php module; on RHEL 9, PHP runs through PHP-FPM instead of the removed mod_php module. If the configuration passes, move on to logs, port ownership, permissions, dependencies and handler mapping.

Use this recovery sequence first

The following order isolates configuration errors before you change service state again. Substitute the service name used by your distribution: Debian and Ubuntu call it apache2; RHEL and Fedora call it httpd.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

1. Record the complete failure

Capture the status output with the full, untruncated journal text:

sudo systemctl status apache2 --no-pager -l
sudo journalctl -u apache2 -b --no-pager

On RHEL-family systems use:

sudo systemctl status httpd --no-pager -l
sudo journalctl -u httpd -b --no-pager

The first fatal message is more useful than the final “control process exited with error code” summary. Keep the exact service name and the first reported file, line number or socket path; later steps depend on them.

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.

2. Run an explicit configuration test

Apache’s documentation describes configtest as a configuration-file syntax test. A restart performs this check internally, but running it separately exposes the error without attempting another service transition.

sudo apache2ctl configtest

For RHEL, Fedora and source installs:

sudo apachectl configtest

A healthy configuration returns exactly Syntax OK. If a filename and line number are printed, fix that location before restarting. Do not treat a generic systemd failure as the root cause when Apache has already identified a more precise one.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

3. Correct the named PHP or Apache setting

Open the file reported by the test and inspect the surrounding directives. Common post-install blockers include a versioned LoadModule pointing to a file that no longer exists, an unrecognised PHP directive, the same PHP module loaded twice, or a module binary built for an incompatible Apache/PHP application binary interface (ABI). Remove or update the stale entry, then rerun configtest until it says Syntax OK.

4. Inspect what is enabled

On Debian and Ubuntu, list the loaded modules and PHP enablement files:

sudo apache2ctl -M
ls -l /etc/apache2/mods-enabled/php*.load /etc/apache2/mods-enabled/php*.conf

On RHEL, inspect the Apache and PHP-FPM configuration trees:

sudo ls -l /etc/httpd/conf.d/
sudo ls -l /etc/httpd/conf.modules.d/
sudo ls -l /etc/php-fpm.d/

Compare those files with the packages installed by your distribution. A manually copied module or an old versioned symlink can survive a package upgrade and make Apache load an object that is no longer present.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

5. Restart only after the test passes

sudo systemctl restart apache2.service

For RHEL 9:

sudo systemctl restart httpd
sudo systemctl start php-fpm

If PHP-FPM is already running, start reports that it is active; if it fails, troubleshoot that service before retrying httpd. Enable services at boot only after both start successfully:

Rank #2
Sale
Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
  • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
  • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
  • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
  • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
  • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.
sudo systemctl enable httpd php-fpm

6. If syntax is valid but startup still fails, read runtime errors

When configtest returns Syntax OK, inspect the current boot’s journal and Apache’s ErrorLog. Look for the first fatal line, not a cascade of follow-on messages:

sudo journalctl -u apache2 -b --no-pager
sudo journalctl -u httpd -b --no-pager

Apache’s startup guidance notes that fatal startup errors are sent to the console or ErrorLog. A message such as Unable to bind to Port ... usually means another process already owns the listener or Apache lacks the required privilege.

7. Verify PHP over HTTP and remove diagnostics

Once the service is running, create a temporary file in the Apache DocumentRoot, for example:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo sh -c 'printf "%sn" "<?php phpinfo(); ?>" > /var/www/html/phpinfo.php'

Request http://127.0.0.1/phpinfo.php locally (or use the site’s normal hostname), confirm the expected PHP version and SAPI, and then delete the file:

sudo rm /var/www/html/phpinfo.php

A public phpinfo() page reveals paths, loaded modules and environment details, so leaving it online is an avoidable information disclosure.

Why Ubuntu/Debian and RHEL require different fixes

The installation method determines which Apache integration should exist. Treating an RHEL 9 host like an Ubuntu host, or copying an Ubuntu LoadModule line into RHEL, commonly creates the failure.

Area Ubuntu/Debian RHEL 9 and related RHEL-family systems
Typical PHP integration libapache2-mod-php loaded as an Apache module PHP-FPM through FastCGI by default
Web service name apache2 httpd
Additional PHP service Not normally required for the module-based setup php-fpm must start successfully
Apache module/configuration area /etc/apache2/mods-enabled/ /etc/httpd/conf.d/ and /etc/httpd/conf.modules.d/
PHP-FPM configuration Used only when you deliberately choose FPM /etc/php-fpm.conf and /etc/php-fpm.d/www.conf

Canonical’s Ubuntu Server guidance installs PHP with libapache2-mod-php, checks for matching php8.*.load and php8.*.conf files under /etc/apache2/mods-enabled, then restarts apache2.service. The exact PHP minor version in those filenames depends on the packages available for your Ubuntu release; do not hard-code an old version into a new installation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by

Red Hat documents that RHEL 9’s Apache runs PHP through FastCGI Process Manager by default and that the mod_php module supplied for Apache has been removed. On that platform, a copied LoadModule php_module ... line is not a valid way to restore PHP; configure the FPM service and the Apache-to-FPM proxy mapping instead.

Match the error message to the repair

Failure signature What it usually means Next action
Syntax error on line ... An Apache or PHP directive is invalid at the named location. Open that file and line, correct or remove the directive, then rerun configtest.
Cannot load ... libphp*.so A stale, missing or mismatched PHP module is referenced. Install the distribution’s matching integration package and disable stale versioned enablement or manual copies.
Module php... already loaded The module is declared in more than one configuration file. Keep one package-managed load statement and disable the duplicate.
Unable to bind to Port ... Another process owns the listener, or Apache lacks permission to bind it. Find the listener with ss -ltnp; stop or reconfigure the conflicting service and retry.
php-fpm.service failed FPM has a configuration, socket, permission or dependency problem. Read the FPM status and journal, fix the first reported error, then restart httpd.
Restart succeeds but PHP downloads or displays source No PHP handler or FPM mapping is active for that virtual host. Confirm the intended module or FastCGI proxy configuration and test with phpinfo().

Ubuntu and Debian: repair the module-based setup

Confirm the package and module files

For the standard Apache module arrangement, install the distribution packages rather than downloading a shared object manually:

sudo apt update
sudo apt install php libapache2-mod-php

After installation, check that the enabled directory contains a matching pair of PHP load and configuration files:

ls -l /etc/apache2/mods-enabled/php*.load
ls -l /etc/apache2/mods-enabled/php*.conf

If the listing shows an old minor version while the installed package supplies another, disable the obsolete enablement and enable the package’s current module using your distribution’s helper. The exact helper name and version depend on the release, so use the module names actually present under /etc/apache2/mods-available/ rather than guessing.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Remove duplicate or hand-copied declarations

Search Apache’s configuration for every PHP load directive:

sudo grep -RniE 'LoadModule.*php|php_module|libphp' /etc/apache2

There should be one authoritative module load for the chosen package. If the same library appears in a custom file and a package-managed file, remove the custom duplicate or disable that site-specific include. Do not delete files blindly; first identify which package owns them and whether a virtual host depends on them.

Test, restart and check the active module list

sudo apache2ctl configtest
sudo systemctl restart apache2.service
sudo apache2ctl -M | grep -i php

If the final command shows no PHP module, Apache may be running while PHP files remain unhandled. Recheck the enabled module symlinks and the virtual host that serves the request.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

RHEL 9: repair the PHP-FPM path

Check all three relevant services and configuration trees

RHEL 9 separates the web server from the PHP runtime. Inspect:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo systemctl status httpd --no-pager -l
sudo systemctl status php-fpm --no-pager -l
sudo journalctl -u php-fpm -b --no-pager
sudo ls -l /etc/httpd/conf/httpd.conf /etc/httpd/conf.d/
sudo ls -l /etc/php-fpm.conf /etc/php-fpm.d/www.conf

The first FPM error may identify an invalid pool directive, an unavailable Unix socket, a directory permission problem or a dependency that did not start. Fix that error in the named file, then run:

sudo systemctl restart php-fpm
sudo apachectl configtest
sudo systemctl restart httpd

Do not reintroduce removed mod_php configuration

Search for copied module directives:

sudo grep -RniE 'LoadModule.*php|libphp|mod_php' /etc/httpd

On RHEL 9, remove or disable obsolete mod_php references and retain the FastCGI configuration supplied for your PHP packages. Apache should proxy PHP requests to the FPM pool, commonly through the socket or address declared in the pool and virtual-host configuration. The socket path in your files is authoritative; do not substitute a path from another release.

Confirm the FPM pool’s ownership and socket

If the journal reports that Apache cannot connect to the FPM socket, compare the socket path in /etc/php-fpm.d/www.conf with the path in the Apache proxy configuration. Check that the socket exists after FPM starts and that its owner, group and mode allow the Apache worker to connect. Correct the pool settings, restart FPM, and only then restart httpd.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When configuration syntax passes but Apache still will not start

Find a port collision

For a bind failure, list listening TCP sockets and the owning process:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo ss -ltnp

Compare the process and port with Apache’s Listen directives and the virtual-host files. A second web server, an old Apache instance or a container can own port 80 or 443. Stop the unintended service or change one listener and its firewall or proxy arrangement consistently. A privilege error can also occur when a non-root process attempts to bind a low-numbered port; use the distribution’s service unit rather than launching Apache manually as an unprivileged user.

Read ErrorLog and journal entries together

The systemd journal shows why the unit exited; Apache’s ErrorLog often adds the module name, virtual host or filesystem path. Check the ErrorLog location declared by your active configuration and read the newest entries immediately after a failed start. Fix the earliest fatal entry first, because later “shutdown” messages are consequences rather than separate causes.

Check permissions and dependencies

A PHP upgrade can expose ownership or access problems in a document root, log directory, runtime directory or FPM socket. Verify that Apache can traverse the document root and write its configured logs, and that FPM can read its pool configuration and create its socket. On systems using mandatory access controls, an access-denied entry in the audit or service log points to a policy issue rather than an Apache syntax error; correct the policy or file labeling according to your distribution’s administration procedure instead of broadly disabling protection.

Prove that PHP requests are handled correctly

Use a temporary local diagnostic

Create phpinfo.php in the actual DocumentRoot for the virtual host you are testing. Its contents should be only:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<?php phpinfo(); ?>

Request it locally and check:

  • The PHP version is the version you intended to install.
  • The “Server API” or SAPI matches your design: an Apache module on the Debian/Ubuntu module path, or FPM/FastCGI on RHEL 9.
  • The loaded configuration file and additional scan directory are the ones you expect.
  • Extensions required by the application appear as loaded.

If the page downloads instead of executing, Apache is serving the file as static content because no PHP handler is attached to that virtual host. If it displays the PHP source, treat that as an urgent configuration and information-disclosure problem: stop exposing the file, remove it, and configure the proper module or FPM mapping before serving application code again.

Delete the file after verification

sudo rm /var/www/html/phpinfo.php

Use the real path for your site if its DocumentRoot differs. Confirm with a second request that the diagnostic URL no longer exists.

Prevent the next PHP upgrade from breaking Apache

  • Use the packages and integration method supplied for the operating system instead of copying libphp binaries between hosts.
  • Before upgrades, save the active Apache and PHP configuration and note enabled modules, virtual hosts, FPM pools and socket paths.
  • After every PHP package change, run apache2ctl configtest or apachectl configtest before restarting the web service.
  • Keep one package-managed module declaration; remove obsolete versioned symlinks and hand-written duplicates.
  • On RHEL 9, treat httpd and php-fpm as separate services and test both after changes.
  • Keep a private, local-only verification procedure rather than leaving phpinfo() online.
  • Record the first fatal journal message and the exact configuration file that fixed it; that short incident note makes the next rollback or upgrade safer.

Decision checklist

  1. Identify whether the host uses apache2 or httpd.
  2. Capture status and the current-boot journal for that service.
  3. Run the matching configtest command.
  4. If a file and line are named, repair that directive, stale module, missing library or duplicate and retest.
  5. Inspect enabled modules on Debian/Ubuntu, or Apache and FPM configuration on RHEL.
  6. Restart the correct service only after Syntax OK; start or restart php-fpm on RHEL 9.
  7. If startup still fails, inspect ErrorLog and journal output, then check port ownership with ss -ltnp, permissions and dependencies.
  8. Verify a real HTTP request with a temporary phpinfo() page and remove it immediately.

Frequently Asked Questions

Why does Apache restart fail immediately after a PHP version update?

The update can leave a versioned PHP module reference, missing shared object, duplicate load directive or unsupported PHP directive in Apache’s configuration. Run the distribution-appropriate configtest; its filename and line number identify which entry must be corrected.

Can I fix RHEL 9 by enabling mod_php?

No. Red Hat states that mod_php was removed for RHEL 9. Configure PHP-FPM and Apache’s FastCGI mapping, then verify both php-fpm and httpd.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What should I do if configtest says Syntax OK but PHP files download?

Apache is running, but the virtual host has no active PHP handler. Check the enabled Debian/Ubuntu module or the RHEL FastCGI proxy and confirm the result with a temporary local phpinfo() request.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.