LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-31-2008, 02:37 PM   #1
inluminous
LQ Newbie
 
Registered: Mar 2008
Posts: 7

Rep: Reputation: 0
How to enable php cli?


I have a dedicated server running Fedora Core 6 (64-Bit)
with php 5.1.6. warboot.com/phpinfo.php
php directory /usr/bin/php

Let me begin by saying I'm new to linux and do not have that much experience when it comes to linux.

I need to enable cli for php, i need it for a video script. I have looked through various websites and could not find a way to do this, without reinstalling php (that i don't know how to do).

Any help would be greatly appreciated!
 
Old 03-31-2008, 04:56 PM   #2
simplicissimus
Registered User
 
Registered: Mar 2008
Posts: 104

Rep: Reputation: 15
Cli

Since PHP 4.3.0 the CLI SAPI is on by default. If you use the Fedora 6 installed PHP 5.x version than you should have it already. Unless you compiled PHP yourself and disabled CLI, but then you would know about it.

CLI means Command Line Interface. To run a PHP script from the terminal type:

Code:
$ php my_script.php param1 param2 paramN
I assume your video script is written in PHP, but is not meant to be run on a webserver, and you have to pass parameters on the command line.

Hope this helps,
Regards,
SIMP
 
Old 03-31-2008, 06:14 PM   #3
inluminous
LQ Newbie
 
Registered: Mar 2008
Posts: 7

Original Poster
Rep: Reputation: 0
thanks

Thank you for reply. I have a 1and1 dedicated server, so they had all the stuff installed already, i rang them up, and they cant provide me any support with this.
Basically my script is here http://warboot.com/tube/install/index.php?lng=en (ostube script)
it says:
"The command line version of PHP could not be found. Please make sure that the cli version is installed, and that mysql.so is also activated for the cli."
So i need to fix this. Any ideas?
 
Old 03-31-2008, 07:21 PM   #4
simplicissimus
Registered User
 
Registered: Mar 2008
Posts: 104

Rep: Reputation: 15
some options

The server has a PHP version with CLI disabled. Not uncommon that system administrators recompile certain packages to their liking.

I think it's paranoid to remove CLI, but some people might argue that PHP is mainly used for generating webpages and the majority will not use CLI anyway. They think it's a security problem, which is a silly. If some intruders have taken over the server already, then a missing CLI from PHP will not hold them back.

If this is not your own server and you can not convince them to reinstall PHP with CLI or at least install an additional PHP version with CLI (also possible), then you still have a few options:

1) switch service provider (phpwebhosting.com seems to be a good choice)

