Can't load images nor custom stylesheets from the public directory, gives 404

when upgrading ojs from 3.3.0.14 to 3.4.0.7 i encountered some problems (look extra info down) but i was able to solve them and the system worked fine except that the logo, the banner, the favicon and the stylesheet was not loaded and server responded with 404 in the console

i tried editing the whole ojs directory’s permissions to 777 but it didnt work
i tried reuploading the files but it didnt work
i tried updating some plugins, it didnt work
the only (recent) error im seeing in the logs is 404

i use ojs 3.4.0.7 on bootstrap theme (yes i tried to change to default and got the same issue)


image
image

Extra info:
during the update process i encountered two errors
1st one was because i rechanged the locale setting to en_US by mistake but i solved it with ease
2nd one: in the update page when i clicked on update ojs button it asked me to convers some tables engines to InnoDB which i did and the update proceeded

if there are any information im missing in the post please tell and i’ll provide asap, thx in advance <3

Hi @_E_L_0,

It is strongly advised not to use 777 permissions. We give advise on how to set permissions for OJS here: https://docs.pkp.sfu.ca/admin-guide/en/troubleshooting#configuring-file-permissions

As well as some general system security here: https://docs.pkp.sfu.ca/admin-guide/en/securing-your-system

Your console log indicates a 404 error, and that suggests checking your PHP error log, which tends to more helpful in pinpointing errors that are being experienced with OJS like this. Are you able to check your PHP error log and report back on errors found there?

-Roger
PKP Team

Hello @rcgillis thx for responding
the log file has a lot of ojs2: 404 Not Found
and some Server host "www.realpublishers.us" not allowed!
those are after and before the update
i couldnt upload nor copy the full log file because it’s too big
there is also this part of the log:

[20-Sep-2024 12:27:36 UTC] PHP Warning:  mkdir(): Permission denied in /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/classes/file/FileManager.php on line 418
[20-Sep-2024 12:27:36 UTC] UsageEventLog: Couldn't create /usageStats/usageEventLogs.
[20-Sep-2024 12:27:36 UTC] PHP Warning:  file_put_contents(/usageStats/salt): Failed to open stream: No such file or directory in /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/classes/statistics/PKPStatisticsHelper.php on line 159
[20-Sep-2024 12:27:36 UTC] PHP Warning:  filemtime(): stat failed for /usageStats/salt in /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/classes/observers/listeners/LogUsageEvent.php on line 212
[20-Sep-2024 12:27:36 UTC] PHP Warning:  file_put_contents(/usageStats/salt): Failed to open stream: No such file or directory in /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/classes/statistics/PKPStatisticsHelper.php on line 159
[20-Sep-2024 12:27:36 UTC] There was a problem reading the Geo database at /usageStats/IPGeoDB.mmdb. Error: The file "/usageStats/IPGeoDB.mmdb" does not exist or is not readable.
[20-Sep-2024 12:27:36 UTC] PHP Warning:  mkdir(): Permission denied in /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/classes/file/FileManager.php on line 418
[20-Sep-2024 12:27:36 UTC] UsageEventLog: Couldn't create /usageStats/usageEventLogs.
[20-Sep-2024 12:27:36 UTC] PHP Warning:  fopen(/usageStats/usageEventLogs/usage_events_20240920.log): Failed to open stream: No such file or directory in /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/classes/observers/listeners/LogUsageEvent.php on line 103
[20-Sep-2024 12:27:36 UTC] PHP Fatal error:  Uncaught TypeError: flock(): Argument #1 ($stream) must be of type resource, false given in /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/classes/observers/listeners/LogUsageEvent.php:104
Stack trace:
#0 /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/classes/observers/listeners/LogUsageEvent.php(104): flock()
#1 /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/classes/observers/listeners/LogUsageEvent.php(54): PKP\observers\listeners\LogUsageEvent->logUsageEvent()
#2 /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(441): PKP\observers\listeners\LogUsageEvent->handle()
#3 /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php(249): Illuminate\Events\Dispatcher->Illuminate\Events\{closure}()
#4 /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/lib/vendor/laravel/framework/src/Illuminate/Foundation/helpers.php(451): Illuminate\Events\Dispatcher->dispatch()
#5 /home/u884693246/domains/realpublishers.us/public_html/pages/index/IndexHandler.php(84): event()
#6 [internal function]: APP\pages\index\IndexHandler->index()
#7 /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/classes/core/PKPRouter.php(334): call_user_func()
#8 /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/classes/core/PKPPageRouter.php(278): PKP\core\PKPRouter->_authorizeInitializeAndCallRequest()
#9 /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/classes/core/Dispatcher.php(165): PKP\core\PKPPageRouter->route()
#10 /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/classes/core/PKPApplication.php(395): PKP\core\Dispatcher->dispatch()
#11 /home/u884693246/domains/realpublishers.us/public_html/index.php(21): PKP\core\PKPApplication->execute()
#12 {main}
  thrown in /home/u884693246/domains/realpublishers.us/public_html/lib/pkp/classes/observers/listeners/LogUsageEvent.php on line 104
[20-Sep-2024 12:27:39 UTC] ojs2: 404 Not Found

if there is a specific way to get you to look at the full log file let me know please

Hi @_E_L_0,

Thank you for your response. I will see if one of our team members can look at this when they have an opportunity.

-Roger
PKP Team

Hi @_E_L_0,

This issue…

Server host "www.realpublishers.us" not allowed!

…can be corrected by making sure the allowed_hosts setting in your config.inc.php configuration file is complete.

For the images and stylesheets problem, when you upgraded your installation, did you remember to bring along the contents of the public directory from your old installation?

Regards,
Alec Smecher
Public Knowledge Project Team

hello @asmecher, thank you for replying, let me take this chance to thank you for your hard work among various platforms, I always seen you there, you always helped me fix errors :)\

my allowed hosts setting is as follows:
allowed_hosts = "[\"realpublishers.us\"]"

and about the public directory, yes, i did keep its content by copying a backup before the update and reuploading it later after the update.

here is another thing i tried, i moved the favicon to the main ojs directory, changed it’s name, and tried changing the favicon src value from the page inspect but it gave the same error, this shows that the problem is in accessing the image and not really a 404 case.

again, thx for replying and keep up the hard work <3