ngnix 配置CI框架 与 CI的简单使用

ngnix 支持 CI框架
1、修改config.php

参考网址:https://www.chenyudong.com/archives/codeigniter-in-nginx-and-url-rewrite.html

2、 ci小样例

http://www.mamicode.com/info-detail-514033.html

控制器的默认配置文件: routes.php, 不修改默认为跳转到welcome控制器

3、修改CI为子目录

https://yq.aliyun.com/articles/44948

我的ngnix.conf样例:

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

http {

    autoindex on;# 显示目录
    autoindex_exact_size on;# 显示文件大小
    autoindex_localtime on;# 显示文件时间
        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;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   D:/wnmp/www;
            #root   D:/wnmp/www/framework/CodeIgniter-3.1.0;
            index  index.html index.htm index.php;

            try_files $uri $uri/ /index.php?$query_string;
        }

        location /CI/ {
            root   D:/wnmp/www;
            index  index.html index.htm index.php;

            try_files $uri $uri/ /index.php?$query_string;

         }
        location /CI/index.php {

            root   D:/wnmp/www;

            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;

            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_param PATH_INFO $fastcgi_path_info;
            fastcgi_param  SCRIPT_FILENAME   $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        #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 scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root   D:/wnmp/www;
            #root D:/wnmp/www/framework/CodeIgniter-3.1.0;

            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info ^(.+\.php)(.*)$;
            fastcgi_param   PATH_INFO $fastcgi_path_info;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

        # deny access to .htaccess files, if Apache‘s document root
        # concurs with nginx‘s one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

    # 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 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}
时间: 2024-12-21 15:33:59

ngnix 配置CI框架 与 CI的简单使用的相关文章

三、CI框架之一个最简单的页面

一.在CI框架里面的controllers <?php defined('BASEPATH') OR exit('No direct script access allowed'); class Welcome extends CI_Controller { public function index() { //显示welcome_message.php文件 $this->load->view('welcome_message'); } } 二.在view里面 <?php def

CI框架入门中的简单MVC例子

最简单的CI模型: 注意:模型需要用到数据库 配置文件在appcation/config.php 这里我们要用到数据库,需要将databases.php中的 相关参数填写一下,具体不再赘述. 直接进入主题: MVC: 1.首先谈"M" 模型 CI中的模型存放在application/models文件夹里 命名规则是:类名_model.php 文件中只包含一个类: 如: class Nb_model extends CI_Model { public function __constru

CI框架--事务

CI框架--事务 CI框架中事务封装的很完善,使用起来很简单 1.不开启事务 1 2 3 4 //不开启事务  前两个sql 能够执行成功,第三个执行失败 $this->device_model->addForCamera(1, '爱三123', '2016122903', 0); $this->device_model->setStateInDevices(1, array(2)); $this->device_model->addForCamera(1, '爱三12

最简单的CI框架入门示例--数据库取数据

这个写给初学者看,这是最简单可以调通的例子,网上很多例子其实初学者本地跑不通,缺这少那. 1.下载CI框架(自己找) 2.配置 database.php配置:    为数据库服务器设置 connection 参数: $db['default']['hostname'] = "your-db-host"; $db['default']['username'] = "your-username"; $db['default']['password'] = "y

【转】最简单的CI框架入门示例--数据库取数据

1.下载CI框架(自己找) 2.配置 database.php配置:    为数据库服务器设置 connection 参数: 源码打印? $db['default']['hostname'] = "your-db-host"; $db['default']['username'] = "your-username"; $db['default']['password'] = "your-password"; $db['default']['dat

ci框架简单出现的错误[Undefined property: MContacts::$db]

出现这样的错误时说明自己忘记加载数据库了, application/config/aotuload.php     $autoload['libraries'] = array('database'); ci框架简单出现的错误[Undefined property: MContacts::$db]

apache php 配置 CI 框架

声明:配置域名需要用到  httpd.conf  httpd_vhosts.conf  (apache) 中两个文件 和   hosts (C:\Windows\System32\drivers\etc)  ****** 一  LoadModule rewrite_module modules/mod_rewrite.so   二    Include conf/extra/httpd-vhosts.conf  ****** 一  是开启重写地址模块   二 是开启引用httpd-vhosts.

Nginx配置CI框架问题(Linux平台下Centos系统)

CI框架:官方文档 http://codeigniter.org.cn/user_guide/index.html CI框架的数据流程图如下: 其中:index.php作为入口文件,在安装好CI框架后,index.php文件一般放置在Nginx服务器(其他服务器相同)所配置的web根目录下,Nginx配置文件在 xxx/nginx/conf/nginx.conf文件中,其中xxx为安装路径,如配置.php的解析文件可用如下模板: 1 server { 2 listen 80; // 监听的端口

Ajaxupload插件超级简单使用(php的ci框架)

                     Ajaxupload简单使用  友情提示:1.蓝色文字为必修改内容.2.#字符后面是解释该代码段的主要内容  备注: 该实例是用php的ci框架直接接收图片并保存 1. 引用AjaxUpload.js文件 #public/js/ajaxupload.js ajaxupload插件的文件位置 <script tyep="text/javascript" src="public/js/ajaxupload.js">&