简体   繁体   中英

Executing shell script in different directory using PHP

I have a shell script in the /home/ directory. I'd like to execute it by using a web page. The webserver is located in /var/www/. I'm wondering how would I execute the shell script from within the homepage using PHP?

I'm using Ubuntu Server.

Use php exec function:

exec('/path/to/shell/script');

However this will only work if safe_mode is disabled, php has permissions to such folder and file, or is defined in your basedir.

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