Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

gabeLon's avatar

How to deal with Nginx config to run an app (OJS) developed for Apache

I am having trouble with the appropriate Nginx configuration of my server.

The deployed php app on It is OJS, a journal management and publishing system, originally developed to run on Apache1. Although OJS may runs on Nginx without further specific server configuration, a minor change on the OJS main config settings (disable_path_info ON) must be done because PATH_INFO doesn't seem to be supported by Nginx. However that generate non pretty URLs, which in turn cause some OJS features/plugins to work out of specifications, or not to work at all2.

I found some posts were people share successful experiences on that:

https://coolpandaca.wordpress.com/2012/12/07/migrate-ojs-to-nginx-from-apache

https://forum.pkp.sfu.ca/t/ojs3-on-nginx-php7-0-fpm/28590

http://inetholic.blogspot.com/2013/02/ojs-and-nginx.html

https://www.snip2code.com/Snippet/305514/nginx-configuration-for-OJS-on-an-aegir-

I am running Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-42-generic x86_64) on a Digital Ocean account configured by Laravel Forge.

I couldn't find the way to combine this blocks of code (the ones at examples on above links) with mine default Nginx settings.

FORGE CONFIG (DO NOT REMOVE!)

include forge-conf/evidenciaonojs.tk/before/*;

server { listen 80; listen [::]:80; server_name evidenciaonojs.tk; root /home/forge/evidenciaonojs.tk/;

# FORGE SSL (DO NOT REMOVE!)
# ssl_certificate;
# ssl_certificate_key;

ssl_protocols TLSv1.2;
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384;
ssl_prefer_server_ciphers on;
ssl_dhparam /etc/nginx/dhparams.pem;

add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";

index index.html index.htm index.php;

charset utf-8;

# FORGE CONFIG (DO NOT REMOVE!)
include forge-conf/evidenciaonojs.tk/server/*;

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt  { access_log off; log_not_found off; }

access_log off;
error_log  /var/log/nginx/evidenciaonojs.tk-error.log error;

error_page 404 /index.php;

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

location ~ /\.(?!well-known).* {
    deny all;
}

}

FORGE CONFIG (DO NOT REMOVE!)

include forge-conf/evidenciaonojs.tk/after/*; I expect to change back OJS config file to disable_path_info Off and be able to use pretty URL while running on Nginx.

Any help on this will be truly appreciated!

0 likes
0 replies

Please or to participate in this conversation.