No media on Fresh Wordpress install

My YunoHost server

Hardware: VPS from Vultr
YunoHost version: Fresh install of 4.3.6.2
I have access to my server : Through SSH | through the webadmin
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no

Description of my issue

I just installed wordpress on yunohost on diymedia.cc

When I upload media, it does not display. I get a 404 when trying to access it directly through the browser. I can view it over SFTP and verify that it exists.

I did a clean install of Debian 10, a clean install of yunohost, and a clean install of wordpress, but the issue persists.

Any tips?


From the CLI, can you check the ownership of these files with the following command? ls -la <path_to_media>

ls -la /var/www/wordpress/wp-content/2022/03/

drwxr-x--- 2 wordpress wordpress    4096 Mar 25 20:12 .
drwxr-x--- 3 wordpress wordpress    4096 Mar 25 20:11 ..
-rw-r----- 1 wordpress wordpress   65739 Mar 25 20:12 20220324_162225-1024x576.jpg
-rw-r----- 1 wordpress wordpress    5867 Mar 25 20:12 20220324_162225-150x150.jpg
-rw-r----- 1 wordpress wordpress  124951 Mar 25 20:12 20220324_162225-1536x864.jpg
-rw-r----- 1 wordpress wordpress  130783 Mar 25 20:12 20220324_162225-1568x882.jpg
-rw-r----- 1 wordpress wordpress  212698 Mar 25 20:12 20220324_162225-2048x1152.jpg
-rw-r----- 1 wordpress wordpress   10628 Mar 25 20:11 20220324_162225-300x169.jpg
-rw-r----- 1 wordpress wordpress   42624 Mar 25 20:12 20220324_162225-768x432.jpg
-rw-r----- 1 wordpress wordpress 2505083 Mar 25 20:11 20220324_162225.jpg
-rw-r----- 1 wordpress wordpress  344882 Mar 25 20:11 20220324_162225-scaled.jpg

ls -la /var/www/wordpress/wp-content/uploads/

drwxr-x--- 3 wordpress wordpress 4096 Mar 25 20:11 .
drwxr-x--- 6 wordpress www-data  4096 Mar 25 20:18 ..
drwxr-x--- 3 wordpress wordpress 4096 Mar 25 20:11 2022


It looks like the permissions are not quite the right ones. Let’s fix that and see if that’s better:

sudo su
final_path=/var/www/wordpress
chmod 750 "$final_path"
chmod -R o-rwx "$final_path"
chown -R $app:www-data "$final_path"
chmod 400 "$final_path/wp-config.php"
chown $app:$app "$final_path/wp-config.php"

Then restart PHP-FPM: systemctl restart php7.3-fpm


Actually, you wrote

Do you mean you try to open something like https://yourdomain.tld/wordpress/2022/03/20220324_162225.jpg? If so, I’m not sure Wordpress would allow that. However, can you load the media in an post and see if they are displayed? If not, check your browser console and network dev tools to check what actual addresses end up with an error 404.

That worked.

These URLs did not load an image before. They do after updating permissions. Thank you.

Both load without issue.

I guess I should open a bug against the yunohost wordpress installer for setting the file permissions incorrectly?

It actually was already filed: Accessing uploaded files broken since PR 155 · Issue #156 · YunoHost-Apps/wordpress_ynh · GitHub

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.