0

I want to restart my TOR service with a PHP script in order to receive a new IP address. The reason why I plan to do that is because Google and some other sites start blocking me sometimes.

I tried Scripts such as

shell_exec ("sudo service tor restart")

exec ("sudo service tor restart") and system ("sudo service tor restart")

... but none of these are working.

Can someone give me a hint on what to do?

1 Answer 1

0

You have to setup sudo to make it possible. Apache user should have permissions to exec commands as root using sudo. Also there is no tty in php scripting so you have to disable tty requirement in sudo. And you don't have ability to enter user password to sudo in a php script, so you have to disable authentication too.

To do so put "service tor restart" to text file and make executable. It's much more secure meaning that apache user could only to restart TOR, nothing else. Then in /etc/sudoers comment out line:

Defaults    requiretty

Add lines:

Defaults    !authenticate
apache      ALL=NOPASSWD: /path/to/file

Replace apache with www-data if you're using Debian-like distro

Now you can do "sudo service tor restart" from your php script.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .