Linux下Nginx配置示例及Nginx/PHP/MySQL简单管理脚本[服务器安全]
本文“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;
#}
}
server {
listen 80;
server_name www.linuxidc.com;
index index.html index.php;
root /root/workspace/mysql;
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;
# }
#}
}fastcgi_params
========================================================================
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_FILENAME $document_root$fastcgi_script_name;
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 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;2,Nginx + PHP + MySQL简易管理Shell脚本
nginx
========================================================================
#!/bin/bash
function_start_nginx(){
printf "Starting Nginx ...\n"
以上是“Linux下Nginx配置示例及Nginx/PHP/MySQL简单管理脚本[服务器安全]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |