Where to set PHP_FCGI_MAX_REQUESTS value? DUBLICATE - php

I cannot find the location of the conf file where I can change the value of PHP_FCGI_MAX_REQUESTS.
Info about the system: Debian, php7, FAST-CGI, Apache 2.4, Plesk Onyx 17.
There are similar questions on the web including stackoverflow, but none of the answers give the file directory.
I need to use this in order to solve the error (32)Broken pipe..mod_fcgid: ap_pass_brigade failed in handle_request_ipc function, as many people recommend to set it 10 times more than FcgidMaxRequestsPerProcess.

For all Debian-based OSes with Plesk installed, add it to the /etc/apache2/mods-available/fcgid.conf file, inside IfModule mod_fcgid.c block:
# tail -n 5 /etc/apache2/mods-available/fcgid.conf
FcgidInitialEnv RAILS_ENV production
FcgidIdleScanInterval 10
FcgidMaxRequestsPerProcess 500
</IfModule>
Do not forget to restart or reload the service:
# service apache2 graceful
[ ok ] Reloading web server config: apache2.

Related

Set PHP limits in Virtual Host FPM/FastCGI

I am trying to create individual setting of PHP (like memory_limit..) for Virtual Hosts But I dont know how could I do that.
I am using Fedora 27 deamon httpd, VHosts works good. When I put SetEnv PHPRC /var/www/pokus.cz/php.ini it doesnt work ( Yes I reloaded deamon).
I try just write php_value memory_limit 64M to VHost.conf file but it prints error
Invalid command "php_value"
I Think that, it is because there is no mod_php in Fedora 27 httpd, but it uses FPM/FastCGI. How could I solve that, Thanks alot for any advise :)
If you want to set individual PHP parameters to your VHosts on server and there is PHP-FPM running on it, you could specify it by different FPM pools.
Just copy the default FPM pool called www (etc/php-fpm.d/www.conf) and edit:
name parameter (specify new socket name) and
listen parameter (specify new socket name, which will VHost run)
(You can edit the php parameters there, like memory_limit...)
Now you have to add this to your VHost conf file:
<FilesMatch \.(php|phar)$>
SetHandler "proxy:unix:/run/php-fpm/yourchoosenname.sock|fcgi://localhost"
</FilesMatch>
This will start your php scripts on new FPM pool for this specific VHost.
Dont forget to reload your web server (I use Apache, so systemctl reload httpd) and PHP-FPM.

Max filesize not taking effect from php.ini

I know this is a massive repost but I couldn't figure this out. The server is Ubuntu using nginx.
Doing phpinfo() I see the configuration file I am using is /etc/php/7.0/fpm/php.ini.
These are the properties I set:
upload_max_filesize = 256M
post_max_size = 256M
I restarted nginx, as well as the php7.0-fpm process and the max upload size is still not changing.
I am using wordpress so as a last resort I even tried using a plugin that increases the max upload size and even that didn't work.
I also tried setting it in my .htaccess as well and still nothing:
php_value post_max_size 256M
php_value uploads_max_filesize 256M
By default NGINX has a limit of 1MB on file uploads. To change this you will need to set the client_max_body_size variable. You can do this in the http block in your nginx.conf
http {
#...
client_max_body_size 100m;
client_body_timeout 120s; # Default is 60, May need to be increased for very large uploads
#...
}
If you are expecting upload very large files where upload times will exceed 60 seconds you will also need to add the client_body_timeout variable with a large value
After updating you NGINX configuration don’t forget to restart NGINX.
you need to restart nginx and php to reload the configs. This can be done using the following commands;
sudo service nginx restart
sudo service php7.0-fpm restart
Note:if you don't have to host multiple
Websites just add it to the server block
server {
client_max_body_size 8M;
}
The answer I found here:
Have you tried to put your php.ini under /etc/php5/fpm/php.ini? This is normally the default location that php reads from, if I understand php5-fpm correctly.
A couple of things.
When you mention that your server uses nginx it is unnecesary to use an .htaccess file since those are for Apache servers.
That being said, I would try a couple of things.
Do you know what's the ini file of your php instance?
You mention the one for php 7 but you could also have php 5 installed.
If you go to your console and type "php --ini" what's the loaded configuration file?
Once you know that, using vi / vim or your editor of choice you can set:
upload_max_filesize = 100M
post_max_size = 100M
Now, have into account that you have to restart your services, both php and nginx:
for php 5:
service php5-fpm reload
for php 7:
service php7-fpm reload
for nginx:
service nginx reload
try printing the current values as well:
$uploadMaxFilesize = ini_get('upload_max_filesize');
$postMaxSize = ini_get('post_max_size');
Also, since this is for WordPress, did you try setting it up in the WordPress admin settings?
Admin Dashboard > Settings > Upload Settings
There's a couple things I had to change to get it working for me.
Firstly from user NID here, add this to your /etc/nginx/nginx.conf file (inside the http block):
http {
#...
client_max_body_size 100m;
client_body_timeout 120s; # Default is 60, May need to be increased for very large uploads
#...
}
Then I also had to follow something similar to user Just Rudy here.
Edit your php.ini file - contrary to many guides, for me it was not located in my wordpress root folder, but instead, /etc/php/7.2/fpm/php.ini.
There should be some predefined values for upload_max_filesize and post_max_size. Change these to what you want.
Restart nginx and php-fpm:
sudo systemctl reload nginx
sudo systemctl restart php7.2-fpm

Apache 2.4 Error: FCGI: attempt to connect to Unix domain socket /run/php/php7.0-fpm.sock (*) failed

I have updated my working Froxlor installation to PHP 7.
All my customer-sites work perfectly fine (with PHP 7 via FPM).
The only problem is, that if I want to access the Froxlor Backend, I get an Erorr 503.
The apache Error-Log says:
`[Tue Oct 11 10:01:04.067069 2016] [proxy:error] [pid 23949] (2)No such file or directory: AH02454: FCGI: attempt to connect to Unix domain socket /run/php/php7.0-fpm.sock (*) failed`
`[Tue Oct 11 10:01:04.089648 2016] [proxy_fcgi:error] [pid 23949] [client xx.xx.xx.xx:1819] AH01079: failed to make connection to backend: httpd-UDS`
The Error-Log of PHP-FPM says nothing.
The same thing happens, if I try to access the server directly via IP.
System-Details:
Debian 8
Apache 2.4
PHP7
PHP7-FPM
Where I have to serach for the Problem? If needed, config-files can be provided.
If you are using PHP-FPM, the problem may also be that you need to start the PHP service.
Apache does not automatically stop the process, so you will either manually start it up or automatically on startup
For PHP 7.x (remember to include your version):
service php7.x-fpm start
For PHP 7:
service php7-fpm start
For PHP 5:
service php-fpm start
This will begin the FPM process for you.
Additionally, you may also want the process to startup on boot. To do that simply enter the following, of course considering your respective version.
systemctl enable php7.x-fpm
I had same issue, on New server having php7.4 and these virtual host configuration files(located in /etc/apache2/sites-available/ directory) i migrated from server having php7.2.
When checked in detail i found
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.2-fpm.sock|fcgi://localhost/"
</FilesMatch>
Which then i replaced with
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost/"
</FilesMatch>
Basically updating php version and it worked fine after restarting apache2
Steps I made in order to make it work on my host:
in /etc/apt/sources.list - added non-free to debian repository
apt update
apt install libapache2-mod-fastcgi
a2enmod fastcgi
(That made the "Invalid command 'FastCgiExternalServer' error, I encountered on a new installation", go away).
In Froxlor - "Settings" - "Froxlor VirtualHost settings":
[X] Enable PHP-FPM for the Froxlor vHost If enabled, Froxlor will also be running under a local user.
I also removed all "Listen" entries from apache2's ports.conf

Any php file is not working in browser

I have tried many php files like huge file, small file but any of them is not working it will load and shows 504 gateway error
I tried test.php file with one line of code it is also showing the same error
<?php echo"Hi working fine"; ?>
I think you have updated php execution time in php config but what about Nginx config?
Try updating your Nginx Config :
Step 1 : Updates for your website test.com
vim /etc/nginx/sites-available/test.com
Step 2 : Updating Execution Time
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_read_timeout 300;
}
Step 3 : Don't forget to reload to reflect changes
service php5-fpm reload
service nginx reload
Hope this helps.
I'd check in the following order:
1) If php5-fpm is running:
sudo service php5-fpm status
if it returns the process number - try telneting it:
telnet 127.0.0.1 9000
2) If telnet returns connected status - I'd start checking the /etc/nginx/sites-enabled if the config of your site is there. If it's there - check that the stuff is set up correspondingly...one of the examples of how to set up nginx with php-fpm is here:
https://www.howtoforge.com/installing-nginx-with-php5-fpm-and-mysql-on-ubuntu-14.04-lts-lemp
3) If that is ok - reload the php5-fpm and nginx and check if permissions in your site dir (typically something like /var/www/html/site.com) are set right for user www-data (the default nginx user).
If that is ok - then I can't think of anything more without seeing configs and having fingertips on machine terminal.
Hopefully this helps a bit.
Had this problem on Ubuntu 16.04 with Apache and PHP 7.0. Tried a dozen solutions, which still gave me errors, and then found https://www.howtoforge.com/tutorial/apache-with-php-fpm-on-ubuntu-16-04/ which worked for me. With PHP 7.0 and Apache 2 installed, and as superuser:
apt install libapache2-mod-fastcgi php7.0-fpm
a2enmod actions fastcgi alias
Restart Apache.
And then add the following to a copy of /etc/apache2/sites-available/000-default.conf as a child of <VirtualHost>
<Directory /usr/lib/cgi-bin>
Require all granted
</Directory>
<IfModule mod_fastcgi.c>
SetHandler php7-fcgi.php
Action php7-fcgi /php7-fcgi virtual
Alias /php7-fcgi /usr/lib/cgi-bin/php7-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php7-fcgi -socket /var/run/php/php7.0-fpm.sock -pass-header Authorization
</IfModule>
In my case, I used a Sites directory in Home instead of /var/www/ and also had inside :
ServerName localhost
ServerAdmin me#myemail.com
DocumentRoot /home/me/Sites
If using a copy of 000-default.conf make sure to disable it with a2disconf and enable your copy with a2enconf.

413 Request Entity Too Large - File Upload Issue

I am trying to upload 30MB file on my server and its not working.
When I upload 30MB file, the page loads "Page Not Found"
When I upload a 3MB file, I receive "413 Request Entity Too Large" with nginx/0.6.32
I am trying to find nginx so I can increase "client_max_body_size" but I am unable to find nginx installed on my server. I even tried running:
vi /etc/nginx/nginx.conf
or
vi /usr/local/nginx/conf/nginx.conf
to check if the config file exists, but I couldnt find it on my server.
Is there anyway to resolve this issue? Or do I have to installed nginx on my server.
EDIT:
I have made all necessary changes in my php.ini files,
post_max_size 128M
upload_max_filesize 100M
memory_limit 256M
Thanks,
Raju
Source:
http://www.cyberciti.biz/faq/linux-unix-bsd-nginx-413-request-entity-too-large/
Edit the conf file of nginx:
nano /etc/nginx/nginx.conf
Add a line in the http, server or location section:
client_max_body_size 100M;
Doen't use MB it will not work, only the M!
Also do not forget to restart nginx
systemctl restart nginx
-in php.ini (inside /etc/php.ini)
max_input_time = 24000
max_execution_time = 24000
upload_max_filesize = 12000M
post_max_size = 24000M
memory_limit = 12000M
-in nginx.conf(inside /opt/nginx/conf)
client_max_body_size 24000M
Its working for my case
First edit the Nginx configuration file (nginx.conf)
Location: sudo nano /etc/nginx/nginx.conf
Add following codes:
http {
client_max_body_size 100M;
}
Then Add the following lines in PHP configuration file(php.ini)
Location: sudo gedit /etc/php5/fpm/php.ini
Add following codes:
memory_limit = 128M
post_max_size = 20M
upload_max_filesize = 10M
sudo nano /etc/nginx/nginx.conf
Then add a line in the http section
http {
client_max_body_size 100M;
}
don't use MB only M.
systemctl restart nginx
then for php location
sudo gedit /etc/php5/fpm/php.ini
for nowdays maximum use php 7.0 or higher
sudo nano /etc/php/7.2/fpm/php.ini //7.3,7.2 or 7.1 which php you use
check those increasing by your desire .
memory_limit = 128M
post_max_size = 20M
upload_max_filesize = 10M
restart php-fpm
service php-fpm restart
I add the changes directly to my virtualhost instead the global config of nginx, like this:
server {
client_max_body_size 100M;
...
}
And then I change the params in php.ini, like the comments above:
max_input_time = 24000
max_execution_time = 24000
upload_max_filesize = 12000M
post_max_size = 24000M
memory_limit = 12000M
and what you can not forget is to restart nginx and php-fpm, in centos 7 is like this:
systemctl restart nginx
systemctl restart php-fpm
Please enter domain nginx file :
nano /etc/nginx/sites-available/domain.set
Add to file this code
client_max_body_size 24000M;
If you get error use this command
nginx -t
I got the same error and fixed it with the below steps.
At first, edit the nginx.conf file.
vi /etc/nginx/nginx.conf
At the HTTP section, added the below line.
http {
client_max_body_size 100M;
}
Finally restarted Nginx with the below command.
systemctl restart nginx
Assuming that you made the necessary changes in your php.ini files:
You can resolve the issue by adding the following line in your nginx.conf file found in the following path:
/etc/nginx/nginx.conf
then edit the file using vim text editor as follows:
vi /etc/nginx/nginx.conf
and add client_max_body_size with a large enough value, for example:
client_max_body_size 20MB;
After that make sure you save using :xi or :wq
And then restart your nginx.
That's it.
Worked for me, hope this helps.
I got the upload working with above changes. But when I made the changes I started getting 404 response in file upload which lead me to do further debugging and figured out its a permission issue by checking nginx error.log
Solution:
Check the current user and group ownership on /var/lib/nginx.
$ ls -ld /var/lib/nginx
drwx------. 3 nginx nginx 17 Oct 5 19:31 /var/lib/nginx
This tells that a possibly non-existent user and group named nginx owns this folder. This is preventing file uploading.
In my case, the username mentioned in "/etc/nginx/nginx.conf" was
user vagrant;
Change the folder ownership to the user defined in nginx.conf in this case vagrant.
$ sudo chown -Rf vagrant:vagrant /var/lib/nginx
Verify that it actually changed.
$ ls -ld /var/lib/nginx
drwx------. 3 vagrant vagrant 17 Oct 5 19:31 /var/lib/nginx
Reload nginx and php-fpm for safer sade.
$ sudo service nginx reload
$ sudo service php-fpm reload
The permission denied error should now go away. Check the error.log (based on nginx.conf error_log location).
$ sudo nano /path/to/nginx/error.log
Anyone looking for a solution for Apache2 (Ubuntu 18 for me), you can edit:
/etc/apache2/apache2.conf
And find/edit the line:
LimitRequestBody 7000000 #7mb
In my case, I was using nginx along with letsencrypt to put a ssl layer in front of my spring boot application.
Putting clint_max_body_size property in "/etc/nginx/nginx.conf" did not work for me.
Instead, I put this property inside the site specific conf file.
sudo nano /etc/nginx/sites-available/mywebsite.com
server {
...
client_max_body_size 3M;
...
}
Post saving the above, restarted the nginx server and it worked !
sudo service nginx stop
sudo service nginx start
Open file/etc/nginx/nginx.conf
Add or change client_max_body_size 0;
Use:
php -i
command or add:
phpinfo();
to get the location of configuration file.
Update these variables according to your need and server
max_input_time = 24000
max_execution_time = 24000
upload_max_filesize = 12000M
post_max_size = 24000M
memory_limit = 12000M
On Linux you will need to restart nginx / apache and phpfpm service so the new ini settings are loaded. On xampp, ammps you can restart these from control panel that comes with such applications.
Just open this file and ---
sudo vim /etc/nginx/nginx.conf
Add a line in the http, server or location section:
client_max_body_size 100M;
Then check nginx is okey or not by the following command
sudo nginx -t
If everything looks fine then you will get
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Then restart nginx
sudo systemctl restart nginx
I hope your purpose is served :)

Categories