对于各种语言常用的框架,Nginx 在官方的 Wiki 页面的 入门 部分提供了示例配置文件。具体可以参考这个页面的 Pre-canned Configurations 部分,这里列出了各种框架。
直接点击 Codeigniter 进入 Codeigniter 框架的设置页面:
配置完成后,需要设置 codeIgniter 的 config.php 文件,内容如下:
$config['base_url'] = "http://domain.tld/"; $config['index_page'] = ""; $config['uri_protocol'] = "REQUEST_URI";也可以选用下面这种配置,同样适用于生产环境。这里只需要删除 config.php 文件中的 “index.php”:
$config['base_url'] = ""; $config['index_page'] = ""; $config['uri_protocol'] = "AUTO"; server { listen 80; server_name localhost; root /var/www/html/ci; autoindex on; index index.php; location / { try_files $uri $uri/ /index.php; location = /index.php { fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME /var/www/html/ci$fastcgi_script_name; include fastcgi_params; } } location ~ \.php$ { return 444; } }Nginx 配置:
server { listen 80; server_name local.cn; root /home/szhz; location / { if (-f $request_filename) { expires max; break; } if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; } index index.php; autoindex off; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } }CodeIgniter 配置:
$config['base_url'] = ''; $config['index_page'] = 'index.php'; $config['uri_protocol'] = 'REQUEST_URI';转载于:https://www.cnblogs.com/kika/p/10851586.html
相关资源:数据结构—成绩单生成器