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

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>

mkidoAsked:
Who is Participating?
 
bimal_linuxCommented:
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
 
bimal_linuxCommented:
#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
 
mkidoAuthor Commented:
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
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
mkidoAuthor Commented:
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
 
mkidoAuthor Commented:
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
 
mkidoAuthor Commented:
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
 
mkidoAuthor Commented:
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
 
mkidoAuthor Commented:
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
 
mkidoAuthor Commented:
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
 
bimal_linuxCommented:
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
 
mkidoAuthor Commented:
Thank you very much.   My a few PHP scripts are working fine, and I feel great.   Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.