如何在Nginx上运行Open Journal System(OJS)

flvlnr44  于 2024-01-06  发布在  Nginx
关注(0)|答案(2)|浏览(336)

我的服务器的Nginx配置有问题。
它上部署的php应用程序是OJS,一个日志管理和发布系统,最初开发用于在Apache 1上运行。尽管OJS可以在Nginx上运行,而无需进一步的特定服务器配置,但OJS主配置设置的微小更改(disable_path_info ON)必须这样做,因为PATH_INFO似乎不支持Nginx。然而,这会生成不漂亮的URL,这反过来又会导致一些OJS特性/插件不符合规范,或者根本不能在2上工作。
我发现一些帖子是人们分享成功的经验:

我在Laravel Forge配置的Digital Ocean帐户上运行Ubuntu 18.04.1 LTS(GNU/Linux 4.15.0-42-generic x86_64)。
我找不到将这些合并代码块(上面链接中的示例)与我的默认Nginx设置结合起来的方法。

  1. # FORGE CONFIG (DO NOT REMOVE!)
  2. include forge-conf/evidenciaonojs.tk/before/*;
  3. server {
  4. listen 80;
  5. listen [::]:80;
  6. server_name evidenciaonojs.tk;
  7. root /home/forge/evidenciaonojs.tk/;
  8. # FORGE SSL (DO NOT REMOVE!)
  9. # ssl_certificate;
  10. # ssl_certificate_key;
  11. ssl_protocols TLSv1.2;
  12. 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;
  13. ssl_prefer_server_ciphers on;
  14. ssl_dhparam /etc/nginx/dhparams.pem;
  15. add_header X-Frame-Options "SAMEORIGIN";
  16. add_header X-XSS-Protection "1; mode=block";
  17. add_header X-Content-Type-Options "nosniff";
  18. index index.html index.htm index.php;
  19. charset utf-8;
  20. # FORGE CONFIG (DO NOT REMOVE!)
  21. include forge-conf/evidenciaonojs.tk/server/*;
  22. location / {
  23. try_files $uri $uri/ /index.php?$query_string;
  24. }
  25. location = /favicon.ico { access_log off; log_not_found off; }
  26. location = /robots.txt { access_log off; log_not_found off; }
  27. access_log off;
  28. error_log /var/log/nginx/evidenciaonojs.tk-error.log error;
  29. error_page 404 /index.php;
  30. location ~ \.php$ {
  31. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  32. fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
  33. fastcgi_index index.php;
  34. include fastcgi_params;
  35. }
  36. location ~ /\.(?!well-known).* {
  37. deny all;
  38. }
  39. }
  40. # FORGE CONFIG (DO NOT REMOVE!)
  41. include forge-conf/evidenciaonojs.tk/after/*;

字符串
我希望将OJS配置文件更改为disable_path_info Off,并能够在Nginx上运行时使用漂亮的URL。
在这方面的任何帮助将真正感谢!

cyvaqqii

cyvaqqii1#

我刚刚在OJS 3论坛上看到了你的留言。
对于NginX,请尝试此配置

  1. # FORGE CONFIG (DO NOT REMOVE!)
  2. include forge-conf/evidenciaonojs.tk/before/*;
  3. server {
  4. listen 80;
  5. listen [::]:80;
  6. server_name evidenciaonojs.tk;
  7. root /home/forge/evidenciaonojs.tk/;
  8. # FORGE SSL (DO NOT REMOVE!)
  9. # ssl_certificate;
  10. # ssl_certificate_key;
  11. ssl_protocols TLSv1.2;
  12. 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;
  13. ssl_prefer_server_ciphers on;
  14. ssl_dhparam /etc/nginx/dhparams.pem;
  15. add_header X-Frame-Options "SAMEORIGIN";
  16. add_header X-XSS-Protection "1; mode=block";
  17. add_header X-Content-Type-Options "nosniff";
  18. index index.html index.htm index.php;
  19. charset utf-8;
  20. # FORGE CONFIG (DO NOT REMOVE!)
  21. include forge-conf/evidenciaonojs.tk/server/*;
  22. location / {
  23. try_files $uri $uri/ /index.php?$args;
  24. }
  25. location = /favicon.ico { access_log off; log_not_found off; }
  26. location = /robots.txt { access_log off; log_not_found off; }
  27. access_log off;
  28. error_log /var/log/nginx/evidenciaonojs.tk-error.log error;
  29. error_page 404 /index.php;
  30. location ~ ^(.+\.php)(.*)$ {
  31. set $path_info $fastcgi_path_info;
  32. fastcgi_split_path_info ^(.+\.php)(.*)$;
  33. fastcgi_param PATH_INFO $path_info;
  34. fastcgi_param PATH_TRANSLATED $document_root$path_info;
  35. if (!-f $document_root$fastcgi_script_name) {
  36. return 404;
  37. }
  38. include fastcgi_params;
  39. fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
  40. fastcgi_index index.php;
  41. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  42. }
  43. location ~ /\.(?!well-known).* {
  44. deny all;
  45. }
  46. }
  47. # FORGE CONFIG (DO NOT REMOVE!)
  48. include forge-conf/evidenciaonojs.tk/after/*;

字符串
请务必设置:

  1. PHP-FPM中的cgi.fix_pathinfo=1(可能在/etc/php/7.2/fpm/php. ini中)。
    2./etc/php/7.2/fpm/pool.d/your_site.conf中的FPM池配置文件security.limit_extensions = .php
  2. disable_path_info = Off(在OJS中)
    重新启动PHP-FPM和NginX服务。然后,如果它工作,阅读NginX IF和'cgi.fix_pathinfo'的邪恶。
展开查看全部
cvxl0en2

cvxl0en22#

只是确认一下,在我的情况下,在Nginx上成功运行OJS是有用的(Ubuntu 18.04.1 LTS在Laravel Forge配置的Digital Ocean帐户上)包括:
1)在PHP-FPM中修改cgi.fix_pathinfo=1(在/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 = Off(在OJS中).
4)将nginx配置替换为:

  1. # FORGE CONFIG (DO NOT REMOVE!)
  2. include forge-conf/evidenciaonojs.tk/before/*;
  3. server {
  4. listen 80;
  5. listen [::]:80;
  6. server_name evidenciaonojs.tk;
  7. root /home/forge/evidenciaonojs.tk/;
  8. # FORGE SSL (DO NOT REMOVE!)
  9. # ssl_certificate;
  10. # ssl_certificate_key;
  11. ssl_protocols TLSv1.2;
  12. 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;
  13. ssl_prefer_server_ciphers on;
  14. ssl_dhparam /etc/nginx/dhparams.pem;
  15. add_header X-Frame-Options "SAMEORIGIN";
  16. add_header X-XSS-Protection "1; mode=block";
  17. add_header X-Content-Type-Options "nosniff";
  18. index index.html index.htm index.php;
  19. charset utf-8;
  20. # FORGE CONFIG (DO NOT REMOVE!)
  21. include forge-conf/evidenciaonojs.tk/server/*;
  22. location / {
  23. try_files $uri $uri/ /index.php?$query_string;
  24. }
  25. location = /favicon.ico { access_log off; log_not_found off; }
  26. location = /robots.txt { access_log off; log_not_found off; }
  27. access_log off;
  28. error_log /var/log/nginx/evidenciaonojs.tk-error.log error;
  29. error_page 404 /index.php;
  30. location ~ ^(.+\.php)(.*)$ {
  31. set $path_info $fastcgi_path_info;
  32. fastcgi_split_path_info ^(.+\.php)(.*)$;
  33. fastcgi_param PATH_INFO $path_info;
  34. fastcgi_param PATH_TRANSLATED $document_root$path_info;
  35. fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
  36. fastcgi_index index.php;
  37. include fastcgi_params;
  38. }
  39. location ~ /\.(?!well-known).* {
  40. deny all;
  41. }
  42. }
  43. # FORGE CONFIG (DO NOT REMOVE!)
  44. include forge-conf/evidenciaonojs.tk/after/*;

字符串
5)最后重启服务(service php7.2-fpm restart和sudo service nginx restart)。

展开查看全部

相关问题