php 执行脚本

本文详细介绍了如何解决在Linux环境下遇到的PHP命令未找到的问题,通过修改环境变量PATH并重启配置,确保PHP命令可以在命令行中正确执行。此外,还讲解了如何通过编辑sudoers文件为特定用户或组分配执行权限,以便于在不输入密码的情况下运行PHP脚本。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

PHP -v 找不到命令

➜   which php

/usr/local/php/bin/php

➜   vim /etc/profile

PATH=$PATH:$HOME/bin:/usr/local/php/bin/

export PATH

➜  source /etc/profile

PHP命令行执行脚本

➜  php ./dosomethings.php

PHP网页操作shell脚本

需要给用户加入权限

➜  lsof -i:80

COMMAND PID  USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
nginx   714  root    6u  IPv4  12949      0t0  TCP *:http (LISTEN)
nginx   715 nginx    6u  IPv4  12949      0t0  TCP *:http (LISTEN)
nginx   716 nginx    6u  IPv4  12949      0t0  TCP *:http (LISTEN)
nginx   717 nginx    6u  IPv4  12949      0t0  TCP *:http (LISTEN)
nginx   718 nginx    6u  IPv4  12949      0t0  TCP *:http (LISTEN)

➜  vim /etc/sudoers

## Allow root to run any commands anywhere 
root    ALL=(ALL)       ALL
nginx    ALL=(ALL)       NOPASSWD:ALL #此行新加入nginx组无密码权限
## Allows members of the 'sys' group to run networking, software, 

欢迎来我的私人博客看看:http://blog.6le6le.com/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值