简体   繁体   中英

How do I execute a php file on the server using the screen command?

I was looking at this post which is where I got the idea to use screens to execute my php scripts on the server: Running a PHP script completely on server side

I was successfully able to execute a php script using:

screen

php ./file.php

However, this did not work for me:

screen ./file.php

And it was that last way of doing it that was recommended in that post I linked.

All it says is: Cannot exec './file.php': Permission Denied

sudo screen ./file.php did not work either.

You have to pass screen a shell command that works.

You had a shell command that works in your first attempt.

You then removed part of it when you tried to pass it to screen . Don't do that. Leave the command intact.

screen php ./file.php

If you want the PHP script to be executable directly (ie without passing it as an argument to the php command line binary) then you need to:

  • Make sure that the first line explains how to execute it ( #!/usr/bin/env php )
  • Set the permissions on it so it is executable ( chmod u+x file.php )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM