YunoHost-Apps / pixelfed_ynh

The federated image shareing service Pixelfed for YunoHost
https://pixelfed.org/
GNU Affero General Public License v3.0
44 stars 15 forks source link

Change php upload limit + explain it in the readme #120

Open lapineige opened 4 years ago

lapineige commented 4 years ago

See : https://github.com/YunoHost-Apps/pixelfed_ynh/issues/118#issuecomment-700513503

PHP default upload limit is too low¹ for Pixelfed default value. Also users could change Pixelfed value without any visible effect, because of PHP limit.

¹ it seems to be 2MB by default, which is limited for images and well too low for videos…

What needs to be done:

lapineige commented 3 years ago

@yalh76 do you think a simple php.ini file in /var/www/pixelfed would do the job ?

If that the case, I'll do the PR :)

yalh76 commented 3 years ago

I think it would be easier to reintegrate https://github.com/YunoHost/example_ynh/blob/master/conf/php-fpm.conf that i removed during php 7.1 to 7.3 upgrade

lapineige commented 3 years ago

Do we need that whole file ?

yalh76 commented 3 years ago

yes, to have a customized php-fpm.

lapineige commented 3 years ago

So we can't include only a few lines of it, we need the whole file ? (and to maintain it aligned with the standard one, including the case when we change php version) Then wouldn't it be simpler to have a php.ini file with the only 2 or 3 relevant lines ? Note: I don't know the implications in both cases, I'm not really into php.

yalh76 commented 3 years ago

So we can't include only a few lines of it, we need the whole file ? (and to maintain it aligned with the standard one, including the case when we change php version) Then wouldn't it be simpler to have a php.ini file with the only 2 or 3 relevant lines ? Note: I don't know the implications in both cases, I'm not really into php.

I don't know how to use a php.ini...

And usually there are few changes php-fpm.conf between php version

lapineige commented 3 years ago

From my understanding, adding a php.ini file one /var/www/pixelfed containing just the one or few lines needed does the job. It did in my case at least.

yalh76 commented 3 years ago

well in that case, feel free to do a PR for that ;)

lapineige commented 3 years ago

I think maybe someone from the @YunoHost-Apps/apps-group might know these things better than me: what would be your advise in that case ? php-fpm conf or "just" the php.ini file ?

yalh76 commented 3 years ago

client_max_body_size is now 50Mo but can be increase

https://github.com/YunoHost-Apps/pixelfed_ynh/blob/c9f256a0de081f46a25eafc781bd43ec238c3249/conf/nginx.conf#L14

mikail97 commented 3 years ago

The same thing is happening to me, where I find the file in which I can modify the size? Thanks in advance! @yalh76

lapineige commented 3 years ago

/etc/nginx/conf.d/pixelfed_domain.tld.conf/pixelfed.conf, or something like this.

That's the Nginx part, you might need to adjust php file too, probably located in /etc/php7.4/fpm/pool.d/pixelfed.ini or similar (sorry, I don't have the ability to check if that's very accurate right now…). There you can add those lines :

php_admin_value[upload_max_filesize] = 16M
php_admin_value[memory_limit] = 8M
php_admin_value[post_max_size] = 8M

(adjust the value to ones that fits your needs ;)

Then reload php service php-7.4-fpm reload, and you're done :)

mikail97 commented 3 years ago

/etc/nginx/conf.d/pixelfed_domain.tld.conf/pixelfed.conf, or something like this.

That's the Nginx part, you might need to adjust php file too, probably located in /etc/php7.4/fpm/pool.d/pixelfed.ini or similar (sorry, I don't have the ability to check if that's very accurate right now…). There you can add those lines :

post_max_size = 8M upload_max_filesize = 8M max_file_uploads = 20

(adjust the value to ones that fits your needs ;)

Then reload php service php-7.4-fpm reload, and you're done :)

I found two "pixelfed.conf" files in my system, but no one is "pixelfed.ini" /etc/nginx/conf.d/mydomain.xxx.d/pixelfed.conf /etc/php/7.3/fpm/pool.d/pixelfed.conf

If I add the lines of code that you told me in one of these two files or in both, when restarting the service, it does not restart.

lapineige commented 3 years ago

/etc/php/7.3/fpm/pool.d/pixelfed.conf

That's the one :) (I knew it wasn't .ini… :sweat_smile:)

If I add the lines of code that you told me in one of these two files or in both, when restarting the service, it does not restart.

What's the error ?

mikail97 commented 3 years ago

If I add the lines of code that you told me in one of these two files or in both, when restarting the service, it does not restart.

What's the error ?

If I add the three code lines you told me, and I reload php, I get a 502 (Bad Gateway) If I stop the service and I start it again (try to) I get this :

● php7.3-fpm.service - The PHP 7.3 FastCGI Process Manager
   Loaded: loaded (/lib/systemd/system/php7.3-fpm.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Sun 2021-07-04 15:06:02 EDT; 12s ago
     Docs: man:php-fpm7.3(8)
  Process: 10517 ExecStart=/usr/sbin/php-fpm7.3 --nodaemonize --fpm-config /etc/php/7.3/fpm/php-fpm.conf (code=exited, status=78)
  Process: 10518 ExecStopPost=/usr/lib/php/php-fpm-socket-helper remove /run/php/php-fpm.sock /etc/php/7.3/fpm/pool.d/www.conf 73 (code=exited, status=0/SUCCESS)
 Main PID: 10517 (code=exited, status=78)

Jul 04 15:06:02 mydomain.xxx systemd[1]: Starting The PHP 7.3 FastCGI Process Manager...
Jul 04 15:06:02 mydomain.xxx php-fpm7.3[10517]: [04-Jul-2021 15:06:02] ERROR: [/etc/php/7.3/fpm/pool.d/pixelfed.conf:21] unknown entry 'post_max_size'
Jul 04 15:06:02 mydomain.xxx php-fpm7.3[10517]: [04-Jul-2021 15:06:02] ERROR: Unable to include /etc/php/7.3/fpm/pool.d/pixelfed.conf from /etc/php/7.3/fpm/php-fpm.conf at line 21
Jul 04 15:06:02 mydomain.xxx php-fpm7.3[10517]: [04-Jul-2021 15:06:02] ERROR: failed to load configuration file '/etc/php/7.3/fpm/php-fpm.conf'
Jul 04 15:06:02 mydomain.xxx php-fpm7.3[10517]: [04-Jul-2021 15:06:02] ERROR: FPM initialization failed
Jul 04 15:06:02 mydomain.xxx systemd[1]: php7.3-fpm.service: Main process exited, code=exited, status=78/CONFIG
Jul 04 15:06:02 mydomain.xxx systemd[1]: php7.3-fpm.service: Failed with result 'exit-code'.
Jul 04 15:06:02 mydomain.xxx systemd[1]: Failed to start The PHP 7.3 FastCGI Process Manager.

when I check service php-7.3-fpm status

lapineige commented 3 years ago

My bad, the syntax was wrong (I edited my previous post). Here is the correct one:

php_admin_value[upload_max_filesize] = 16M
php_admin_value[memory_limit] = 8M
php_admin_value[post_max_size] = 8M
mikail97 commented 3 years ago

My bad, the syntax was wrong (I edited my previous post). Here is the correct one:

php_admin_value[upload_max_filesize] = 16M
php_admin_value[memory_limit] = 8M
php_admin_value[post_max_size] = 8M

I just did it and it doesn't give me an error but it hasn't solved the main problem either, I still cannot upload photos of more than 2MB, I have to put those three lines in both files?

lapineige commented 3 years ago

I have to put those three lines in both files?

No, that for php, the other file is for Nginx (the web server).

What's the client_max_body_size value in Nginx config file ?

mikail97 commented 3 years ago

What's the client_max_body_size value in Nginx config file ?

50M

Edit: I just tried to upload an image, and it won't let me upload anything larger than 500KB, previously it let me up to 2MB

lapineige commented 3 years ago

Edit: I just tried to upload an image, and it won't let me upload anything larger than 500KB, previously it let me up to 2MB

WTF is happening…

If you comment out those lines in php pixelfed.conf file (and reload php service) does it come back to the previous state ?

edit: I wonder, but I have no idea if that's true, if the memory limit is not too low… you could try to test it with huge values for each field, like 500M

mikail97 commented 3 years ago

If you comment out those lines in php pixelfed.conf file (and reload php service) does it come back to the previous state ?

I erased the lines and, yes, it does

edit: I wonder, but I have no idea if that's true, if the memory limit is not too low… you could try to test it with huge values for each field, like 500M

I put 500M in each field, both in the php and in the nginx and it works Thank you so much <3

Whenever I change the configuration from the web interface and give "save", I get this "Something went wrong We cannot process your request at this time, please try again later. Go back to Pixelfed. " Why?

lapineige commented 3 years ago

Whenever I change the configuration from the web interface and give "save", I get this "Something went wrong We cannot process your request at this time, please try again later. Go back to Pixelfed. " Why?

I don't know… If you do the same change in the .env file (don't forget to run the usual php artisan commands, to take the change into account), does it work ?

sthaydn commented 2 years ago

Hi,

that was the issue for me as well. I wasn't able to upload pics with more then 2M, while pixelfeld says it should be 25M. php_admin_value[upload_max_filesize] = 25M adding to the pixelfed.conf inside /etc/php/7.3/pool.d/ did the trick.

Would it be a good idea to have that line as standard for the installation process? As yunohost should be for people with not as much knowledge (like myself) it would be great to achieve changing the setting inside pixelfed should be enough. So maybe having set this value to 100M for example would be a good choice, even when people will post large pics the pixelfed value could be changed.

lapineige commented 2 years ago

So we can't include only a few lines of it, we need the whole file ?

@yalh76 do you think that with the new tools Yunohost includes to setup a kind of "php performance profile" (memory limit, CPU usage…) we could change that upload size value without using a custom php.conf file ?

twnl commented 1 year ago

I'm currently updating YH to Debian 11 and Pixelfed to 0.11.4 and take the waiting time to write this.

I also have this same problem, even after reading the entire issue and even though @sthaydn already gives a quite good explanation, I'm not 100% sure what I need to do to solve the problem.

php_admin_value[upload_max_filesize] = 25M adding to the pixelfed.conf inside /etc/php/7.3/pool.d/ did the trick.

Is that it, is that correct @lapineige ?

lapineige commented 1 year ago

I don't remember :sweat_smile: Can you tell us once you tried ? :smile:

type: sudo nano /etc/php/LATEST-PHP-VERSION/pool.d/pixelfed.conf

Php7.4 right now, for your information. If you have PHP 8.0 installed by another app, it's not the one you should configure for Pixelfed. (it might be php7.4-fpm, I'm unsure how this folder is named)

webmink commented 1 year ago

Helpful voices on the Fediverse pointed me here as I had the same issue with a clean install of PixelFed on Yunohost 11. Not being especially familiar with the software involved I was not able to work out what to do from this thread, but I did edit /etc/php/7.4/fpm/php.ini and change upload_max_filesize to 20M and it now works. I suspect I will not be the only marginally capable Yunohost user with this problem...

lapineige commented 1 year ago

We now changed the default upload limit to be 50MB for your information. Thanks @yalh76 !

You could try the testing branch and see if it fixes it :slightly_smiling_face:

isAAAc commented 1 year ago

@lapineige : (edit: i tried to reopen this issue, but don't see how .... :/ )

in https://github.com/YunoHost-Apps/pixelfed_ynh#change-max-upload-limit The readme.md should better explain where and wich file to edit:

To change max upload limit (default : 50MB), edit the Pixelfed php-fpm.conf file and find the line Common values to change to increase file upload limit And adjust those values:

this is wrong and should be:

 To change max upload limit (default : 50MB), edit the Pixelfed pixelfed.conf file in the `/etc/php/<PHP_VERSION>/fpm/pool.d/pixelfed.conf` and add and adjust those values:
isAAAc commented 1 year ago

the upgrade removes the change i made :/ perhaps we could have an include for local changes ?

lapineige commented 1 year ago

I don't get what should have been untouched ?

tituspijean commented 1 year ago

All of this should be handled with a YunoHost config panel, so that the setting is save across upgrades.

lapineige commented 1 year ago

Yes we have to configure a config panel for that 😅

unersame342 commented 1 year ago

after that you need to restart redis-server postgresql nginx and php8.0 in yunohost and all should work