且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用CodeIgniter 3和NGINX的控制器文件出现404错误

更新时间:2022-11-27 19:24:40

在Nginx中使用此配置(来源):

Use this config in Nginx (Source):

 server {
            server_name domain.tld;

            root /your/web/root/path
            index index.html index.php;

            # set expiration of assets to MAX for caching
            location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
                    expires max;
                    log_not_found off;
            }

            location / {
                    # Check if a file or directory index file exists, else route it to index.php.
                    try_files $uri $uri/ /index.php;
            }

            location ~* \.php$ {
                    fastcgi_pass 127.0.0.1:9000;
                    include fastcgi.conf;
            }
    }

此外,您还需要在php-fpm配置中进行更改.编辑此文件:

Also you need to make a change in your php-fpm config. Edit this file:

/etc/php/7.0/fpm/pool.d/www.conf

查找此行:

listen = /run/php/php7.0-fpm.sock

更改为此:

listen = 127.0.0.1:9000

此更改应该可以解决您的问题.

This changes should solve your issue.