I have a small shop setup using Woocommerce on Wordpress. My own VPS on nginx.
Everything was working fine but a few days ago ago Ajax is not working on checkout page.
I tried every possible way woocommerce support http://docs.woothemes.com/document/endless- loadingspinner-on-the-checkout-page/
Chrome console saying this:
https://example.com/?wc-ajax=get_refreshed_fragments Failed to load
resource: the server responded with a status of 405 (Not Allowed)
So what I have found is when I load this https://example.com/?wc-ajax=get_refreshed_fragments it goes to homepage and not loading ajax. And when I load full URLs given below it loads well.
https://example.com/index.php?wc-ajax=get_refreshed_fragments
https://example.com/checkout/?wc-ajax=get_refreshed_fragments
Below is the block file for the site in question:
server {
listen 80;
server_name example.com www.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl spdy;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
server_name example.com www.example.com;
root /home/user/example.com/public/;
index index.php;
access_log /home/user/example.com/logs/access.log;
error_log /home/user/example.com/logs/error.log;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ /.well-known {
allow all;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
# With php5-fpm: fastcgi_pass
#unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
I would like woocommerce to call wc-ajax=get_refreshed_fragments using full path. Any idea or suggestion for nginx config or any php/ajax workaround would be helpful.
try to remove the
try_files $uri =404;
in the php location.
and disable all plugins you have one by one.
are you mixing www.example.com and example.com?
Related
I have put a Laravel 8 application on a AWS t2.nano Linux AMI ec2 instance. I would like to start up front by saying I have been at this for about a day now. I have tried a few configurations.
Here's some configurations I have tried:
The default nginx config file from the Laravel 8 documentation
https://laravel.com/docs/8.x/deployment#nginx
Another very similar stackoverflow question referenced here
Laravel on nginx says 404 for all routes except index
At the end of the day, I cannot get it to work properly. My index page loads, but any of the other routes end up at a 404 page. You can view the application here.
https://technology.dvemedia.com/
So here are some tech specs and the current state of my conf file.
Laravel - 8
PHP - 7.4
NGINX - 1.12.2
# HTTP
server {
listen 80;
listen [::]:80;
server_name technology;
return 301 https://$host$request_uri; # Redirect to www
}
server {
listen 80;
listen [::]:80;
server_name technology.dvemedia.com;
root /var/www/html/technology/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fixes timeouts
fastcgi_read_timeout 600;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
What am I missing or doing wrong, because I cannot get it to route to save my life.
Try this:
## Nginx php-fpm Upstream
upstream dvemedia {
server unix:/var/run/php/php7.4-fpm.sock;
}
## Web Server Config
server
{
## Server Info
listen 80;
listen [::]:80;
server_name technology.dvemedia.com;
root /var/www/html/technology/public;
index index.html index.php;
## DocumentRoot setup
location / {
try_files $uri $uri/ #handler;
expires 30d;
}
## Disable .htaccess and other hidden files
location /. {
return 404;
}
## Rewrite all request to index
location #handler {
rewrite / /index.php;
}
## Execute PHP scripts
location ~ \.php$ {
try_files $uri = 404;
expires off;
fastcgi_pass dvemedia;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
and put all your optimisation/tweaks (like fastcgi_buffers ...) in fastcgi_params file
I made a bad assumption by thinking my php-fpm socket would stay the same. After looking at the directory structure, my socket for 7.4 ended up being here.
fastcgi_pass unix:/var/run/php-fpm/www.sock;
That actually fixed it and everything worked. I gave bad information when I wrote the path for my socket was actually this.
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
#Latheesan answer would most likely have worked had I had given the correct information, minus the spelling mistake of course.
So recently my company started running websites on nginx instead of apache. Our application makes use of codeigniter.
So after uploading the source code a lot of url's werent working and i managed to get everything to work for codeigniter.
But we have a part of the website that doesnt work and also isnt codeigniter its a piece of code by itself /simplesaml/module.php/saml/sp/saml2-acs.php/surfconext-uvt. It used to create simplesaml requests and login.
The config file right now is:
server
{
listen X.X.X.X:443 ssl http2;
server_name X;
access_log /var/log/nginx/domains/X.log;
access_log /var/log/nginx/domains/X.nl.bytes bytes;
error_log /var/log/nginx/domains/X.nl.error.log;
root /home/u10024/domains/X.nl/private_html;
index index.php index.html index.htm;
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ {
expires max;
log_not_found off;
}
location /simplesaml {
rewrite ^/simplesaml/(.*) /simplesamlphp/www/$1 break;
}
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$
{
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include /etc/nginx/fastcgi_params;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/nginx_limits.conf;
if (-f $request_filename)
{
fastcgi_pass unix:/usr/local/php71/sockets/u10024.sock;
}
}
ssl on;
ssl_certificate /usr/local/directadmin/data/users/u10024/domains/X.nl.cert.combined;
ssl_certificate_key /usr/local/directadmin/data/users/u10024/domains/X.nl.key;
include /usr/local/directadmin/data/users/u10024/nginx_php.conf;
include /etc/nginx/webapps.ssl.conf;
}
I know close to nothing about nginx and am struggling to understand what i need to do here... Some help would be highly appreciated.
I've been Googling this for a while but can't seem to find a solution.
At the moment I have a config file setup on Nginx to send all requests regardless of file extension to a single index.php file. However, it ignores requests ending with .php and will throw a 404 if it's not there or, try to execute it if it is.
How can I configure Nginx to send .php requests to the index.php file too so I can use it to handle all file requests, not just non-PHP files?
My config file currently looks like the following:
server {
listen 80;
listen 443;
ssl on;
ssl_certificate /somecrt.crt;
ssl_certificate_key /somekey.key;
root /sites/;
index index.php;
server_name somesite.net;
access_log /sites/logs/access.log;
error_log /sites/logs/error.log;
location ~ /\. { deny all; }
location / {
# First attempt to serve request as file, then
# as directory then fall back to index.php
try_files $uri $uri/ /index.php?$args;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
try_files $uri /index.php?$args =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
After some more Googling "nginx: Map single static URL to a PHP file" helped me figure out the solution. So the new config is now:
server {
listen 80;
listen 443;
ssl on;
ssl_certificate /somecrt.crt;
ssl_certificate_key /somekey.key;
root /sites/;
index index.php;
server_name somesite.net;
access_log /sites/logs/access.log;
error_log /sites/logs/error.log;
location ~ /\. { deny all; }
location / {
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
}
}
With this config, all requests will be sent to the single index.php.
Of course, this will include static files such as image files which will probably impact Nginx server performance. In that case, you might want to add another location block before it if you want to exclude certain kind of requests.
For example, to exclude jpgs and gifs:
location ~ \.(jpg|gif) {
try_files $uri =404;
}
Hi every one I am new to magento. I've been trying to install magento 1.9.0.0 on with nginx server on Ubuntu 14.04LTS but I can't get started. I can see default page see below
magento default page
but whenever I try to log in it, server fails with UNABLE TO CONNECT error.
here is my virtual host
server {
listen 80;
listen [::]:80;
server_name www.mymagento.com;
root /var/www/magento;
index index.php;
#need it to execute php
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
include fastcgi.conf;
}
}
I already tried other solution like updating core_config_data web/unsecure/base_url and web/secure/base_url they contain my base url.
I tried reloading cache. there is nothing in nginx log neiher.
Thank you for helping me :-)
You have nothing to redirect URIs to the Magento common front handler. As a minimum you should add:
location / {
try_files $uri $uri/ /index.php;
}
But I suggest that you check this site for more.
Hi as Richard SMITH said, my virtual host was missing some lines to somehow redirect to front handler. As I have just begin to use Nginx, I won't be able to explain each lines but after strugling with Nginx this config works for me (I also needed to add self signed certificate to config to make it work).
server {
listen 80;
listen [::]:80;
listen 443 default ssl;
server_name www.mymagento.com;
ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key;
root /var/www/magento;
index index.php;
location / {
index index.html index.php;
autoindex on;
#If missing pass the URI to Magento's front handler
try_files $uri $uri/ #handler;
expires max;
}
#need it to execute php
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
include fastcgi.conf;
}
## Magento uses a common front handler
location #handler {
rewrite / /index.php;
}
}
I've looked up a few topics on here around this, but none of the solutions I've found so far seem to work.
I have 3 boxes created via a Vagrantfile with puppet modules, which have nginx and php installed. I've created a simple webpage to output the host name statically, plus php info.
On the load balancer I have the following code for /etc/nginx/sites-available/127.0.0.1 (note this is now the default site and linked setup through my Vagrantfile)
# vagrant/puppet/modules/nginx/files/loadBalancer/127.0.0.1
upstream backend {
server 192.168.205.20; #ip of second machine
server 192.168.205.30; #ip of third machine
}
server {
listen 80;
server_name _;
root /var/www/app;
index index.php;
location / {
try_files $uri /index.php;
proxy_pass http://backend;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
The two additional hosts which host this web app, have the following file for their /etc/nginx/sites-available/127.0.0.1
# vagrant/puppet/modules/nginx/files/127.0.0.1
server {
listen 80;
server_name _;
root /var/www/app;
index index.php;
location / {
try_files $uri /index.php;
proxy_pass http://backend;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
However, this results in only one page coming up (the load balancers, it never alternates to the other two like it should).
I have also tried passing in the backend upstream as the fastcgi_pass but this causes a 502 bad gateway. Is there something I am misunderstanding as far how this should function? Any help would really be appreciated!