jessicana Posted April 8, 2023 Posted April 8, 2023 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? Quote
jessicana Posted April 8, 2023 Author Posted April 8, 2023 (edited) 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 April 8, 2023 by jessicana Quote
jessicana Posted April 10, 2023 Author Posted April 10, 2023 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. Quote
jessicana Posted July 16, 2023 Author Posted July 16, 2023 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; Smoky Barnable 1 Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.