Samay Bhavsar

Blog

Problem with permissions which when using Linux commands with PHP in functions like exec, system

December 15, 2011 by samay

When you execute linux command in PHP functions like exec(), system() or shell_exec() there might be a problem in accessing certain files. Here the commands are executed by Apache and the user which executes it is www-data. This user does not have root access and if you use sudo, it will ask for password. This can be solved by editing the /etc/sudoers file.

It is recommended to take a backup before editing this file. Go to shell prompt and type:

visudo

Add the line below to the file and save.

www-data ALL=(ALL) NOPASSWD: ALL

Restart Apache2 using

/etc/init.d/apache2 restart

Category:

No Comments »

No comments yet.

RSS feed for comments on this post.

Leave a comment