如何 运行 在 Nginx 上打开日志系统 (OJS)

How to run Open Journal System (OJS) on Nginx

我的服务器 Nginx 配置有问题。

php 上部署的应用程序是 OJS, a journal management and publishing system, originally developed to run on Apache1。 尽管 OJS 可以在 Nginx 上运行而无需进一步的特定服务器配置,但必须对 OJS 主配置设置(disable_path_info ON)进行微小更改,因为 Nginx 似乎不支持 PATH_INFO。然而,这会生成不漂亮的 URL,这反过来会导致某些 OJS features/plugins 无法正常工作,或者根本无法工作 2

我发现一些帖子是人们分享这方面的成功经验:

我是 运行 Ubuntu 18.04.1 LTS (GNU/Linux 4.15.0-42-generic x86_64) 在 Laravel Forge 配置的 Digital Ocean 帐户上。

我找不到将这些代码块(上面链接示例中的代码块)与我的默认 Nginx 设置结合起来的方法。

# 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/*;

我希望将 OJS 配置文件改回 disable_path_info 关闭并能够在 Nginx 上使用漂亮的 URL 而 运行。

如有任何帮助,我们将不胜感激!

我刚刚在 OJS3 论坛上看到你的留言。

对于 NginX,试试这个配置

# 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?$args;
    }

    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)(.*)$ {
        set $path_info $fastcgi_path_info;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param PATH_TRANSLATED $document_root$path_info;

        if (!-f $document_root$fastcgi_script_name) {
            return 404;
        }
        include fastcgi_params;

        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

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

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

一定要设置:
1. PHP-FPM 中的 cgi.fix_pathinfo=1(可能在 /etc/php/7.2/fpm/php.ini 中)。
2. security.limit_extensions = .php 在您的 FPM 池配置文件中(在 /etc/php/7.2/fpm/pool.d/your_site.conf 中)
3. disable_path_info = Off(在 OJS config.inc.php)

重启PHP-FPM和NginX服务。然后,如果它有效,请阅读有关 NginX IF 和 'cgi.fix_pathinfo'.

的弊端

只需确认对我的情况有用的东西 运行 在 Nginx 上成功运行 OJS(Ubuntu 18.04.1 LTS 在由 Laravel Forge 配置的 Digital Ocean 帐户上)包括:

1)修改cgi.fix_pathinfo=1 in PHP-FPM(in /etc/php/7.2/fpm/php.ini)

2) 取消注释(启用)security.limit_extensions = .php(在/etc/php/7.2/fpm/pool.d/www.conf)

3) 更改 disable_path_info = 关闭(在 OJS config.inc.php 中)。

4) 将 nginx 配置替换为:

# 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)(.*)$ {
     set $path_info $fastcgi_path_info;
     fastcgi_split_path_info ^(.+\.php)(.*)$;
     fastcgi_param   PATH_INFO               $path_info;
     fastcgi_param   PATH_TRANSLATED         $document_root$path_info;
     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/*;

5) 最后重启服务(service php7.2-fpm restart AND sudo service nginx restart)。