2

Im a newbie to PHP and trying to run this code in apache webserver but for some reason its not running.

The file is saved under htdocs info.php. WHen I run there is no action at all..Infacts it opens the download window.

ANy help is appreciated

php code:

<?php
    date_default_timezone_set('America/Los_Angeles');
    echo date("F j, Y, g:i:s a");
?>  
8
  • 6
    It sounds like Apache is not configured to properly parse PHP files. Commented May 4, 2012 at 18:47
  • nickb is right. What OS are you using? Commented May 4, 2012 at 18:48
  • For windows, php.net/manual/en/install.windows.apache2.php or use Wamp or good tutarial for linux and windows: blazonry.com/scripting/install_apache.php Commented May 4, 2012 at 18:50
  • check whether apache is running or not Commented May 4, 2012 at 18:51
  • For instance, in Ubuntu you need to run the following command to install the PHP parser: sudo apt-get install libapache2-mod-php5 Commented May 4, 2012 at 18:53

2 Answers 2

2

I don't know what steps you took to install the web server, but did you install PHP and configured Apache to use it?

If the configuration isn't the main priority and programming in PHP is, then just download WAMP. This is a Apache webserver with PHP, PHPmyAdmin and MySQL already configured and ready to go.

Download at: http://www.wampserver.com/en/

Sign up to request clarification or add additional context in comments.

Comments

1

Although i rarely recommend using "all-in-one" XAMP packages I do make an exception when it comes to beginners.

In this case it would be much easier to simply download and use XAMPP instead of nitpicking about what might be misconfigured on the existing web server.

3 Comments

And why do you not recommend "all-in-one" packages?
They are often too specifically configured and targeted toward beginners which is why sooner or later people willing to switch from simple experimenting to some serious development will face a problem. On the other hand "all in one" packages are way less painful for absolute beginners and usually provide enough pre-configured functionality to satisfy all of their needs.
I never had any problems with the default configuration of a complete package before. It are the same configuration files that you would end up when installing it all on your own. When I need some extra configuration, then I just edit the config files until they are what I want them to be. So why go through all the time and pain to install them separately? Can you give any examples of issues that you've encountered?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.