因此,我正在与PHP / MySQL网站上的设计师合作,他希望有一些脚本可以让他的生活更轻松。 他非常适合使用git,SASS,node等东西的命令行。我希望他能像运行程序一样运行我的脚本,而不是通过PHP运行它。
所以不是这样的:
php /path/to/file/create_module.php module_name我想这样做:
myscript create_module module_name是否可以在Apache服务器上使用PHP执行此操作? 我知道我很可能必须修改服务器才能正确解释它,这很好。 我甚至不知道从哪里开始,也无法在Google上找到我需要的东西。
So I'm working with a designer on a website in PHP/MySQL and there are a few scripts that he would like to have to make life easier for him. He is pretty comfortable using the command line for stuff like git, SASS, node, etc. I would like him to be able to run my scripts like he would run a program, instead of running it through PHP.
So instead of this:
php /path/to/file/create_module.php module_nameI would like to do this:
myscript create_module module_nameIs it possible to do this with PHP on an Apache server? I know I will most likely have to modify the server to interpret it properly, which is fine. I just don't even know where to begin, and couldn't find what I needed on Google.
最满意答案
你最好的选择是创建一个alias 。
所以myscript的别名实际上会指向命令: php /path/to/file/create_module.php然后任何额外的参数将作为类型传递。
在命令行中,执行以下操作:
cd /etc/ nano bash.bashrc在文件的最底部,添加以下文本行:
alias "myscript=php /path/to/file/create_module.php"BASHRC是一个在用户登录时运行的脚本,因此每次用户登录系统时都会重新创建别名。
Your best bet would to be to create an alias.
So an alias of myscript would actually point to the command: php /path/to/file/create_module.php and then any extra arguments will be passed as typed.
In command line, do the following:
cd /etc/ nano bash.bashrcAt the very bottom of the file, add this line of text:
alias "myscript=php /path/to/file/create_module.php"BASHRC is a script that is run on user login, so the alias will be recreated every time the user logs into the system.
更多推荐
发布评论