【发布时间】:2016-09-10 06:51:50
【问题描述】:
我在这里阅读了几个问题,如何从 html 运行 bash 脚本。他们中的大多数人把我介绍给了 php。 I followed everything in here 但不行。 我对 html 或 php 没有任何经验。 所以我把所有东西都设置好了(我认为......)。 我安装了 nginx(并且工作正常)。 我安装了 php 和 php-fpm。
我的简单网页是:
<!DOCTYPE html>
<html>
<head>
<title>My page</title>
</head>
<body>
<button type="button" onclick="run.php">Click Me!</button>
</body>
</html>
我的默认 nginx 服务器配置是:
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.html;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root /usr/share/nginx/html;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_index index.php;
# include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
我尝试了两种选择:单独使用 php5-cgi / 使用 php5-fpm
我的 php 脚本应该在按钮点击时触发:
<?php
shell_exec("ls");
header('Location: https://www.google.com');
?>
但是什么也没有发生(现在,我只运行简单的 ls。当它可以工作时,我会将其更改为一些 /path/script.sh)
我做错了什么?
【问题讨论】: