?
Solved

Setting up a New PHP program in a brand new Fedora Core Server, How?

Posted on 2006-05-04
11
Medium Priority
?
160 Views
Last Modified: 2010-03-04
Hello!   Everyone,

The following PHP script doesn't run in a brand new Fedora Core.   What should I edit on /etc/php.ini.   Should I add my username?   Thank you for help!


#!/usr/bin/php

<!-- This is another comment line after shell-bang -->



<html><head><title></title></head>



<body>



<h1>A Test!</h1>



<?



// A comment line, if it hides



$userName = "Mitsuru";

print "Hi there! $userName";



?>



</body>

</html>

0
Comment
Question by:mkido
  • 8
  • 3
11 Comments
 
LVL 6

Expert Comment

by:bimal_linux
ID: 16628195
#rpm -qa|grep php
What is the out put?? Could you please confirm necessary php rmps are inplace in the system?

Regards,
Bimal Mankara
0
 

Author Comment

by:mkido
ID: 16645146
Hello!  Bimal_linux,

Here is the output.   What do you think?   Is this about the running PHP version?  

[root@biwa root]# rpm -qa | grep php
php-imap-4.3.3-6
php-4.3.3-6
php-ldap-4.3.3-6
[root@biwa root]#

By the way, which file permission should the PHP file have?   755?  
0
 

Author Comment

by:mkido
ID: 16645247
How about, is there any other way to test if PHP program is functional (or operating) by a simple test?    Such as by a command line test?  
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:mkido
ID: 16654432
I am also wondering that the Place of file is not the correct place.   Right now, I put the PHP file at,
   /var/www/cgi-bin/TEST/

I am assuming that PHP file should be treated like a PERL CGI?   Am I right?   Or do I place PHP files somewhere else.   Or should I configure "php.ini" file?    Any suggestion?  
0
 

Author Comment

by:mkido
ID: 16654443
When I was browsing about PHP, I saw some some PHP is missing the first line of Poud-Bang (#!) magic line,

In PERL,
 #!/usr/bin/perl
print "<HTML>\n";
print "<BODY>\n";
print "<P>Welcome, $Name</P>\n";
print "</BODY>\n";
print "</HTML>\n";

And now in PHP:
<HTML>
<BODY>
<P>Welcome, <?php print $Name; ?></P>
</BODY>
</HTML>

When the magic line is necessary, and when it isn't necessary?    
0
 

Author Comment

by:mkido
ID: 16654632
Another question I have is, (to bimal_linux), what is this rpm check.  

php-imap-4.3.3-6
php-4.3.3-6
php-ldap-4.3.3-6

 If it shows above, then that means the PHP program (module) is loaded and running?   I tried addition of modules based on the FAQ 53 of (www.php.net) onto "httpd.conf", but it didn't accept the module addition.
0
 

Author Comment

by:mkido
ID: 16655564
Hello!,  

I found a command level running of .php script according to the textbook, "PHP Cookbook" (O'Reilly)" page 518.

Then one of my .php script which runs at command level was executed from a .html page.   Then it shows as below.   Where can I adjust the REDIRECT_STATUS CGI in the Apache Server.   Is it /etc/httpd/conf/httpd.conf ????


==========  What I got, now  ==========
Security Alert! The PHP CGI cannot be accessed directly.

This PHP CGI binary was compiled with force-cgi-redirect enabled. This means that a page will only be served up if the REDIRECT_STATUS CGI variable is set, e.g. via an Apache Action directive.

For more information as to why this behaviour exists, see the manual page for CGI security.

For more information about changing this behaviour or re-enabling this webserver, consult the installation file that came with this distribution, or visit the manual page.
=========================
0
 
LVL 6

Accepted Solution

by:
bimal_linux earned 400 total points
ID: 16656069
Hi Mkido,

Sorry i was out of the town.
From these mails I understand that you are trying to run PHP as a CGI script. Do you really need this?  Your appache installation has the php support. (thank you for the rpm list). What you have to do is put your php file in the document root (/var/www/html if you have default settings) and try to access the page with http://yourip/test.php. You dont have to use "#!/usr/bin/php" at the begnining of the php file.

Hope it helps

Regards,
Bimal Mankara
0
 

Author Comment

by:mkido
ID: 16660381
It's start WORKING!!!!

Thank you very very much.   By the way,

You said,
--Your appache installation has the php support. (thank you for the rpm list).--

How do you read the response of
rpm -qa | grep php ??

php-imap-4.3.3-6
php-4.3.3-6
php-ldap-4.3.3-6

Does this suggest it's OK to run in /var/www/html?    I don't have to treat .php as CGI?    In what condition, I have to treat .php script as CGI?   I will close soon, but just a final talk.   Thanks.
0
 
LVL 6

Expert Comment

by:bimal_linux
ID: 16665091
Hi,

if you have the rpm package: php-4.3.3-6, the php support for httpd will be there. And I assumed httpd server is already installed. What was pending is the correct location for your php script. Usually php is not using as CGI. It is not appreciable and is difficult ;) . YOu can treat any executable script as cgi. why only php? Dont go for php as cgi unless your application require it.

Thanks
Bimal Mankara
0
 

Author Comment

by:mkido
ID: 16668896
Thank you very much.   My a few PHP scripts are working fine, and I feel great.   Thanks.
0

Featured Post

Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In my time as an SEO for the last 2 years and in the questions I have assisted with on here I have always seen the need to redirect from non-www urls to their www versions. For instance redirecting http://domain.com (http://domain.com) to http…
Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question