Jump to content

Archived

This topic is now archived and is closed to further replies.

Benan

Apache Installation help!

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.

Share this post


Link to post
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?

Share this post


Link to post
Share on other sites
No I havn't configured it, I dont know how to can you help me? and I tried that script same prob

Share this post


Link to post
Share on other sites
Okay. Could you post the steps you did you to configure Apache here. Also what OS are you using? Windows, Linux, or Mac?

Share this post


Link to post
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..

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites
Do you have to do anything special to install SQL? like I did with PHP?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites
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??

Share this post


Link to post
Share on other sites
I see youre using apache2.2.x. PHP is not compatible with this version of Apache. See if downgrading Apache to Apache2.0.x solves this.

If you want to use Apache2.2.x you'll want to download the third party php5Apache2.dll file from apachelounge.com

Share this post


Link to post
Share on other sites
ok  after downloading the apache 2.0 i have to remove the current vesion right but after unstalling the apachee 2.2 the files are remaining in the programmfiles

Share this post


Link to post
Share on other sites
i have to download this vesion right  "Win32 Binary (MSI Installer): apache_2.0.59-win32-x86-no_ssl.msi [PGP] [MD5]"

Share this post


Link to post
Share on other sites
Yes download the binaries.

NOTE: Before installing Apache remove the files left over from uninstalling Apache2.2.x.

Share this post


Link to post
Share on other sites
the apache is working fine now  thank you

and i have test the php like http://localhost/Examples/hello.php
and create the files in C:\Examples\hello.php  its not working

error msg  "The page cannot be found"

Share this post


Link to post
Share on other sites

×

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.