Linux下Nginx配置示例及Nginx/PHP/MySQL简单管理脚本

1,Linux下Nginx主配置文件及FasgCGI配置文件
nginx.conf
==========================
user www www;
worker_processes      8;
worker_rlimit_nofile 51200;

error_log /root/workspace/logs/nginx/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;

pid        logs/nginx.pid;


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" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';

#access_log logs/access.log main;

sendfile        on;
tcp_nopush      on;
tcp_nodelay     on;

#keepalive_timeout 0;
keepalive_timeout 65;

gzip on;
gzip_types         text/plain text/css application/x-Javascript application/xml;

fastcgi_connect_timeout   500;
fastcgi_read_timeout      300;
fastcgi_send_timeout      300;
fastcgi_intercept_errors   on;

server {
listen       80;
server_name www.linuxidc.net;
index        index.html index.php;
root         /root/workspace/htdocs;

access_log   /root/workspace/logs/nginx/host.access.log main;

location ~ \.php$ {
fastcgi_pass   127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include        fastcgi_params;
}

location ~ \.(gif|jpg|jpeg|png|swf|bmp)$ {
expires        30d;
}

location ~ \.(css|js)$ {
expires        1h;
}

        #charset koi8-r;

#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   html;
#}

# proxy the PHP script to Apache listening on 127.0.0.1:80
#
#localtion ~ \.php$ {
#    proxy_pass http://127.0.0.1;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#    deny all;
#}
   }

location ~ \.php$ {
fastcgi_pass   127.0.0.1:9000;
fastcgi_index index.php;
include        fastcgi_params;
}

location ~ \.(gif|jpg|jpeg|png|swf|bmp)$ {
expires 30d;
}

location ~ \.(css|js)$ {
expires 1h;
}
}

    #another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
#    listen       8000;
#    listen       somename:8080;
#    server_name somename alias another.alias;

#    location / {
#        root   html;
#        index index.html index.htm;
#    }
#}


# HTTPS server
#
#server {
#    listen       443;
#    server_name localhost;

#    ssl                  on;
#    ssl_certificate      cert.pem;
#    ssl_certificate_key cert.key;

#    ssl_session_timeout 5m;

#    ssl_protocols SSLv2 SSLv3 TLSv1;
#    ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
#    ssl_prefer_server_ciphers   on;

#    location / {
#        root   html;
#        index index.html index.htm;
#    }
#}

}

相关推荐