zoukankan      html  css  js  c++  java
  • CentOS 下用的是lnmp 的包配置Nginx 下的CI伪静态(搞爽了)

    server
            {
                    listen       80;
                    server_name cy.com;
                    index index.html index.htm index.php default.html default.htm default.php;
                    root  /home/wwwroot/cy;
    
                    location / {
                          if (-e $request_filename) {
                                    break;
                            }
                 if (-f $request_filename) {
                      expires max;
                      break;
                   }
    if (!-e $request_filename) { rewrite ^/(.*)$ /index.php/$1 last; } } # include ci.conf; location ~ .*.(php|php5)?$ { try_files $uri =404; fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_index index.php; include fcgi.conf; } location /index.php { fastcgi_pass unix:/tmp/php-cgi.sock; fastcgi_param SCRIPT_FILENAME /home/wwwroot/cy/index.php; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_split_path_info ^(.+.php)(.*)$; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fcgi.conf; } # location ~ /index.php/ { # fastcgi_pass unix:/tmp/php-cgi.sock; # fastcgi_index index.php; # include fcgi.conf; # } location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*.(js|css)?$ { expires 12h; } access_log off; }

    在Nginx下通过ci框架开发项目时,发现ci框架在nginx下是不能运行的,在网络上搜索了相关资料后可通过修改相关配置实现nginx支持PHP的ci框架。

    1、修改ci框架的配置文件 config/config.php
    修改$config['uri_protocol']值
    改为:

    $config['uri_protocol'] = 'PATH_INFO';

    2、修改nginx配置文件,在SERVER段中添加如下代码:

    location /index.php{
        fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_param SCRIPT_FILENAME /home/wwwroot/index.php;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_split_path_info ^(.+.php)(.*)$;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        include fcgi.conf;
    }

    如果有多个应用,如:后台应用,可以多加一段以上代码,并修改相应入口文件:

    location /admin.php{
        fastcgi_pass  unix:/tmp/php-cgi.sock;
        fastcgi_param SCRIPT_FILENAME /home/wwwroot/admin.php;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_split_path_info ^(.+.php)(.*)$;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        include fcgi.conf;
    }

    第一次访问的时候,我是这么访问

    http://cy.com/index.php/admin

    我有一个admin 的目录

    ---------------------------------

    如果出现了 Access Denied

    ----------------------------------------------

    请检查

    1、 php.ini(/etc/php5/cgi/php.ini)的配置中这两项
    cgi.fix_pathinfo=1  (这个是自己添加的)

  • 相关阅读:
    Java学习笔记之——封装
    Java学习笔记之——String和Arrays常用方法
    Flask+uwsgi+virtualenv环境配置
    shell常用函数封装-main.sh
    APK模式下,epg版本升级,需要做同步
    cboss升级顺序
    Mariadb使用xtrabackup工具备份数据脚本
    Seaweedfs-启动脚本
    运营商-工作内容调整记录
    MSC服务器-主从检测脚本-check_server_state.sh
  • 原文地址:https://www.cnblogs.com/jackluo/p/3185910.html
Copyright © 2011-2022 走看看