Jump to content

Apache Installation help!


Benan

Recommended Posts

Hi,

I installed Apache, used localhost for my domain name serrver and website, installed it etc.. then went to http://localhost in my browser and it said "it works" so I made a folder called "examples" in the htdocs directory, saved my script to it with is a basic script

[code]<?
echo "hello";
?>[/code]

and I saved it to exmaples folder as hello.php and when i went to http://localhost/Examples/hello.php it didnt come up as hello it come up as the code, i think this might be a problem with the apache installation i made because the code is pefectly fine from what I can see.
Link to comment
Share on other sites

Use full php tags not short php tags:
[code=php:0]<?php
echo "hello";
?>[/code]

Dont used <? use <?php instead.

If it still doesnt parse your php script then Apahe isnt configured to send any php files that are requested to the php intepreter. How have your configured Apache?
Link to comment
Share on other sites

Umm, Im using Windows..

Configure? I havnt tried configuring, i installed it and trie to use it..

but the steps i did to install
pretty much click next, until i had to enter some info.. which was: domain server name: localhost, domainname:localhost, email:Benan7@hotmail.com then next installed..
Link to comment
Share on other sites

So you have just installed Apache. you havn't downloaded and installed PHP? If you havnt downloaded PHP yet, download the following package:
[url=http://www.php.net/get/php-5.1.6-Win32.zip/from/a/mirror]PHP 5.1.6 zip package[/url]

Download that package to your My Documents area.

Once downloaded, extract the contents of zip to C:\php (XP and 2000 should have an Extraction Wizard built in when you Right click and select Extract All)

Once you have extracted PHP. We'll add the PHP folder to the Windows PATH variable. To do this make sure you're logged in as the adminstrator account. Now go to Start > Control Panel > System > Advanced Tab > Evironment Variables button > Evnvironment Variables Box

Scroll to the Path variable. Left click the Path variable row and click the edit button. Now press the End key on your keyboard type in the following exactly: [b];C:\php;[/b] Click Ok on the three open dialog boxes to close them

Now to configure Apache. Make sure you have downloaded and installed Apache2.0.x. If you have Apache2.2.x then you may need to download a third party dll file.

Okay find and edit the httpd.conf file. You can access this file easily by going to Start > Program files > Apache HTTP Server (your version here) > Configure Apache Server > Edit the Apache httpd.conf Configuration File

The httpd.conf file opens up for editing in Notepad/Wordpad

Now scroll down and find the following:
[code]#LoadModule ssl_module modules/mod_ssl.so[/code]

Add the following on a new line after it:
[code]#PHP 5
LoadModule php5_module "C:/php/php5apache2.dll"

#PHPIniDir
PHPIniDir "C:/php"[/code]

Now scroll down and find the following:
[code]DirectoryIndex index.html index.html.var[/code]
Add (space)index.php after index.html.var so the DirectoryIndex line is like this:
[code]DirectoryIndex index.html index.html.var index.php[/code]

Again scroll down and find the following:
[code]AddType application/x-gzip .gz .tgz[/code]
Add the following on a new line after the line above:
[code]#PHP5
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-phps .phps[/code]

You have successfully configured Apache to parse PHP files with the PHP intepreter! Save the httpd.conf (Ctrl+S) Close the editor. Now go to C:\php and find the php.ini-recommended file. Rename this file to php.ini

Everything is done. All you need to do now is restart your computer in order for the Path variable to com available. When you restart your computer.  You should get no errors/beeps fingers crossed. If you get no beeps/errors when Apache startup. Open up your browser and go to http://localhost/Examples/hello.php

Is the php script now being parsed?
Link to comment
Share on other sites

Glad its all working.

Npte if you wish to work with a mySQL database. You'll need to enable the mysql extension. Which you can learn to do [url=http://www.phpfreaks.com/forums/index.php/topic,95378.0.html]in this FAQ[/url].

If you get any problems please post back.
Link to comment
Share on other sites

Which ever version of SQL you want to use MySQL, MSSQL, PostrgreSQL etc yuou'll need to download and install them from thier develoipers web site.

Then for PHP to be able to communicate to the SQL Server you install you'll need to enable the extension in the php.ini
Link to comment
Share on other sites

  • 2 weeks later...
i got same problem before and i configure the apache according to this post and its didnt work for me then what i did is unstall the apache and reinstall it, now the problem is when i start the apache service its giving the following error  "windows could not start the apache2.2 on local computer "  how can i solve this problem and run my php script  and iam using iis also when i starting the window i stop the iis service and start the apache is that the problem iam getting??
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.