Consider the example of killing process from the PHP website.
The approach of giving full permission to the webserver(apache or nginx) users like www-data, is not secure because if the site is hacked, the hackers can access the full system. So the following approach is the best method which doesn't have any security problems:
- Save the process ids in a database(egs:mysql) table through the PHP code itself.
- Open the linux terminal and login as the root user
- Setup a cron job which runs every minute.
- For that run the following command to edit the cron
- Put the following line:
* * * * * killProcess.php
Where killProcess.php fetches the process IDs from the database and execute the kill linux command(or any other linux commands as per your requirement) through the php function shell_exec().
Since the cronjob entry is configured as the root user, the specified script has all the same set of privileges as the root user.
Where are the examples?
ReplyDelete