LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-04-2015, 07:09 PM   #1
Bashed
Member
 
Registered: Jul 2015
Posts: 127

Rep: Reputation: Disabled
sh: zip: command not found


Running Centos 6.6 VPS (OVZ) with Centos Web Panel.

Trying to run a Wordpress plugin, getting this in log file

How do I correct this? It appears zip module is already installed as a dependency by default.

I tried a phpinfo.php file using only the following code:

Code:
<?php
var_dump( exec('zip -r domains.zip "domains"') );
// phpinfo();
?>
The php error log is now: [Sat Jul 04 17:44:27 2015] [error] [client xxx.xxx.xxx.xxx] sh: zip: command not found
Code:
[root@server ~]# yum install zip
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.atlanticmetro.net
 * extras: mirror.trouble-free.net
 * rpmforge: repoforge.mirror.constant.com
 * updates: mirror.cogentco.com
Setting up Install Process
Package zip-3.0-1.el6.x86_64 already installed and latest version
Nothing to do

Code:
[root@server ~]# php -m
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
hash
iconv
ionCube Loader
json
libxml
mbstring
mcrypt
mysql
mysqli
mysqlnd
openssl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
soap
sockets
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlrpc
xmlwriter
xsl
zip
zlib

It's already set to 5.4 PHP and zip is already compiled.

"You are running PHP version: 5.4.27"

Installed dependencies first too.

These are the flags which I already compiled.

Code:
./configure
--prefix=/opt/alt/php54/usr
--with-zlib
--enable-soap
--enable-exif
--with-config-file-path=/opt/alt/php54/usr/php
--with-config-file-scan-dir=/opt/alt/php54/usr/php/php.d
--enable-phar
--enable-bcmath
--enable-calendar
--with-curl
--with-iconv
--with-mysql
--with-mysqli
--with-mysql=mysqlnd
--with-mysqli=mysqlnd
--with-mcrypt
--with-gettext
--with-xsl
--with-xmlrpc
--with-pdo-mysql=mysqlnd
--enable-posix
--enable-ftp
--with-openssl
--enable-mbstring
--with-jpeg-dir=/usr
--with-freetype-dir=/usr
--with-kerberos
--with-xsl
--with-bz2
--enable-sockets
--enable-zip
--with-gd
--with-imap
--with-imap-ssl
--enable-sockets
--with-pcre-regex
--libdir=/usr/lib64
--with-mysql-sock=/var/lib/mysql/mysql.sock
Output of phpinfo.php ends up being

Code:
string(0) ""
 
Old 07-05-2015, 01:30 AM   #2
mralk3
Slackware Contributor
 
Registered: May 2015
Distribution: Slackware
Posts: 1,819

Rep: Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004Reputation: 1004
sh: zip: command not found

Nevermind, I misread the post.

Last edited by mralk3; 07-05-2015 at 01:31 AM.
 
Old 07-05-2015, 07:56 AM   #3
michaelk
Moderator
 
Registered: Aug 2002
Posts: 24,362

Rep: Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454
Welcome to LinuxQuestions.

The exec function will run zip as an external program versus the internal module. The error is due to zip not being in the Apache path environment. Either use the full path (usr/sbin/zip) or rewrite your code to use php internal zip functions.
 
Old 07-05-2015, 02:19 PM   #4
Bashed
Member
 
Registered: Jul 2015
Posts: 127

Original Poster
Rep: Reputation: Disabled
Thanks for your help. I changed "zip" to "/usr/bin/zip" in the phpinfo.php file and the out come was:

Code:
string(42) "updating: domains/xxxxxx.co/ (stored 0)"
Now, how do I do change this in the VPS so that path is always defined and able to be called by any script without having to manually define the full path?

I want to add /usr/bin/zip to the executable path for the web server.

I've tried:

Code:
export PATH=$PATH:/usr/bin/zip
AND

Code:
cd /usr/bin
Code:
sudo ln -s /usr/bin/zip zip
but neither helped
 
Old 07-05-2015, 03:04 PM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 20,193

Rep: Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829
you need to add the dir of the executable, not the app itself, so
export PATH=$PATH:/usr/bin
should have been added, but I'm not really sure about your problem, so this is only a tip now. I do not really understand your last link (ln -s ...) command
 
Old 07-05-2015, 03:55 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 24,362

Rep: Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454
There might be other methods but since Apache does not have a shell you can not export a path. To add a path you need to use the setenv directive in the http.conf file.

http://httpd.apache.org/docs/2.2/mod...nv.html#setenv

Last edited by michaelk; 07-05-2015 at 03:56 PM.
 
