0

Im trying to install codeigniter inside phplist and everything is running well in apache.

But its getting 404 when uploaded to live server which is using nginx.

I knew it must be the mod_rewrite problem, and trying google the config but no luck..

please help to fix the config for nginx where the codeigniter is inside the phplist

thanks in advance

Note : Services is subdirectory name for codeigniter files

here's my config

server {
listen 443 ssl http2;
#listen [::]:443 ssl;
include snippets/self-signed.conf;
include snippets/ssl-params.conf;
server_name _;
root /var/www/domain.domain/lists;
index index.php index.html index.htm;
location ~ [^/]\.php(/|$) {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            fastcgi_read_timeout 1200;
            proxy_connect_timeout 1200;
            proxy_send_timeout 1200;
            proxy_read_timeout 1200;
            send_timeout 1200;
}
location ~ /.ht {
    deny all;
}
location ~ /.well-known {
    allow all;
}
location /phpmyadmin {
    index index.php;
}
if (!-e $request_filename) {
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
    rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}


// ADDING this conf for codeigniter inside phplist but no luck
    location /services/ {
        alias  /var/www/domain.domain/lists/services/;
        try_files $uri $uri/ /services/index.php;
        
        location ~ \.php$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_index   index.php;
            fastcgi_pass    backend;
            include /etc/nginx/fastcgi_params;
            fastcgi_param   SCRIPT_FILENAME $request_filename;
        }
    }
}

server {
    listen 80;
    #listen [::]:80 ipv6only=on;
    server_name _;
    return 302 https://$server_name$request_uri;
}

and im getting this error

sudo nginx -t
nginx: [emerg] no port in upstream "backend" in /etc/nginx/sites-enabled/your.conf:52
nginx: configuration file /etc/nginx/nginx.conf test failed

HOW TO SOLVE!!

The problem was solved and what triggered the error is fastcgi_pass was set to "backend" where's in my case should set to "fpm-sock" location.

here's my final conf and the codeigniter run well.

server {
listen 443 ssl http2;
#listen [::]:443 ssl;
include snippets/self-signed.conf;
include snippets/ssl-params.conf;
server_name _;
root /var/www/domain.domain/lists;
index index.php index.html index.htm;
location ~ [^/]\.php(/|$) {
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            fastcgi_read_timeout 1200;
            proxy_connect_timeout 1200;
            proxy_send_timeout 1200;
            proxy_read_timeout 1200;
            send_timeout 1200;
}
location ~ /.ht {
    deny all;
}
location ~ /.well-known {
    allow all;
}
location /phpmyadmin {
    index index.php;
}
if (!-e $request_filename) {
    rewrite /wp-admin$ $scheme://$host$uri/ permanent;
    rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
    rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
}
location /services/ {
    alias  /var/www/domain.domain/lists/services/;
    try_files $uri $uri/ /services/index.php;
    
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_index   index.php;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        include /etc/nginx/fastcgi_params;
        fastcgi_param   SCRIPT_FILENAME $request_filename;
    }
}
}
server {
    listen 80;
    #listen [::]:80 ipv6only=on;
    server_name _;
    return 302 https://$server_name$request_uri;
}
4
  • Where did you define this upstream backend? Jun 25, 2020 at 11:56
  • Honestly i dont really know what it is use for...should i remove it or changw with something ? Jun 25, 2020 at 19:13
  • It must be set to point to php-fpm. Jun 25, 2020 at 19:19
  • well, it's done. thanks for notice the fpm-sock. just realized it...its done.. thank you @MichaelHampton Jun 25, 2020 at 20:46

0

You must log in to answer this question.

Browse other questions tagged .