Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have installed apache 2.2 and php 5.3. when I run a simple php code like <?php phpinfo();?> instead of the simple php information page the code shows up on the screen. My php it seems is not running. How I can enable it and makes it to run with apache. btw. I am newbee

thanks

share|improve this question

migrated from stackoverflow.com May 17 '10 at 18:08

This question came from our site for professional and enthusiast programmers.

    
"simple php code like ()" .... –  Moak May 17 '10 at 17:09
1  
This means that apache does not pass the PHP page to the PHP interpreter. Check if you activated the module in your httpd.conf. Please ask this questions on SuperUser or on ServerFault. Here you get answers on programming questions. –  Simon May 17 '10 at 17:12
add comment

4 Answers

Quick google search will show tons of options concerning configuration and installation. Give this one a go: http://php.net/manual/en/install.php

The easiest way to test you PHP installation is to run a php_info() function. See details and examples here: http://php.net/manual/en/function.phpinfo.php

share|improve this answer
add comment

depends on your linux distribution. they all have different ways to enable php module.

share|improve this answer
add comment

One way to test whether PHP is functioning, is to create a page like this:

<?php
    phpinfo();
?>

You should see a page generated by php with its configuration and settings. If you see the code itself, then Apache is not parsing the PHP and instead just passing it on as a regular text file. Definitely not what you want.

To configure Apache to parse PHP correctly, you need to make sure it is loading the PHP library, and that it is set to serve up *.php files using that library; and finally ensure that you have set up your index pages the way you want, usually so that index.php and index.html are both considered valid default files for a directory on your server.

The specifics of how to do this are explained numerous times in various Apache/PHP setup tutorials, and depending on your operating system and installation specifics, you will need to consult the tutorial or documentation specific to your case. Also you might want to try asking or searching on serverfault.com because the installation and setup of these programs are more suited to that wiki than stackoverflow.com. Once you've got your server running and need some help with specific PHP coding questions, this is the place.

Edit: Removed a line that's not relevant because the question was edited for clarity.

share|improve this answer
    
The () was only a formatting error :D –  Simon May 17 '10 at 17:17
    
Noted and updated accordingly. –  JYelton May 17 '10 at 17:18
add comment

You missed some packages or some switches from your installation.

If you installed PHP with your distribution's package manager, search for apache2-mod-php, libapache2-mod-php, or some similar package. This package contains the missing Apache module for your PHP.

If you installed PHP from source, you missed --with-apxs2=$(which apxs2) switch.

If you tell us your distribution, we can help you to solve this problem.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.