在mac上使用nginx配置codeigniter框架一直显示404的问题的一种方法(重启)

今天在mac上配置nginx+codeigniter的开发环境,在配置nginx的时候发生了奇怪的现象,就是http://localhost/cn/cgi(我的项目路径)总是显示404。我更改了无数次,看了大概几十篇博客,都未能解决这个奇怪的问题。今天特意把这个解决方案记下来,为的就是让自己以后遇到了能多一种思路:重启大法。我在下面贴出自己的nginx配置(当然问题不是出在nginx上,在这里贴出来只是给大家看看当时试了多少次~):

#user  nobody;
worker_processes  1;

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

pid  /var/run/nginx.pid;


events {
    worker_connections  1024;
}


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" '
    #                  '"$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 utf8;
        root  /usr/local/var/www/BackApi/frontend;

        location / {
            index index.html index.php;
        }   

         location ~ \.php($|/) {
            root  /usr/local/var/www/BackApi/frontend;        
            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;
            fastcgi_param    PATH_TRANSLATED    $document_root$fastcgi_path_info;
                include        fastcgi_params;       
 }

#       location / {
 #                       index  index.php;
  #             try_files $uri $uri/ /index.php?$uri&$args;
   #    }   

        #include enable-php-pathinfo.conf; 
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /index.php/$1 last;
            break;
        }   
#        access_log  /usr/local/nginx/logs/test.platform.access.log;
       # error_log  /usr/local/nginx/logs/test.platform.error.log;
    }

 # 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;
    #    }
    #}
    include servers/*;
}

是的,试了多种方式之后,无奈重启,发现错误竟然消失了。。

这里写图片描述

原来重启不是一个梗,可能mac和nginx之间兼容性有点问题,我的nginx服务并没有如我的意去重启,所以我的配置一直不能生效。
为什么记录下来呢,真的是有的时候还可以试一下这个方法,说不定你的问题就飞走了。。真的,我花了一天看这个东西,没想到是重启解决了它。如果朋友们试了网上其他的种种方法还是不行的话,试试重启吧。:)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值