Old 07-05-2015, 07:05 PM   #7
Bashed
Member
 
Registered: Jul 2015
Posts: 127

Original Poster
Rep: Reputation: Disabled
"setenv" not found in httpd.conf?

Running Centos 6.6 64bit with Centos Web Panel, Apache 2.4, PHP 5.4


Quote:
[root@server conf]# which php
/usr/local/bin/php
[root@server conf]# which zip
/usr/sbin/zip
[root@server conf]# php -v
PHP 5.4.27 (cli) (built: Jul 4 2015 20:14:29)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
[root@server conf]# which httpd
/usr/bin/which: no httpd in (/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/bin/zip:/root/bin)
It's not my software to modify it's path internally too, it's obfuscated. So I cannot edit it's own files like that unfortunately.


I ran

ln -s /usr/bin/zip /usr/sbin/zip

Back to

[Sun Jul 05 18:58:19 2015] [error] [client xxx.xxx.23.22] sh: zip: command not found

My simple goal here:
I need to be able to call the command zip from within a PHP script without having to use the direct path /usr/bin/zip because it's out of my control to edit every single plugin needing zip access and modify their path.

Last edited by Bashed; 07-05-2015 at 08:24 PM.
 
Old 07-06-2015, 12:46 AM   #8
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 20,193

Rep: Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829
if you have zip in /usr/sbin you need to link it by:
ln -s /usr/sbin/zip /usr/bin/zip
 
Old 07-06-2015, 06:06 AM   #9
Bashed
Member
 
Registered: Jul 2015
Posts: 127

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by pan64 View Post
if you have zip in /usr/sbin you need to link it by:
ln -s /usr/sbin/zip /usr/bin/zip
I already ran that and it didn't solve the problem. Please read my previous post. I made it very clear I ran that in my last post.
 
Old 07-06-2015, 06:56 AM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 24,362

Rep: Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454
Did you try adding the path to the /etc/sysconfig/httpd and restarting apache.

export PATH=$PATH:/usr/bin

The output of phpinfo() should display the path environment.

Last edited by michaelk; 07-06-2015 at 07:04 AM.
 
Old 07-06-2015, 08:53 AM   #11
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 20,193

Rep: Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829
Quote:
Originally Posted by Bashed View Post
I already ran that and it didn't solve the problem. Please read my previous post. I made it very clear I ran that in my last post.
Please read carefully I did not write the same command. Your original command cannot work (but probably that was only mistyped, I don't know)
 
Old 07-06-2015, 12:27 PM   #12
Bashed
Member
 
Registered: Jul 2015
Posts: 127

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
Did you try adding the path to the /etc/sysconfig/httpd and restarting apache.

export PATH=$PATH:/usr/bin

The output of phpinfo() should display the path environment.
I put that in httpd.conf, restarted httpd but it gave an error and failed to restart.

Also,

[root@server ~]# ln -s /usr/sbin/zip /usr/bin/zip
ln: creating symbolic link `/usr/bin/zip': File exists
 
Old 07-06-2015, 12:34 PM   #13
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 20,193

Rep: Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829Reputation: 6829
obviously, it won't work in httpd.conf or similar file, that command should be used in shell.
also if that file exists you cannot create a link, that is normal.
what will
Code:
file /usr/bin/zip
file /usr/sbin/zip
respond?

Last edited by pan64; 07-06-2015 at 12:36 PM.
 
Old 07-06-2015, 01:21 PM   #14
michaelk
Moderator
 
Registered: Aug 2002
Posts: 24,362

Rep: Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454Reputation: 5454
/etc/sysconfig/httpd is not the same thing as /etc/http/conf/httpd.conf.
 
Old 07-06-2015, 01:24 PM   #15
Bashed
Member
 
Registered: Jul 2015
Posts: 127

Original Poster
Rep: Reputation: Disabled
/etc/sysconfig/httpd

Doesn't exist.

Running Centos 6.6 64bit to clarify.
 
  


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
[SOLVED] Apache error_log line: sh: zip: command not found AcorpComputers Linux - Server 2 06-09-2012 04:17 AM
ZIP 100drive atapi ide -not found!!!! chilibowl Linux - Hardware 3 11-02-2011 06:11 PM
How to zip several files to several zip with one command? thomas2004ch Linux - Newbie 4 02-08-2010 08:13 AM
bash: rpm: command not found && sudo: alien: command not found Java_Code Ubuntu 7 07-27-2006 11:57 PM
Klamav - virus found - Zip.ExceededFilesLimit rrsc16954 Mandriva 7 01-16-2006 06:53 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:47 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
Open Source Consulting | Domain Registration