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;
}
}
Related
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;
}
}
I am trying to have 2 websites running on the same adress,
I want everything request on my.website.com/test_slim and every my.website.com/test_slim/anything/following to be directed on /var/www/html/test_slim/src/public/index.php.
I want everything else (my.website.com/, my.website.com/foo, my.website.com/bar/baz ...) to be served as normal PHP files in /var/www/html/whatever/file/according/to/url/index.php
Fow now, this are my server configurations :
In /etc/nginx/site-enabled/my-default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}
In /etc/nginx/sites-enabled/test_slim
server {
listen 80;
server_name _;
index index.php;
error_log /var/www/html/test_slim/error.log;
access_log /var/www/html/test_slim/access.log;
root /var/www/html/test_slim/src/public;
location /test_slim/ {
try_files $uri /index.php$is_args$args;
}
location ~ \.php {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi.conf;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_index index.php;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
}
But what I actually get is :
Request on localhost/ execute /var/www/html/index.html as wanted.
Request on localhost/toto execute /var/www/html/toto/index.html as wanted.
Request on localhost/test_slim downloads the /var/www/html/test_slim/src/public/index.pxp
Request on localhost/test_slim/hello returns us a Nginx error page (404 if hello folder doesn't exist, 403 if it does).
Request on localhost/test_slim/src/public/ exectute the /var/www/html/test_slim/src/public/index.php file.
I have the following nginx config for multiple root (html/web is default, html/pma is additional route):
server {
listen 443 http2 ssl;
listen [::]:443 http2 ssl;
server_name website.com;
server_tokens off;
root /usr/share/nginx/html/web;
index index.php;
location / {
try_files $uri /index.php?$args;
}
location ^~ /pma {
root /usr/share/nginx/html;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
So, by default /html/web/index.php is opened, however website.com/pma opens /html/pma/, where pma is PHPMyAdmin.
The problem is:
PHPMyAdmin authentification form redirects to index.php. Therefore, when I write my credentials, it redirects me to /html/web/index.php! But should /html/pma/index.php. Even log out from PHPMyAdmin redirects to /html/web/index.php!
Could anyone suggest a better way of configuration?
I can see two errors in your configuration.
You try_files statement should end with /index.php or =404, not both! See this document for details.
The nested location ~ \.php$ block will never be consulted. The outer location ~ \.php$ block take precedence. You can solve this problem by using the ^~ modifier on the surrounding prefix location. See this document for details. For example:
location ^~ /pma {
...
location ~ \.php$ {
...
}
}
location ~ \.php$ {
...
}
My domain registrar's DNS hits my server and gets the nginx default page, so that's properly configured
I copied an nginx vhost that is currently working, changed the server_name and the name of the conf file and nothing else.
Diff:
diff 701sm.club.conf drz400.info.conf
3c3
< server_name www.701sm.club 701sm.club;
---
> server_name www.drz400.info drz400.info;
then I restarted nginx.
Here is the entire non-functioning vhost:
server {
listen 80;
server_name www.701sm.club 701sm.club;
index index.php index.html index.htm;
access_log /var/www/drz400.info/logs/access.log;
error_log /var/www/drz400.info/logs/error.log;
location / {
root /var/www/drz400.info/production;
}
location ~ \.php$ {
root /var/www/drz400.info/production;
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Both sites should hit my .../production/index.html, but only one does. What could be wrong here?
Please try the following code,
server {
listen 80;
server_name www.701sm.club 701sm.club;
index index.php index.html index.htm;
access_log /var/www/drz400.info/logs/access.log;
error_log /var/www/drz400.info/logs/error.log;
root /var/www/drz400.info/production;
location / {
try_files $uri /index.html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Just got curious about your log directive, you point out the log to /var/www/drz400.info/logs/error.log while your domain was www.701sm.club. If you access www.701sm.club, is there any error on your error.log ?
And what type of error was occurred ?
I am having a problem with my nginx (and php-fpm) virtual host configuration. The problem is all requests (except static files) return HTTP 500 (Internal Server Error)
Here is my nginx vh code
server {
listen 80;
root /var/www/somesite/public;
index index.php index.html index.htm;
server_name somesite.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
However when I serve using php's inbuilt development server everything works fine. FYI it's a laravel app
Thanks in advance