Benan Posted October 2, 2006 Share Posted October 2, 2006 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. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 2, 2006 Share Posted October 2, 2006 Use full php tags not short php tags:[code=php:0]<?phpecho "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? Quote Link to comment Share on other sites More sharing options...
Benan Posted October 2, 2006 Author Share Posted October 2, 2006 No I havn't configured it, I dont know how to can you help me? and I tried that script same prob Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 2, 2006 Share Posted October 2, 2006 Okay. Could you post the steps you did you to configure Apache here. Also what OS are you using? Windows, Linux, or Mac? Quote Link to comment Share on other sites More sharing options...
Benan Posted October 2, 2006 Author Share Posted October 2, 2006 Umm, Im using Windows..Configure? I havnt tried configuring, i installed it and trie to use it..but the steps i did to installpretty 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.. Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 2, 2006 Share Posted October 2, 2006 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 BoxScroll 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 themNow 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 FileThe httpd.conf file opens up for editing in Notepad/WordpadNow 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 5LoadModule php5_module "C:/php/php5apache2.dll"#PHPIniDirPHPIniDir "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]#PHP5AddType application/x-httpd-php .php .phtmlAddType 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.iniEverything 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.phpIs the php script now being parsed? Quote Link to comment Share on other sites More sharing options...
Benan Posted October 2, 2006 Author Share Posted October 2, 2006 It worked! No error so far! thankyou very much Wildteen! Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 2, 2006 Share Posted October 2, 2006 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. Quote Link to comment Share on other sites More sharing options...
Benan Posted October 2, 2006 Author Share Posted October 2, 2006 Do you have to do anything special to install SQL? like I did with PHP? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 2, 2006 Share Posted October 2, 2006 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 Quote Link to comment Share on other sites More sharing options...
devarmagan Posted October 14, 2006 Share Posted October 14, 2006 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?? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 14, 2006 Share Posted October 14, 2006 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 Quote Link to comment Share on other sites More sharing options...
devarmagan Posted October 14, 2006 Share Posted October 14, 2006 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 Quote Link to comment Share on other sites More sharing options...
devarmagan Posted October 14, 2006 Share Posted October 14, 2006 i have to download this vesion right "Win32 Binary (MSI Installer): apache_2.0.59-win32-x86-no_ssl.msi [PGP] [MD5]" Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted October 14, 2006 Share Posted October 14, 2006 Yes download the binaries.NOTE: Before installing Apache remove the files left over from uninstalling Apache2.2.x. Quote Link to comment Share on other sites More sharing options...
devarmagan Posted October 14, 2006 Share Posted October 14, 2006 the apache is working fine now thank youand i have test the php like http://localhost/Examples/hello.phpand create the files in C:\Examples\hello.php its not working error msg "The page cannot be found" Quote Link to comment Share on other sites More sharing options...
devarmagan Posted October 14, 2006 Share Posted October 14, 2006 thank you its working fine Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.