linux 기본 스 크 립 트 학습 - CGI 간단 한 설정
3746 단어 링크 ux 기본 스 크 립 트 학습
spawn - fcgi 를 통 해 여러 cgi 인 스 턴 스 를 시작 합 니 다.
spawn-fcgi -a 127.0.0.1 -p 9000 /root/bin/php-cgi
nginx 설정 파일 은 다음 과 같 습 니 다.
user ciaos ciaos;
worker_processes 2;
events {
use epoll;
worker_connections 51200;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request_time "$request" ';
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
fastcgi_intercept_errors on;
server {
listen 80 default backlog=10000;
server_name localhost;
root /root/ciaos/html;
location / {
index index.html index.htm index.php;
}
location ~ .*\.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /root/ciaos/html$fastcgi_script_name;
include fastcgi_params;
}
}
}
그 중 fastcgiparams 파일 내용 은 다음 과 같 습 니 다.
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
로그 절단
#!/bin/bash
Y=`date -d "last day" +%Y`
M=`date -d "last day" +%m`
D=`date -d "last day" +%d`
if [ ! -r /usr/local/ciaos/logs/$Y/$M ]; then
mkdir -p /usr/local/ciaos/logs/$Y/$M
fi
mv /usr/local/ciaos/logs/access.log /usr/local/ciaos/logs/$Y/$M/$D.log
mv /usr/local/ciaos/logs/error.log /usr/local/ciaos/logs/$Y/$M/$D.error.log
kill -USR1 `cat /usr/local/ciaos/logs/nginx.pid`
/usr/local/bin/lzop -9 -U /usr/local/ciaos/logs/$Y/$M/$D*.log
dy=`date -d "-10 day" +%Y`
dm=`date -d "-10 day" +%m`
dd=`date -d "-10 day" +%d`
delgz=/usr/local/ciaos/logs/$dy/$dm/$dd.*gz
rm -rf $delgz 2>/dev/null
dellzo=/usr/local/ciaos/logs/$dy/$dm/$dd.*lzo
rm -rf $dellzo 2>/dev/null