I downloaded the php. MySQL and the apache but, I am facing a problem in which the code is being displayed and not the web page. There must be a configuration problem.
Any help would be much appreciated.

Dani AI

Generated

If PHP source is shown in the browser instead of rendered HTML, the web server isn’t handing .php requests to the PHP interpreter. Common culprits are: opening the file with a file:// URL instead of http://, the file not being inside Apache’s document root, the file having a wrong extension (like .php.txt), Apache not configured to process .php, or use of PHP short tags. This echoes points raised by (OS/setup differences) and (handler/extension issue), while ’s suggestion of a packaged stack can be useful when manual config proves painful.

Quick, practical checklist to isolate the problem:

  • Ensure the file lives in Apache’s document root and is requested with an URL (not file://).
  • Confirm the filename ends with .php.
  • Create a minimal test file named info.php containing:
<?php
phpinfo();
?>

Request . A rendered PHP info page means PHP is working; raw source means Apache isn’t processing PHP.

Configuration and diagnostic tips:

  • Verify Apache loads a PHP handler/module. On many systems run apachectl -M or httpd -M and look for php-related modules. Check httpd.conf or the conf.d files for a LoadModule line and an AddHandler/AddType or SetHandler that maps .php to PHP. If using PHP-FPM, confirm mod_proxy_fcgi and the proxy settings are present.
  • Check logs (Apache error log) for module-load or startup errors and restart Apache after any config change.
  • If PHP code uses <? short tags and short_open_tag is disabled, the code will be output verbatim — use full <?php tags or enable the short tag option in php.ini.

Following these steps will quickly show whether the issue is file placement/URL, a simple extension/tag mistake, or an Apache/PHP configuration problem.

Recommended Answers

All 5 Replies

What did you do? Did you follow some sort of guide?

What OS are you using? setup differs on linux, windoze and so on. Look up "installing LAMP on <your OS>" in google and you should find complete instructions. I have to say that trying to do it on windoze is a bit of a nightmare as i recall

Assuming that PHP and Apache are working correctly (and they may not be) then this is likely caused by trying to run PHP code from a module that doesn't have a .php suffix. For this reason or because of your setup, the module isn't being processed as a php module.

If you are using windows, it may be worth installing a virtual machine to run your lamp installation in. I remember trying to get it to work in windows a few years ago when I was still using it, and as I recall, I had similar problems, and never did work out how to fix them.

Hi,

why don't you use Xampp server it has inbuilt php and mysql database.
you don't need to configure php and mysql database in it.

you can download it free from here :

Gajendra

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.