How To Run a .sh file using PHP

To run a .sh file in PHP, we can either use exec() or shell_exec() function. Here is how it works:

1. Using exec() function

<?php
exec('sh filename.sh');

2. Using shell_exec() function

<?php
shell_exec('sh filename.sh');