Using Centos To Run Shell Commands With PHP Scripts
Linux has all sorts or neat packages you can install. Luckily, you may want to use one of them from a PHP script. This brief tutorial will explain how to do this.
The code below takes a submittted form and gathers the url into variable called $url. Then, the httrack service is used to clone the desired website.
shell_exec('/usr/local/bin/httrack http://' . $url . '/ -O "/home/username/websites/ ' . $url . '" -%v -%e0 2>&1;');
Besides PHP, you need to make modifications to the /etc/sudoers file on Linux. The change is shown below.
username ALL=NOPASSWD: /usr/local/lib/httrack,/usr/local/bin/httrack
Now, when you open the folder /home/username/websites/ you will see the new clone.
Here is a simple may to open the new cloned folder with the Linux shell: