Can I use PHP exec() to run a terminal command on a remote server? If not, what can I use and how? I need to execute a terminal command on a remote server. What are my options?
Can I use PHP exec() to run a terminal command on a remote server?
Share
You can use
ssh2_exec()instead. And very obviously you need permission (= an account) on the remote server and an enabled SSH service. It’s quite a standard option for Unix/BSD/Linux servers.If you don’t have that extension installed, then using
sshvia exec() is the next best thing (but requires some setup, you need keys rather than password authorization):