View Full Version : How to run PHP CLI on a server ?
anjanesh 05-27-2005, 02:05 PM How to run PHP CLI on a server ?
Im working on my clients site and he has a dedicated server with Plesk 7.5.0.
I have a PHP script that takes some 2-3 hrs or more to run (crawling sites and extracting data in case you want to know why 1 code takes so long) and here I have a net connection that is interrupted very often - even 1 sec of disconnection will result in restarting the script because this is browser based and it gets stopped if conection b/w the client and server is down.
I want to know how to run this in CLI ? I understand if I start the command on the server and even if I switch off my PC that script will still run right ?
I entered Plesk's SSH Java-based terminal and entered:
$bash php -v
but it gave Bad Command.
How do I enter into the server via telnet ?
I understand WinSCP has remote terminal too but no user input allowed ?
PHP 4.3.4
Thanks
TehBooster 05-27-2005, 02:30 PM PHP needs to be compiled with --with-cli
./configure --with-cli && make && make install
anjanesh 05-27-2005, 03:00 PM Isnt PHP normally complied with CLI ? After all its a dedicated server.
I dont think compiling can be done now.
Will re-compiling have an effect on the current scripts ?
TehBooster 05-27-2005, 03:39 PM On linux cli is not enabled if PHP is not compiled as CGI.
I doubt it however to be safe, get the current configure command from phpinfo(); and add --with-cli
Example ./configure
'./configure' '--with-apxs=/usr/bin/apxs' '--sysconfdir=/etc/php4/apache/' '--with-layout=PHP'
'--with-config-file-path=/etc/php4/apache' '--with-openssl' '--with-zlib'
'--enable-bcmath' '--enable-calendar' '--with-curl' '--enable-dba'
'--with-dom' '--enable-ftp' '--with-gd' '-with-jpeg-dir=/usr/' '--with-gettext' '--enable-mbstring' '--with-mcrypt' '--with-mhash'
'--with-mime-magic' '--with-mysql=/usr/' '--enable-sysvmsg' '--enable-sysvsem' '--with-xmlrpc' '--enable-xslt' '--with-xslt-sablot'
'--with-zip' '--with-pear' '--enable-memory-limit' '--enable-sockets'
'--enable-pcntl' '--with-cli' '--with-pgsql=/usr/'
anjanesh 05-27-2005, 03:54 PM './configure' '--host=i386-redhat-linux' '--build=i386-redhat-linux'
'--target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr'
'--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share'
'--includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '--localstatedir=/var'
'--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '--infodir=/usr/share/info'
'--cache-file=../config.cache' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d'
'--enable-force-cgi-redirect' '--disable-debug' '--enable-pic' '--disable-rpath'
'--enable-inline-optimization' '--with-bz2' '--with-db4=/usr' '--with-curl'
'--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr'
'--with-png-dir=/usr' '--with-gd' '--enable-gd-native-ttf' '--without-gdbm'
'--with-gettext' '--with-ncurses' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr'
'--with-openssl' '--with-png' '--with-pspell' '--with-regex=system' '--with-xml'
'--with-expat-dir=/usr' '--with-dom=shared,/usr' '--with-dom-xslt=/usr' '--with-dom-exslt=/usr'
'--with-xmlrpc=shared' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-bcmath'
'--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-safe-mode' '--enable-sockets'
'--enable-sysvsem' '--enable-sysvshm' '--enable-track-vars' '--enable-trans-sid' '--enable-yp'
'--enable-wddx' '--with-pear=/usr/share/pear' '--with-imap=shared' '--with-imap-ssl' '--with-kerberos'
'--with-ldap=shared' '--with-mysql=shared,/usr' '--with-pgsql=shared' '--with-snmp=shared,/usr'
'--with-snmp=shared' '--enable-ucd-snmp-hack' '--with-unixODBC=shared,/usr' '--enable-memory-limit'
'--enable-bcmath' '--enable-shmop' '--enable-calendar' '--enable-dbx' '--enable-dio' '--enable-mcal'
'--enable-mbstring' '--enable-mbstr-enc-trans' '--enable-mbregex' '--with-apxs2=/usr/sbin/apxs'
How can I just add --with-cli ?
Burhan 05-27-2005, 04:22 PM Before jumping through all these hoops -- find out if the user that you are logging in as has rights to run the php command. It might just be a permissions issue.
Unless you have root privileges, you will not be able to recompile PHP. Find out what ./configure line was used by viewing the output of phpinfo();
innova 06-03-2005, 06:03 PM Unless you have root privileges, you will not be able to recompile PHP
Cmon :)
Actually, you cannot install it to a system-owned/root-owned folder, like /usr/local.
There is no problem whatsoever with compiling a CLI executable and copying the freshly-minted file to wherever you like and running it from there.
I do this to run a CLI-script that needs php5 for the stream() family of functions that arent part of php4. This way, I can still have php4 on the server and just a standalone (albeit large) php5 binary to run the CLI portion.
Burhan 06-04-2005, 02:15 AM the error just says, that the array you sent is empty, adding the @ beforehand will just ignore that error..
You are correct here, but ... only the very trusting (very stupid) sys admin would allow people to compile and run binaries in their /home dirs.
TimSG 06-04-2005, 03:46 PM If you're using a package based OS, you can also look around and see if there's a php-cli version hiding somewhere. IIRC, Redhat does have one.
Burhan 06-05-2005, 02:27 AM Gah, copied the wrong quote in my previous response. I was replying to :
actually, you cannot install it to a system-owned/root-owned folder, like /usr/local.
There is no problem whatsoever with compiling a CLI executable and copying the freshly-minted file to wherever you like and running it from there.
innova 06-05-2005, 11:47 PM True, but use your imagination :)
Simply compile the binary on your home linux box, have a friend compile a copy for you, etc. There are many ways to accomplish the task.
|