nginx config issue with wordpress - wordpress

Normal Article are working Okay as https://dev.opoyi.com/webstories/hello-world/
but web-stories plugin links cause getting https://dev.opoyi.com/webstories/web-stories/my-first-web-story/ HTTP ERROR 500
Not found any error or log of nginx,fastcgi service
Nginx config of server
server {
listen 7879;
root /var/www/html;
server_name dev.opoyi.com;
location ~ ^/webstories {
alias /var/www/html;
index index.php;
location ~ .*(css|htc|js|bmp|jp?g|gif|ico|cur|png|swf|htm?|html)$ {
try_files $uri $uri/ /blog/index.php?$args;
}
fastcgi_split_path_info ^(.+\.php)(/.+)$;
set $path_info $fastcgi_path_info;
fastcgi_param PATH_INFO $path_info;
#add_header Content-Type text/plain;
#return 200 "$fastcgi_script_name,$fastcgi_path_info";
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
try_files $fastcgi_script_name /webstories/index.php =404;
}
}

Related

Nginx + Pretty Permalink issue

I am having an issue with WP pretty permalink and my nginx conf.
Homepage works good
Post = 404
WP-Admin = 404
Can you help me to resolve it?
Relevant nginx configuration (excludes ssl, gzip, headers, etc.):
server {
server_name sampledomain.com;
listen 443 ssl http2;
root /var/www/sampledomain/;
index index.php;
...
location ~ \.php$ {
try_files $uri $uri/ /index.php?$args;
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
Based on your config here, I think you need to add another location block at or before line 39.
For nginx, a web server aimed at high concurrency, high performance
and low memory usage, add the following location block within the
server block:
location / {
try_files $uri $uri/ /index.php?$args;
}
via WordPress Docs
Example:
server {
server_name sampledomain.com;
listen 443 ssl http2;
root /var/www/sampledomain/;
index index.php;
...
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri $uri/ /index.php?$args;
include fastcgi_params;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}

ZF3 on nginx only working for parent route

I have two apps. One is simple php file and the other is a zend framework app. I am using Nginx. It is working for simple php app which is accessible via example.com/.
For the ZF3 app, nginx is working only for parent route and none of the child routes are working. The parent route is accessible via example.com/products. I want nginx to handle route actions such as example.com/products/add, example.com/products/view which are already defined in module config.
nginx config
server {
listen *:80;
server_name example.com;
index index.html index.htm index.php;
access_log /var/log/nginx/simpleapp.access.log combined;
error_log /var/log/nginx/simpleapp.error.log;
root /var/www/simpleapp;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ^~ /products {
alias /var/www/ecom/public;
try_files $uri $uri/ /index.php$is_args$args;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
}
}
}
nginx log file
FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream
What works:
example.com/
example.com/products
What doesn't work:
example.com/products/add
example.com/products/view
example.com/products/categories
Do you really need two different declarations for very same php processing? I would stick with one and only differentiate the root using alias on /product for example:
server {
listen *:80;
server_name example.com;
index index.html index.htm index.php;
access_log /var/log/nginx/simpleapp.access.log combined;
error_log /var/log/nginx/simpleapp.error.log;
root /var/www/simpleapp;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location /products {
alias /var/www/ecom/public;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}

Nginx location for PHP files that do not exist

I have config(minimal):
server {
listen test.local:80;
server_name test.local;
server_name_in_redirect off;
location / {
root /data/www/test/public;
try_files $uri $uri/ /index.php?route=$uri&$args;
index index.html index.php;
}
location ~ \.php$ {
root /data/www/test/public;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www/test/public$fastcgi_script_name;
fastcgi_param ...
...
}
}
Thats work file for urls /help/ or /contacts/ etc… (all redirect to index.php with get variables).
But if url, for example, /help.php or contacts.php, and this files not exists, I have output:
File not found.
How update my Nginx config? I need URLs, for example:
/help.php => /index.php?route=/help.php
/contacts.php?foo=bar... => /index.php?route=/contacts.php&args=…
Here is simple config for 404 error page . Its custom 404 page.
error_page 404 /404.php;
location /404.php {
root /var/www/public_html;
allow all;
}
Last part
Important line is ========== try_files $uri =404;
location ~ .php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /var/www/public_html$fastcgi_script_name;
include fastcgi_params;
}

nginx configuration for Laravel 4

I am trying to setup my Laravel 4 project using nginx . Here is my nginx server block for laravel :
server {
listen 80;
root /home/prism/www/laravel/public;
index index.php index.html index.htm;
server_name example.com;
location / {
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
But my problem is , Its showing "404 not found" error for all other routes except the default one , that comes with default installation .
This is an NGINX Configuration i've used with Laravel 4 and Laravel 4.1 that works.
server {
listen 80;
server_name sub.domain.com;
set $root_path '/var/www/html/application_name/public';
root $root_path;
index index.php index.html index.htm;
try_files $uri $uri/ #rewrite;
location #rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.php;
include /etc/nginx/fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /\.ht {
deny all;
}
}
you could try this for location / { ... }
location / {
try_files $uri $uri/ /index.php?$query_string;
}
$query_string worked for me.

Server configuration file for nginx

I'm trying to install Symfony on my php5-fpm+nginx server on ubuntu.
When i'm entering to /web/app_dev.php it's displaying an error :
An error occurred while loading the web debug toolbar (404: Not
Found).
Do you want to open the profiler?
When i'm entering to profiler(/web/app_dev.php/_profiler/0db7ac) it tells:
No input file specified.
I know there is a problem with my server configuration file. Here it is:
server {
listen 80;
# listen [::]:80 ipv6only=on;
root /home/marker/Projects/stereoshoots/www;
access_log /home/marker/Projects/stereoshoots/logs/access.log;
server_name stereoshoots.local;
index index.php index.html index.htm;
location / {
autoindex on;
# try_files $uri $uri/ #rewrite;
try_files $uri $uri/ /index.php;
}
# location #rewrite {
# rewrite ^/(.*)$ /index.php?q=$1;
# }
location ~* \.(jpg|jpeg|gif|css|png|js|ico|xml|txt)$ {
access_log off;
expires 30d;
}
location = /favicon.ico {
return 204;
access_log off;
log_not_found off;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
What should i edit, to get symfony installed right?
Thanks!
I think the only thing left is to pass the uri to the index.php
try_files $uri $uri/ /index.php$request_uri
Do you really have index.php?
Try this:
index app_dev.php;
try_files $uri $uri/ #rewrite;
location #rewrite {
rewrite ^/(.*)$ /app_dev.php/$1;
}
location ~ \.php {
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SERVER_PORT 80;
fastcgi_param SERVER_NAME stereoshoots.local;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index app_dev.php;
}
Notice that I changed location ~ \.php$ to location ~ \.php

Resources