Why is php not running?

Why is php not running?

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Why is php not running?

When you see a stack trace or a blank page in your browser, the immediate reaction is often to assume PHP itself has crashed or failed to start. However, there is a distinct difference between PHP being installed but inactive versus the application layer throwing an exception. The confusion usually stems from how web servers handle requests and how operating systems report running processes.

Consider a scenario where you have successfully installed Apache2 and PHP5 on an Ubuntu server. You run sudo apt-get install libapache2-mod-php5 and receive a message indicating the package is already up to date. This confirms the binaries exist, but it doesn't guarantee they are hooked into the web server's request lifecycle. If you navigate to your domain name or IP address and see only the default "It Works!" page provided by Amazon EC2, followed by 404 errors for any other path, you are likely facing a configuration issue rather than a process failure.

A common diagnostic step involves checking system processes with top or ps. If PHP does not appear as a running service, it often leads to panic. This is a misunderstanding of how PHP operates in a typical LAMP stack. Unlike Node.js or Python applications that maintain long-running worker processes to handle incoming requests, Apache serves PHP scripts using the mod_php module (specifically libapache2-mod-php5). In this architecture, PHP code executes synchronously within the context of the Apache child process handling the request. There is no separate "phpd" daemon running in the background waiting for work; it only activates when Apache invokes it. Therefore, seeing no PHP processes in your system monitor is expected behavior and does not indicate a broken installation.

To verify that the PHP environment is functional, you can create a test file at /var/www/html/info.php containing:

<?php phpinfo(); ?>

If this yields a 404 error, the root cause is almost certainly that Apache does not know to serve files as text. By default, Apache looks for a .htaccess or httpd.conf directive mapping specific file extensions to their handlers. If you have simply installed the packages without configuring the MIME types or enabling the PHP module in Apache, the server will treat .php files as plain text or reject them entirely depending on your directory permissions.

You must ensure that libapache2-mod-php5 is actually enabled within the Apache configuration. On Ubuntu systems using the standard package manager, this is often handled automatically, but it is worth verifying that the module is loaded in /etc/apache2/mods-enabled/. Additionally, you need to check the virtual host configuration to ensure the DocumentRoot points to the correct directory (usually /var/www/html) and that Options -Indexes is not stripping out your test files.

If you are using a PHP version older than 5.6 on Ubuntu 12.04, be aware that the underlying system libraries might be outdated, leading to compatibility issues even if Apache restarts cleanly. In modern stacks using PHP-FPM instead of mod_php, the separation of concerns is clearer: Apache passes requests to a separate FPM socket, and you would see php-fpm processes in top. But for the classic setup described, the absence of those processes is normal.

For developers looking for more robust handling of PHP applications, especially when dealing with complex routing or long-running tasks, frameworks like Laravel provide a structured way to manage these configurations. You can find further details on setting up PHP environments at https://laravelcompany.com, which offers guides on transitioning from basic server setups to production-ready architectures.

Ultimately, the 404 error for your test file suggests Apache is ignoring the request rather than PHP failing. Check your .htaccess files and ensure AddHandler application/x-httpd-php .php or the equivalent directive in apache2.conf is active. Once the MIME handler is correctly mapped, refreshing the page should reveal the phpinfo() output, confirming that your environment is ready for deployment.

Our network