|
发表于 2016-3-8 17:35:35
|
显示全部楼层
1,nginx基础配置:
主要的配置文件是 : nginx.conf, fastcgi_params,vhosts文件夹
nginx.conf:
user nobody nobody;
worker_processes 8;
worker_rlimit_nofile 65535;
error_log logs/error.log;
pid logs/nginx.pid;
events {
# use [ kqueue | rtsig | epoll | /dev/poll | select | poll ];
use epoll;
# web server : max_clients = worker_processes * worker_connections
# proxy server : max_clients = worker_processes * worker_connections / 4
worker_connections 8192;
}
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" $request_body '
'"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip off;
gzip_comp_level 5;
gzip_http_version 1.0;
gzip_min_length 1024;
gzip_buffers 4 8k;
gzip_types text/plain application/x-javascript text/css application/xml;
client_header_buffer_size 128k;
large_client_header_buffers 4 16k;
client_max_body_size 32m;
#fastcgi_connect_timeout 300;
#fastcgi_send_timeout 300;
#fastcgi_read_timeout 300;
#fastcgi_buffers 4 256k;
#fastcgi_busy_buffers_size 256k;
#fastcgi_buffer_size 128k;
# The following includes are specified for virtual hosts
include vhosts/*.conf;
#include vhosts/t0.xgame.uuzu.com.conf;
#include vhosts/default.conf;
}
80.conf
server {
listen 80 backlog=8192;
server_name tinlei.com;
root /data/code/ci;
index index.php;
charset utf-8;
keepalive_timeout 300;
access_log logs/80_access.log main;
#access_log off;
#include access_ctrl.conf;
#if (-d $request_filename)
#{
# rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
#}
#error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
#此处配置ci的路由机制
location / {
try_files $uri $uri/ /index.php;
}
location ~ .+\.(do)?$
{
fastcgi_pass unix:/dev/shm/php-fpm.sock;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffers 64 16k;
fastcgi_buffer_size 64k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ .+\.(php)?$
{
if ($request_filename ~* (.*)\.php) {
set $php_url $1;
}
if (!-e $php_url.php) {
return 404;
}
fastcgi_pass unix:/dev/shm/php-fpm.sock;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffers 64 16k;
fastcgi_buffer_size 64k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_index index.php;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ .+\.(dat|sql|tgz|gz|tar|zip)?$
{
deny all;
}
location ~ /\.ht {
deny all;
}
}
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 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;
2,ci配置文件修改
application/config.php 修改:
$config['index_page'] = ''; #默认值为 index.php
$config['uri_protocol'] = 'REQUEST_URI'; #默认值为 AUTO
links:
http://fbsender.github.io/php/2014/12/18/php-ci-nginx-config.html
https://www.nginx.com/resources/wiki/start/topics/recipes/codeigniter/
http://stackoverflow.com/questions/17798457/how-can-i-make-this-try-files-directive-work |
|