2) modify the script: where arguments like $argc and $argv[1] appear, you must change them to $_REQUEST['your-argument-name-here'], and additionally create an HTML page with a webform that passes 'your-argument-name-here' to your script. If your not skilled with PHP or osTube is too complex for you (never mind, it's too complex for most of us), then you can still put up a bid request on rentacoder.com or similar.

Hope this helps,
Regards,
SIMP

Fedora User

Last edited by simplicissimus; 04-02-2008 at 06:13 AM.
 
Old 03-31-2008, 07:42 PM   #5
inluminous
LQ Newbie
 
Registered: Mar 2008
Posts: 7

Original Poster
Rep: Reputation: 0
well..

Well i have root access, so i have full control, and they will not reinstall php for me. I cannot switch service provider as i have a 2 year contract which began this month, so i have to make this work.

You said i could install an additional php module with cli enabled? How would i do this?

As for modifying the script, I'm not that advanced =P

thx for your help
 
Old 04-01-2008, 06:02 AM   #6
simplicissimus
Registered User
 
Registered: Mar 2008
Posts: 104

Rep: Reputation: 15
multiple PHP's

Quote:
You said i could install an additional php module with cli enabled? How would i do this?
It's not a module. You need an entire PHP package installed in a way that does not conflict with the other (currently) installed PHP package.

I've never done that, but should I face something like this, then I would consider these options:

- install PHP as a non-root user into the user's home directory. This way even the configuration files are stored within the home directory. Must set permissions so that Apache can access the files.

- install as root in a different location - the root account would still allow to overwrite existing config files in /etc. Both installs would use the same config files - could work, but can be tricky.

In both cases: You have to make changes so that the video script will be launched by the proper PHP version. How to do this depends on the internals of the code. In the most simple case a shebang-line is enough like:
#!/home/user/bin/php

I'm a bit surprised that Fedora 6 has a CLI-disabled PHP set. I'm using a plain Fedora 8 install and have CLI by default. Since you have root access and somehow own the box, you could reinstall PHP yourself using 'yum' or 'rpm'. You could even upgrade to Fedora 8, as Fedora 6 isn't supported anymore with security fixes as far as I know.

This won't be easy. You should do some install tests on a local box to avoid breaking your server.

Regards,
SIMP
 
Old 04-01-2008, 07:53 AM   #7
inluminous
LQ Newbie
 
Registered: Mar 2008
Posts: 7

Original Poster
Rep: Reputation: 0
cli

That is 2 much hassle for a linux noob like me, ill probably end up breaking the server. Is it not possible to somehow upgrade the php installation to the the latest version, but it keeps all the original settings in tact, but i just add the line --enable cli or something?

As for installing the php in another location, and trying to edit the script, could work, but then i would have to ask whoever made the script how to do it exactly.

thanks
 
Old 04-02-2008, 06:48 AM   #8
simplicissimus
Registered User
 
Registered: Mar 2008
Posts: 104

Rep: Reputation: 15
php -v

Right now we just assume that the osTube installer provides correct output. Run:

Code:
php -v
The output on my Fedora box is:

Code:
$ php -v
PHP 5.2.4 (cli) (built: Oct 16 2007 09:13:35)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies
If you don't have that '(cli)' after the version number, then osTube was right, and you don't have CLI-enabled.

Enabling CLI is a compile-time option, you can not add it later as a module.

Under normal circumstances you will have 'yum' installed. If you decide to re-install PHP, then:

Code:
yum remove php # removes the current PHP, needs confirmation
yum install php # will install again, needs confirmation
If it still is missing CLI, then we will know at least that 64-bit Fedora's have CLI-disabled PHP versions, unlike the 32-bit Fedora that I have on a few PC's (all with CLI). In this case you have to download the source code and follow the README and INSTALL notes. The configuration file should enable CLI by default, but to make sure add the required enable-cli option.

Good luck and let me know how it goes.


Regards,
SIMP
 
Old 04-02-2008, 12:46 PM   #9
marquardl
Member
 
Registered: Apr 2008
Posts: 100

Rep: Reputation: 15
php4-cli

Hi,

Just as an addition or correction:

For PHP there was/is a module available called php4-cgi, which should have an addition called php4-cli.

I guess there must be a version for PHP5 as well ... I don't know for sure. I can't tell if this php4-cgi or php5-cgi is a valid replacement for a full PHP build with CLI enabled, but it is worth to check.

Bye,
Marq

Linux Archive

Last edited by marquardl; 05-01-2008 at 02:35 AM.
 
Old 04-02-2008, 05:12 PM   #10
inluminous
LQ Newbie
 
Registered: Mar 2008
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by marquardl View Post
Hi,

Just as an addition or correction:

For PHP there was/is a module available called php4-cgi, which should have an addition called php4-cli.

I guess there must be a version for PHP5 as well ... I don't know for sure. I can't tell if this php4-cgi or php5-cgi is a valid replacement for a full PHP build with CLI enabled, but it is worth to check.

Bye,
Marq
Thx, will look into it
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP: some scripts parse, some don't (HTTP and CLI) Splenden Linux - Server 6 03-27-2007 02:27 AM
php mail() fails from apache but not from CLI matiasquestions Linux - Server 0 11-24-2006 12:04 PM
cli php & gd janakvi Linux - Software 0 09-12-2006 03:47 AM
Php Cli skiflyer Debian 1 01-11-2005 01:50 PM
PHP CLI on Debian rcs1000 Debian 2 08-01-2004 11:40 AM


All times are GMT -5. The time now is 02:34 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration