Need a CLI version of PHP?


(Avi Miller) #1

If you're installing MySource Matrix with the Squiz Server on Red Hat Enterprise Linux, you may have noticed that the version of PHP that ships by default doesn't include a CLI version.


Here's a known-good PHP configure line for RHEL3 (or any other distro, for that matter), which creates a new version of PHP in /usr/local/php-cli specifically for the Squiz Server and other command-line PHP scripts.


    './configure' \
    '--prefix=/usr/local/php-cli' \
    '--enable-inline-optimization' \
    '--with-xml' \
    '--enable-bcmath' \
    '--with-openssl' \
    '--with-zlib=/usr' \
    '--enable-wddx' \
    '--enable-ftp' \
    '--disable-cgi' \
    '--enable-pcntl' \
    '--enable-memory-limit' \
    '--with-curl=/usr' \
    '--with-gettext' \
    '--enable-sockets' \
    '--with-pspell=shared,/usr' \
    '--with-pgsql=shared' \
    '--enable-mbstring=all' \
    '--with-pear' \
    '--with-ldap'


Notes: You may need to replace
    '--with-pgsql=shared'
with
    '--with-mysql=shared'
if you are using MySQL instead of PostgreSQL.

(44 J) #2

I'm not able to get this working as described.


When I tried to run step 2, I got:


[quote]/usr/local/php-cli/bin/php install/step_02.php .

±-----------------------------------------------+

| MySource Error                              |

|------------------------------------------------|

| DB Error: connect failed                    |

±-----------------------------------------------+[/quote]



So, I did a basic test:


[quote]/usr/local/php-cli/bin/php ./mysql.php



Fatal error: Call to undefined function: mysql_connect() in /home/webadmin/ms.firebright.com/html/mysql.php on line 2[/quote]



I'm trying to get the cli compilation to work with a simple mysql_connect() function, to see whether mysql functionality is there. It's not.



These are the compile options I am using for the CLI:


[quote]'./configure' \

'–prefix=/usr/local/php-cli' \

'–enable-inline-optimization' \

'–with-xml' \

'–enable-bcmath' \

'–with-openssl' \

'–with-zlib=/usr' \

'–enable-wddx' \

'–enable-ftp' \

'–disable-cgi' \

'–enable-pcntl' \

'–enable-memory-limit' \

'–with-curl=/usr' \

'–with-gettext' \

'–enable-sockets' \

'–with-pspell=shared,/usr' \

'–with-mysql=shared,/usr' \

'–enable-mbstring=all' \

'–with-pear' \

'–with-ldap'[/quote]



I'm a little at a loss as to why CLI mysql would not be available, as this the same configuration used on the non-CLI version.



Thoughts? I know this is outside the scope of basic installation, but I'd like to get it solved and I'm sure getting it solved will provide benefit to future customers.



Jonathan


(Avi Miller) #3

First version erased because I didn't read properly.


Its failing to find the PEAR DB modules. You need to create a php.ini file in /usr/local/php-cli/lib which has the location of the CLI-version of PEAR (/usr/local/php-cli/lib/php) configured in the include_path parameter.


(J) #4

Avi -


Actually, I didn't do that, but I was able to get it to install (with warnings though) after upgrading mysql to 4.x on my machine. Apparently (another thread) the 3.23 version I had on my machine was too ancient to work. :wink:



Thanks for the tip though!



Jonathan


(Avi Miller) #5

Handy hint:


To make working with the CLI version of PHP easier, I create a symlink from /usr/bin/php-cli to /usr/local/php-cli/bin/php. Then I can reference php-cli anywhere. :slight_smile:


(Chris Mysourcematrix) #6

The CLI will still fail if you have mysql 3.23.58 with InnoDB support at


php step_02.php .





DB Error: syntax error

SET table_type=innodb [nativecode=1064 ** You have an error in your SQL syntax near 'table_type=innodb' at line 1]



I'm pretty sure that mysql 3.23.x syntax is



"TYPE=InnoDB"



rather than

"table_type=innodb"



Cheers,



Chris


(Chmouel Boudjnah) #7

Just FYI on the subject there is now rpm package of php-cli for RHEL4 that's do have a php-cli command. if scripts rely on it you can mv php to php-cgi and ln php-cli to php. The better would be to fix the scripts thought


(Matt Webster) #8

[quote]
Just FYI on the subject there is now rpm package of php-cli for RHEL4 that's do have a php-cli command. if scripts rely on it you can mv php to php-cgi and ln php-cli to php. The better would be to fix the scripts thought

[/quote]





Is this still the case with RHEL5? do we still need to compile PHP-CLI


(Benjamin Pearson) #9

[quote]
Is this still the case with RHEL5? do we still need to compile PHP-CLI

[/quote]



I guess so, there are RPMs for PHP-CLI for other distros. I assume RHEL5 would have a similar standard. Source: RPM find


(Peter Sheppard) #10

[quote]
Is this still the case with RHEL5? do we still need to compile PHP-CLI

[/quote]



There's an RPM for it as part of the standard distribution.



You just run "php" on the command line now though, not "php-cli".


(Matt Webster) #11

Cheers good to see RHEL caught up with providing a cli version of php aswell :slight_smile: