nginx 基本配置

来源:互联网 发布:java 301跳转 编辑:程序博客网 时间:2024/05/22 06:39
user www-data; #进程用户
worker_processes 4;
pid /run/nginx.pid;# 进程ID


events {
worker_connections 768;
# multi_accept on;
}


http {


sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;




include /etc/nginx/mime.types;
default_type application/octet-stream;




access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;


gzip on;
gzip_disable "msie6";






include /etc/nginx/conf.d/*.conf;
server {
listen 80 ;


root /var/www/html/cms/; #项目目录
# Make site accessible from http://localhost/
server_name www.yxzj520.com; #域名


location / {
                index  index.php; #首页 当用/访问时,定位到inex,.php并把参数呆过去
                try_files $uri/ /index.php?$args; 
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ { #处理.php的访问
# 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;
}


          if (!-f $request_filename) {
             rewrite ^/(.*)$ /index.php/$1 last;
         }
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
# location ~ /\.ht {
# deny all;
# }
}




}
0 0