/    Sign up×
Community /Pin to ProfileBookmark

Problem running first php script on my linux system(RHL5)

Hi Everybody!!!!
I am newbie in field of php. I am trying to run my first php script(present on desktop) named index.php on my Linux system containing following code:-

<html>
<body>
<?php
echo”Hello ……..!!!”;
?>
</html>
</body>

Whenever i double click on this script, it opens a new tab in browser and showing a blank page and then opens a small window saying:

Open file Firefox web browser (default)
Save File

Ok Cancel:confused:

if i press ok then it again opens a same new window….

Is there any problem with the path of script:– current path is /root/Desktop.
What to do Please advice me..

Thanks in advance.

to post a comment
PHP

7 Comments(s)

Copy linkTweet thisAlerts:
@tirnaJan 20.2011 — PHP is a server side scripting language which means it runs on a web server before the web page is sent back to the requesting browser. So double clicking a php file on your desktop won't work.

You have 2 choices.

1) upload your script to a web server somewhere. There are plenty of free web hosts around.

2) download a free local web server onto your pc for development purposes. XAMPP is a good free open source web server preconfigured with apache, php and mysql and is ready to go (just add water ?)
Copy linkTweet thisAlerts:
@kapsonsauthorJan 20.2011 — I have installed apache on my system.....
Copy linkTweet thisAlerts:
@NogDogJan 20.2011 — If Apache is running and PHP properly installed so that Apache "knows" what to do with it, then you need to (a) make sure the PHP file is in the web document root directory or one of its sub-directories, and (b) you need to launch it via a http url (not a "file:" path), usually using "localhost" for the domain if testing locally, e.g.: "http://localhost/path/to/file.php".
Copy linkTweet thisAlerts:
@kapsonsauthorJan 21.2011 — Thanks for your help, I appreciate.......but When i tried


http://localhost/usr/local/apache/htdocs/index.php

it is giving following error..


err:404 Not Found

I have installed my apache in /usr/local/apache/htdocs

and placed a file named "index.php" in /usr/local/apache/htdocs/index.php


?????????
Copy linkTweet thisAlerts:
@wsparrowJan 21.2011 — Have you told apache where to find it? I'm not 100&#37; sure with RHL but in Fedora (which is based on RHL) the default document root is /var/www/html/ Try moving your files there. And check if you have a .htaccess file in your document root (wherever that may be). It's a hidden file, but it should be there. Your server/site configuration depends (in part) on that file.

Also, if you're accessing this server through a LAN or WAN, you'll want to check that your firewalls aren't getting in the way. That's probably not the case here, but it never hurts to check.

Is this the first time you've worked with apache? If so, check out the official documentation, it can be a little cryptic in places, but still helpful.

*edit* Just checked the official docs and the default location for RHL IS in fact /var/www/html/ So if you're putting your files somewhere else, you need to edit httpd.conf (as root) to tell it where to look.
Copy linkTweet thisAlerts:
@tirnaJan 21.2011 — try entering

[URL]http://localhost/[/URL]

in your browser and see where that takes you. It should be the servers root directory.
Copy linkTweet thisAlerts:
@NogDogJan 21.2011 — try entering

[URL]http://localhost/[/URL]

in your browser and see where that takes you. It should be the servers root directory.[/QUOTE]


What Trina said. If htdocs is your web document root, then the URL would be "http://localhost/index.php" (or without the "index.php" as Tirna wrote assuming your Apache configuration has "index.php" as a default file name).
×

Success!

Help @kapsons spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.2,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...