Abdelrahman Wahdan Abdelrahman Wahdan - 5 years ago 327
PHP Question

Run Linux Commands Using PHP

I have seen many questions about Running

Linux
Commands using
PHP
, but my problem is different. I am using a shared hosting
Linux
server, and I want to install a package called
Poppler-utils
using
PHP
code, because i have no access to the
Linux
command-line. First I tried to figure out the
Distro
using
cat /proc/version
and this is the output:

Linux version 2.6.32-604.30.3.lve1.3.63.el6.x86_64 (mockbuild@build.cloudlinux.com) (gcc version 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC) ) #1 SMP Sun Sep 27 06:34:10 EDT 2015


So I assumed it's
Redhat
Distro based on the output above. So I tried to install the
Poppler-Utils
Package using:

exec('yum install poppler-utils',$buffer);
echo implode($buffer);


As mentioned in this article.


install pdftotext under RedHat / RHEL / Fedora / CentOS Linux

pdftotext is installed using poppler-utils package under various Linux
distributions:

# yum install poppler-utils


OR use the following under Debian / Ubuntu Linux

$ sudo apt-get install poppler-utils



But nothing happens at all. So how can I install
Poppler-utils
in
/usr/local/bin/
?

Any help is appreciated!

Answer Source

You won't have sudo / root privileges on shared hosting to install files. The only option is to contact your hosting company and to ask for them to install it on the server.

You cant run exec on commands you don't have access to the function e.g. yum or apt-get ;).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download