<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://dikapediav2.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Nginx</id>
	<title>Nginx - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://dikapediav2.com/wiki/index.php?action=history&amp;feed=atom&amp;title=Nginx"/>
	<link rel="alternate" type="text/html" href="https://dikapediav2.com/wiki/index.php?title=Nginx&amp;action=history"/>
	<updated>2026-05-15T09:10:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://dikapediav2.com/wiki/index.php?title=Nginx&amp;diff=132&amp;oldid=prev</id>
		<title>Ardika Sulistija: Created page with &quot;https://www.tecmint.com/useful-nginx-command-examples/ &lt;/br&gt;https://serversforhackers.com/c/redirect-http-to-https-nginx &lt;/br&gt;https://linuxize.com/post/redirect-http-to-https-in-nginx/   ====How to find and check Nginx configuration==== ----  $ sudo nginx -t  nginx: the configuration file /etc/nginx/nginx.conf syntax is ok  nginx: configuration file /etc/nginx/nginx.conf test is successful   ====How to find php.ini and www.conf==== ---- Find those full file paths using a...&quot;</title>
		<link rel="alternate" type="text/html" href="https://dikapediav2.com/wiki/index.php?title=Nginx&amp;diff=132&amp;oldid=prev"/>
		<updated>2024-09-11T14:08:41Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;https://www.tecmint.com/useful-nginx-command-examples/ &amp;lt;/br&amp;gt;https://serversforhackers.com/c/redirect-http-to-https-nginx &amp;lt;/br&amp;gt;https://linuxize.com/post/redirect-http-to-https-in-nginx/   ====How to find and check Nginx configuration==== ----  $ sudo nginx -t  nginx: the configuration file /etc/nginx/nginx.conf syntax is ok  nginx: configuration file /etc/nginx/nginx.conf test is successful   ====How to find php.ini and www.conf==== ---- Find those full file paths using a...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;https://www.tecmint.com/useful-nginx-command-examples/&lt;br /&gt;
&amp;lt;/br&amp;gt;https://serversforhackers.com/c/redirect-http-to-https-nginx&lt;br /&gt;
&amp;lt;/br&amp;gt;https://linuxize.com/post/redirect-http-to-https-in-nginx/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====How to find and check Nginx configuration====&lt;br /&gt;
----&lt;br /&gt;
 $ sudo nginx -t&lt;br /&gt;
 nginx: the configuration file /etc/nginx/nginx.conf syntax is ok&lt;br /&gt;
 nginx: configuration file /etc/nginx/nginx.conf test is successful&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====How to find php.ini and www.conf====&lt;br /&gt;
----&lt;br /&gt;
Find those full file paths using a find command:&lt;br /&gt;
&lt;br /&gt;
 find / \( -iname &amp;quot;php.ini&amp;quot; -o -name &amp;quot;www.conf&amp;quot; \)&lt;br /&gt;
&lt;br /&gt;
The output should look similar to:&lt;br /&gt;
&lt;br /&gt;
 root@localhost:~# find / \( -iname &amp;quot;php.ini&amp;quot; -o -name &amp;quot;www.conf&amp;quot; \)&lt;br /&gt;
 /etc/php/7.0/fpm/php.ini&lt;br /&gt;
 /etc/php/7.0/fpm/pool.d/www.conf&lt;br /&gt;
 /etc/php/7.0/cli/php.ini&lt;br /&gt;
&lt;br /&gt;
https://www.linode.com/docs/guides/serve-php-php-fpm-and-nginx/&lt;br /&gt;
&lt;br /&gt;
====NGINX Performance Tuning====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[6] https://myshell.co.uk/blog/2012/07/adjusting-child-processes-for-php-fpm-nginx/&lt;br /&gt;
&lt;br /&gt;
https://www.kinamo.be/en/support/faq/determining-the-correct-number-of-child-processes-for-php-fpm-on-nginx&lt;br /&gt;
&lt;br /&gt;
https://serverfault.com/questions/479443/php5-fpm-server-reached-pm-max-children/578673&lt;br /&gt;
&lt;br /&gt;
If PHP has reached the maximum children setting, in which this is due to the setting in the pool directives file (www.conf). Pool Directives are a PHP-FPM convention where multiple &amp;quot;pools&amp;quot; of child processes can be started and have different configurations. &lt;br /&gt;
&lt;br /&gt;
To address this issue, we followed document [6] to calculate the proper value for the max_children setting in the pool directives file (www.conf). The formula we used to calculate this value: &lt;br /&gt;
 pm.max_children = Total RAM dedicated to the web server / Max child process size&lt;br /&gt;
        &lt;br /&gt;
We ran the following commands:&lt;br /&gt;
* To get the average memory usage of a single php-fpm process:&lt;br /&gt;
 $ ps --no-headers -o &amp;quot;rss,cmd&amp;quot; -C php-fpm | awk &amp;#039;{ sum+=$1 } END { printf (&amp;quot;%d%s\n&amp;quot;, sum/NR/1024,&amp;quot;M&amp;quot;) }&amp;#039;&lt;br /&gt;
 25M&lt;br /&gt;
&lt;br /&gt;
* As your instance has over 30GB of memory, in this calculation I just used 10GB of memory to reserve memory for other processes)&lt;br /&gt;
 pm.max_children = 10000MB / 25MB = 400 &lt;br /&gt;
&lt;br /&gt;
This is the final configuration we made based on our calculation above:&lt;br /&gt;
 $ sudo vi /etc/php/7.3/fpm/pool.d/www.conf &lt;br /&gt;
            pm.max_children = 400&lt;br /&gt;
            pm.start_servers = 20&lt;br /&gt;
            pm.min_spare_servers = 20&lt;br /&gt;
            pm.max_spare_servers = 35&lt;br /&gt;
            pm.max_requests = 500&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* After making the above configuration changes, we restarted Nginx and php-fpm:&lt;br /&gt;
&lt;br /&gt;
            $ sudo systemctl restart php7.3-fpm.service &lt;br /&gt;
&lt;br /&gt;
            $ sudo systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===== Optimizing PHP-fpm =====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
https://geekflare.com/php-fpm-optimization/&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====504 gateway timeout====&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
[5] https://easycloudsupport.zendesk.com/hc/en-us/articles/360002057472-How-to-Fix-504-Gateway-Timeout-using-Nginx&lt;br /&gt;
&lt;br /&gt;
Nginx is timing out with a 504. A 504 Gateway Timeout error in Nginx can be generated often by a number of reasons on the backend connection that is serving content. I found that 504 is quite common, and are generated most probably by the PHP max execution time limit or by the FastCGI read timeout settings. &lt;br /&gt;
&lt;br /&gt;
To address the Timeout issue, we ran the following commands. We changed the max_execution_time in php.ini to 300 and also changed request_terminate_timeout to 300 as per article [5]: &lt;br /&gt;
 $ sudo vi /etc/php/7.3/fpm/php.ini &lt;br /&gt;
 max_execution_time = 300 &lt;br /&gt;
 &lt;br /&gt;
 $ sudo vi /etc/php/7.3/fpm/pool.d/www.conf &lt;br /&gt;
 request_terminate_timeout = 300&lt;/div&gt;</summary>
		<author><name>Ardika Sulistija</name></author>
	</entry>
</feed>