Once php has been installed on apache server, why I cannot run php program on it, any idea?

Dani AI

Generated

Thread summary: reported PHP scripts not executing after installation. pointed out that the server must have PHP support enabled, noted that Apache configuration can be distro-specific, and asked about versions. The following is a concise diagnostic checklist and common fixes that are still useful years later.

Start with a few quick checks: confirm the PHP runtime is installed with php -v. Inspect Apache's loaded modules with apachectl -M (or httpd -M) to see whether PHP integration is present (mod_php, proxy_fcgi, etc.). Drop a simple probe into the web root named phpinfo.php to verify parsing:

<?php
phpinfo();
?>

Request that file over HTTP (not file://) and watch whether a formatted page appears. Restart the web server or the PHP service after configuration changes (systemd or init commands depend on the distro).

Common failure modes and how to diagnose them: when the browser downloads the source or shows raw PHP, Apache is not handing .php to a PHP handler; check vhost/conf for a handler or proxy configuration. Blank pages usually mean a fatal PHP error—check the Apache error log and PHP-FPM or PHP error logs. Permission issues, wrong document root, or SELinux file contexts can silently block execution. Using short tags (<?) can fail if short_open_tag is disabled; always test with <?php.

Compatibility and distro notes: modern setups use PHP-FPM + proxy_fcgi; older setups use mod_php. Package names and enabling commands differ by distribution (Debian/Ubuntu helpers versus RHEL/Fedora packages). Helpful diagnostics to include when troubleshooting further are the outputs of php -v, apachectl -v, apachectl -M, and the leading lines of the Apache error log.

Recommended Answers

All 3 Replies

the server must support php, then you can use it

You need to add support to apache as stated something like this if you have apache2;
APACHE2_OPTS="-D PHP4"
On my distro (Gentoo) its in /etc/conf.d/apache2/apache2.conf
Each distro may be a little different like /etc/apache2/httpd.conf

what versions of apache and php do you have?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.