Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Nginx configuration file


jessicana

Recommended Posts

I am using the Nginx configuration file as listed on nginx.com: https://www.nginx.com/resources/wiki/start/topics/recipes/oscommerce/

When I use:

fastcgi_pass 127.0.0.1:9000;

I get a bad gateway page 502 error, therefore I changed it to:

fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;

The site loads the home page but when I click on the links on the home page, I get 404 Not Found. For example, when I click: https://mydomai.com/catalog/sales , I get 404 not found page. 

Why is that?

Link to comment
Share on other sites

There should be documentation on this from OsCommerce. I searched the forum before I post here. Usually, the nginx configuration file is part of the nginx examples/recipes. 

Edited by jessicana
Link to comment
Share on other sites

Thank you for your help. I would not have seen this working without your help. Your configuration partially works and the following block has to be changed:

from: 

location / { 
index $yii_bootstrap; 
}

to:

location / {
index $yii_bootstrap;
try_files $uri $uri/ /$yii_bootstrap?$args;
}

I simply added the below line. Otherwise, I got 404 on certain pages:

try_files $uri $uri/ /$yii_bootstrap?$args;

I am testing my configuration and I will post a complete configuration file later this week on this page to help everyone. The fastcgi_pass on Ubuntu configuration is usually:

fastcgi_pass unix:/var/run/php/php8.x-fpm.sock;

where 8.x is the php version. 

Link to comment
Share on other sites

  • 3 months later...

Below is a complete Nginx configuration file that should work for you with OsCommerce x4:

server {
    listen 80;
    listen [::]:80;

    set $yii_bootstrap "index.php";

    root /var/www/example.com/html/;

    access_log /var/www/example.com/logs/access.log;
    error_log /var/www/example.com/logs/error.log;

    # Add index.php to the list if you are using PHP
    index index.html index.htm index.nginx-debian.html index.php;
    
    index       $yii_bootstrap;
    server_name example.com www.example.com;


    client_max_body_size 50m;
        charset utf-8;


        location /furniture {
        index $yii_bootstrap;
        try_files $uri $uri/ /furniture/$yii_bootstrap?$args;
        }

    location /printshop {
        index $yii_bootstrap;
        try_files $uri $uri/ /printshop/$yii_bootstrap?$args;
    }

    location /admin {
        index $yii_bootstrap;
        try_files $uri $uri/ /admin/$yii_bootstrap?$args;
    }

    location /b2b-supermarket {
        index $yii_bootstrap;
        try_files $uri $uri/ /b2b-supermarket/$yii_bootstrap?$args;
    }

    location /watch {
        index $yii_bootstrap;
        try_files $uri $uri/ /watch/$yii_bootstrap?$args;
    }

    location / {
        index $yii_bootstrap;
        try_files $uri $uri/ /$yii_bootstrap?$args;
    }

    location ~ \.php$ {

        if (!-f $request_filename) { return 404; }
        include fastcgi_params;

        fastcgi_pass unix:/var/run/php/php8.0-fpm.sock;
        fastcgi_index $yii_bootstrap;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param REDIRECT_STATUS 200;

    }


    #location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
    #    try_files $uri $uri/ =404;
    #}

    # pass PHP scripts to FastCGI server
    #
    #location ~ \.php$ {
    #    include snippets/fastcgi-php.conf;
    #
    #    # With php-fpm (or other unix sockets):
    #    fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    #    # With php-cgi (or other tcp sockets):
    #    fastcgi_pass 127.0.0.1:9000;
    #}


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

}

Please change:

1. example to your domain name.

2. php8.0-fpm.sock to your PHP version. For example, if you use 8.2, change this to become:

fastcgi_pass unix:/var/run/php/php8.2-fpm.sock;

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...