在nginx上配置codeigniter [英] configuring codeigniter on nginx
问题描述
我有我的codeigniter代码,并且我在本地主机上设置了nginx服务器.但是未显示codeigniter代码.显示所有页面的404 not found错误. 我四处搜寻,发现编辑/etc/nginx/sites-available/default是关键.
I have my codeigniter code and I have setup nginx server on localhost. But codeigniter code doesn't show up. Shows 404 not found error for all pages. I googled around and came to know that editing /etc/nginx/sites-available/default was the key.
这是我在谷歌搜索文件后添加的代码,请告诉我我哪里出错了,还需要添加什么.我是编辑此类文件的完全新手.我的项目代码在"usr/share/nginx/html/krshop"中. 谢谢!!
Here is the code I added after googling to the file, please tell me where am I wrong and what else needs to be added. I am a complete newbie to editing such files. My code for the project is in 'usr/share/nginx/html/krshop'. Thanxx!!
server {
server_name localhost;
root /usr/share/nginx/html/;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php;
}
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {
expires 15d;
}
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html/index.php;
fastcgi_param REQUEST_URI $request_uri;
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_pass unix:/var/run/php5-fpm.sock;
}
}
推荐答案
可能是这两个链接解决了您的问题,像这样的问题仍未解决
May be these two links solves your problem,question like this are unsolved
http://www.farinspace.com/codeigniter-nginx-rewrite-rules /
https://gist.github.com/lynxluna/1050850
这篇关于在nginx上配置codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!