Centos PHP-fpm+Nginx实现单文件root权限执行exec()等Linux脚本 其他文件为普通权限

php-fpm.conf

[index]
listen = /usr/local/emps/var/virt9178.sock
listen.owner = emps
listen.group = emps
user = root
group = root
request_slowlog_timeout = 5s
slowlog = var/log/php-fpm-slowlog-index.log
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 10
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 500
listen.backlog = -1
request_terminate_timeout = 0s
rlimit_files = 131072
rlimit_core = unlimited
catch_workers_output = yes
env[HOSTNAME] = $HOSTNAME
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

[regular]

listen = /usr/local/emps/var/virt9179.sock listen.owner = emps listen.group = emps user = emps group = emps request_slowlog_timeout = 5s slowlog = var/log/php-fpm-slowlog-regular.log listen.allowed_clients = 127.0.0.1 pm = dynamic pm.max_children = 10 pm.start_servers = 3 pm.min_spare_servers = 2 pm.max_spare_servers = 4 pm.max_requests = 500 listen.backlog = -1 request_terminate_timeout = 0s rlimit_files = 131072 rlimit_core = unlimited catch_workers_output = yes env[HOSTNAME] = $HOSTNAME env[TMP] = /tmp env[TMPDIR] = /tmp env[TEMP] = /tmp

[ordinary]

listen = /usr/local/emps/var/virt9180.sock listen.owner = emps listen.group = emps user = emps group = emps request_slowlog_timeout = 5s slowlog = var/log/php-fpm-slowlog-ordinary.log listen.allowed_clients = 127.0.0.1 pm = dynamic pm.max_children = 10 pm.start_servers = 3 pm.min_spare_servers = 2 pm.max_spare_servers = 4 pm.max_requests = 500 listen.backlog = -1 request_terminate_timeout = 120s rlimit_files = 131072 rlimit_core = unlimited catch_workers_output = yes env[HOSTNAME] = $HOSTNAME env[TMP] = /tmp env[TMPDIR] = /tmp env[TEMP] = /tmp

Nginx.conf

#user  nobody;
worker_processes  1;
#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
pid/usr/local/emps/var/log/nginx/nginx.pid;
events {
worker_connections  1024;
}
http {
include   mime.types;
default_type  application/octet-stream;
log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  '$status $body_bytes_sent "$http_referer" '
  '"$http_user_agent" "$http_x_forwarded_for"';
access_log  /usr/local/emps/var/log/web.access.log  main;
sendfileon;
#tcp_nopush on;
#keepalive_timeout  0;
keepalive_timeout  65;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream novnc_server {
server 127.0.0.1:4081;
}
server_tokens off;
#gzip  on;

###################
# HTTP Connection
###################
server {
listen   4084;
server_name  localhost;
add_header X-Frame-Options SAMEORIGIN;
# The Document Root
root/usr/local/www/enduser;
rewrite "/sess([0-9a-zA-Z]{16})/(.*)" /$2;
# Redirect server error pages to the static pages
error_page  404/nginx/404.html;
error_page  497/nginx/497.html;
error_page  500 502 503 504/nginx/50x.html;
# Pass the INDEX.PHP script to FastCGI server listening on 127.0.0.1:9178
location ~ ^(/index.php|/)$ {
fastcgi_read_timeout 3600;
fastcgi_passunix:/usr/local/emps/var/virt9178.sock;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME  /usr/local/www/enduser/index.php;
fastcgi_paramSCRIPT_NAME  $fastcgi_script_name;
includefastcgi_params;
}
# Pass the regular PHP scripts to FastCGI server listening on 127.0.0.1:9180
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_read_timeout 600;
fastcgi_passunix:/usr/local/emps/var/virt9180.sock;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME  $document_root$fastcgi_script_name;
fastcgi_paramSCRIPT_NAME  $fastcgi_script_name;
includefastcgi_params;
}
}
}
赞 (1) 打赏

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