LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   How to enable php cli? (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-enable-php-cli-631974/)

inluminous 03-31-2008 01:37 PM

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!

simplicissimus 03-31-2008 03:56 PM

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

inluminous 03-31-2008 05:14 PM

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?

simplicissimus 03-31-2008 06:21 PM

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

inluminous 03-31-2008 06:42 PM

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

simplicissimus 04-01-2008 05:02 AM

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

inluminous 04-01-2008 06:53 AM

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

simplicissimus 04-02-2008 05:48 AM

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

marquardl 04-02-2008 11:46 AM

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

inluminous 04-02-2008 04:12 PM

Quote:

Originally Posted by marquardl (Post 3108465)
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


All times are GMT -5. The time now is 02:51 PM.