Use php-fpm log to troubleshoot PHP 8 Linux Azure App Service

Published Apr 04 2022 08:01 PM 1,250 Views
Microsoft

Azure App Service for Linux platform now supports customer using both PHP 7 and PHP 8 built-in docker image.
When switching from PHP 7 to PHP 8, you may recognize the platform changed the web container from using Apache to Nginx+php-fpm mode.

 

This blog shows how to use customized php-fpm configuration in PHP 8 Linux App Service to get more detailed logs to troubleshoot application issues.

 

How to Enable php-fpm access log

How to Enable php-fpm slow requests log

How to check php-fpm status

 

How to Enable php-fpm access log

We can get a lot of detailed PHP requests information in php-fpm access log.
For example:

  • Request URL
  • Response status code
  • Server time the request was received
  • Time taken to serve the request
  • %CPU used by the request
  • peak of memory allocated by PHP

 

In PHP 8 Linux Azure App Service, the original php-fpm config file is stored in  /usr/local/etc/php-fpm.d/www.conf.

By default, php-fpm access log is disabled in the config.

 

To enable php-fpm access log, we need to modify the php-fpm config file.

1.  Make a copy of www.conf from /usr/local/etc/php-fpm.d/www.conf to /home/www.conf

     Go to https://<appservice-name>.scm.azurewebsites.net/webssh/host

 

cp /usr/local/etc/php-fpm.d/www.conf /home/www.conf

 

2.  Enable access.log by uncomment the following two lines in the /home/www.conf file

 

vi /home/www.conf

 

Define your access.log file path. (We suggest put it anywhere under /home/LogFiles/)
Define the access log format, to add the information you need for application issue investigation.

Hanli_Ren_0-1649058972670.png

The meaning of the format arguments are provided in the www.conf file

Hanli_Ren_1-1649059031448.png

 

3.  Change the customer startup script to overwrite the originally www.config file with your customized one.

Put the following command in the startup script:

 

cp /home/www.conf /usr/local/etc/php-fpm.d/www.conf; service nginx restart

 

Hanli_Ren_0-1649062115607.png

 

4. After Restart the App Service, you should be able to see the php-fpm access log in the path you defined in your www.config file.

Hanli_Ren_1-1649062145171.png

 

 

How to Enable php-fpm slow requests log

We can also enable php-fpm slow log to get more detailed php call stacks to analysis requests slowness issues.

We can enable slow log with the following steps:

1. Make a copy of www.conf from /usr/local/etc/php-fpm.d/www.conf to /home/www.conf

 

cp /usr/local/etc/php-fpm.d/www.conf /home/www.conf

 

2. Enable slowlog by uncomment the following two lines in the /home/www.conf file

 

vi /home/www.conf

 

Define your slowlog file path. (We suggest put it anywhere under /home/Logfiles/ folder)
Define the request_slowlog_timeout

Hanli_Ren_2-1649062387969.png

 

3. Change the customer startup script to overwrite the originally www.config file with your customized one.

Put the following command in the startup script:

 

cp /home/www.conf /usr/local/etc/php-fpm.d/www.conf; service nginx restart

 

Hanli_Ren_3-1649062475268.png

 

4. After Restart the App Service, you should be able to see the php-fpm slow log in the path you defined in your www.config file.

For example, I create a very simple slow request sample.

  • index.php calls test.php
  • test.php sleeps 10 seconds when processing the request.

Hanli_Ren_4-1649062557372.png

In my /home/Logfiles/www.log.slow record, I can see detailed call stack in the log for the slow requests.

Hanli_Ren_5-1649062607160.png

 

 

 

How to check php-fpm status

Sometimes we need to check php-fpm status for performance tuning.
For example, we can check "max active process" and "max children reached" number to decide whether we need to increase the pm.max_children in the php-fpm configuration.

 

We can check php-fpm status with the following steps:

1. Make a copy of www.conf from /usr/local/etc/php-fpm.d/www.conf to /home/www.conf

 

cp /usr/local/etc/php-fpm.d/www.conf /home/www.conf

 

2. Enable pm.status_path by uncomment the following line in the /home/www.conf file

Hanli_Ren_0-1649062804874.png

 

3. Make a copy of Nginx configure file from /etc/nginx/sites-enabled/default to /home/default

 

cp /etc/nginx/sites-enabled/default /home/default

 

4. Add location for php-fpm status check

 

# Add location for php-fpm status check
    location = /status {
       include fastcgi_params;
       fastcgi_param SCRIPT_NAME '/status';
       fastcgi_param SCRIPT_FILENAME '/status';
       fastcgi_pass 127.0.0.1:9000;
    }

 

Hanli_Ren_1-1649062926895.png

5. Modify customer startup command to overwrite Nginx and php-fpm config file with your customized settings

Put the following command in the startup script:

 

cp /home/www.conf /usr/local/etc/php-fpm.d/www.conf; cp /home/default /etc/nginx/sites-enabled/default; service nginx restart

 

Hanli_Ren_2-1649063040793.png

 

6. By accessing the https://<webapp-name>.azurewebsites.net/status uri of your App Service, you should be able to monitor the php-fpm usage status in live time.

Hanli_Ren_3-1649063105738.png

 

%3CLINGO-SUB%20id%3D%22lingo-sub-3275136%22%20slang%3D%22en-US%22%3EUse%20php-fpm%20log%20to%20troubleshoot%20PHP%208%20Linux%20Azure%20App%20Service%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3275136%22%20slang%3D%22en-US%22%3E%3CP%3EAzure%20App%20Service%20for%20Linux%20platform%20now%20supports%20customer%20using%20both%20PHP%207%20and%20PHP%208%20built-in%20docker%20image.%20%3CBR%20%2F%3EWhen%20switching%20from%20PHP%207%20to%20PHP%208%2C%20you%20may%20recognize%20the%20platform%20changed%20the%20web%20container%20from%20using%20Apache%20to%20Nginx%2Bphp-fpm%20mode.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20blog%20shows%20how%20to%20use%20customized%20php-fpm%20configuration%20in%20PHP%208%20Linux%20App%20Service%20to%20get%20more%20detailed%20logs%20to%20troubleshoot%20application%20issues.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22%23h_98964409911649063236026%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EHow%20to%20Enable%20php-fpm%20access%20log%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22%23h_549177304101649063248531%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EHow%20to%20Enable%20php-fpm%20slow%20requests%20log%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%3CA%20href%3D%22%23h_890536628121649063253807%22%20target%3D%22_self%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3EHow%20to%20check%20php-fpm%20status%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-393784791%22%20id%3D%22toc-hId-415894421%22%3EHow%20to%20Enable%20php-fpm%20access%20log%3C%2FH2%3E%0A%3CP%3EWe%20can%20get%20a%20lot%20of%20detailed%20PHP%20requests%20information%20in%20php-fpm%20access%20log.%3CBR%20%2F%3EFor%20example%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ERequest%20URL%3C%2FLI%3E%0A%3CLI%3EResponse%20status%20code%3C%2FLI%3E%0A%3CLI%3EServer%20time%20the%20request%20was%20received%3C%2FLI%3E%0A%3CLI%3ETime%20taken%20to%20serve%20the%20request%3C%2FLI%3E%0A%3CLI%3E%25CPU%20used%20by%20the%20request%3C%2FLI%3E%0A%3CLI%3Epeak%20of%20memory%20allocated%20by%20PHP%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20PHP%208%20Linux%20Azure%20App%20Service%2C%20the%20original%20php-fpm%20config%20file%20is%20stored%20in%26nbsp%3B%20%2Fusr%2Flocal%2Fetc%2Fphp-fpm.d%2F%3CA%20href%3D%22http%3A%2F%2Fwww.conf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.conf%3C%2FA%3E.%3C%2FP%3E%0A%3CP%3EBy%20default%2C%20php-fpm%20access%20log%20is%20disabled%20in%20the%20config.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20enable%20php-fpm%20access%20log%2C%20we%20need%20to%20modify%20the%20php-fpm%20config%20file.%3C%2FP%3E%0A%3CP%3E1.%26nbsp%3B%26nbsp%3BMake%20a%20copy%20of%20%3CA%20href%3D%22http%3A%2F%2Fwww.conf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.conf%3C%2FA%3E%20from%20%3CSTRONG%3E%2Fusr%2Flocal%2Fetc%2Fphp-fpm.d%2F%3CA%20href%3D%22http%3A%2F%2Fwww.conf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.conf%3C%2FA%3E%3C%2FSTRONG%3E%20to%20%3CSTRONG%3E%2Fhome%2F%3CA%20href%3D%22http%3A%2F%2Fwww.conf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.conf%3C%2FA%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3BGo%20to%26nbsp%3Bhttps%3A%2F%2F%3CAPPSERVICE-NAME%3E.scm.azurewebsites.net%2Fwebssh%2Fhost%3C%2FAPPSERVICE-NAME%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Ecp%20%2Fusr%2Flocal%2Fetc%2Fphp-fpm.d%2Fwww.conf%20%2Fhome%2Fwww.conf%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E2.%26nbsp%3B%26nbsp%3BEnable%20access.log%20by%20uncomment%20the%20following%20two%20lines%20in%20the%20%2Fhome%2F%3CA%20href%3D%22http%3A%2F%2Fwww.conf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.conf%3C%2FA%3E%20file%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Evi%20%2Fhome%2Fwww.conf%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDefine%20your%20access.log%20file%20path.%20(We%20suggest%20put%20it%20anywhere%20under%20%2Fhome%2FLogFiles%2F)%3CBR%20%2F%3EDefine%20the%20access%20log%20format%2C%20to%20add%20the%20information%20you%20need%20for%20application%20issue%20investigation.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Hanli_Ren_0-1649058972670.png%22%20style%3D%22width%3A%20434px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361023i3D8DF769FBE65DA0%2Fimage-dimensions%2F434x330%3Fv%3Dv2%22%20width%3D%22434%22%20height%3D%22330%22%20role%3D%22button%22%20title%3D%22Hanli_Ren_0-1649058972670.png%22%20alt%3D%22Hanli_Ren_0-1649058972670.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EThe%20meaning%20of%20the%20format%20arguments%20are%20provided%20in%20the%20%3CA%20href%3D%22http%3A%2F%2Fwww.conf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.conf%3C%2FA%3E%26nbsp%3Bfile%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Hanli_Ren_1-1649059031448.png%22%20style%3D%22width%3A%20524px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361024i3B4471990FF02461%2Fimage-dimensions%2F524x91%3Fv%3Dv2%22%20width%3D%22524%22%20height%3D%2291%22%20role%3D%22button%22%20title%3D%22Hanli_Ren_1-1649059031448.png%22%20alt%3D%22Hanli_Ren_1-1649059031448.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E3.%26nbsp%3B%26nbsp%3BChange%20the%20customer%20startup%20script%20to%20overwrite%20the%20originally%20%3CA%20href%3D%22http%3A%2F%2Fwww.config%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.config%3C%2FA%3E%20file%20with%20your%20customized%20one.%3C%2FP%3E%0A%3CP%3EPut%20the%20following%20command%20in%20the%20startup%20script%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Ecp%20%2Fhome%2Fwww.conf%20%2Fusr%2Flocal%2Fetc%2Fphp-fpm.d%2Fwww.conf%3B%20service%20nginx%20restart%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Hanli_Ren_0-1649062115607.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361044i17967E4A801C7FB4%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Hanli_Ren_0-1649062115607.png%22%20alt%3D%22Hanli_Ren_0-1649062115607.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E4.%20After%20Restart%20the%20App%20Service%2C%20you%20should%20be%20able%20to%20see%20the%20php-fpm%20access%20log%20in%20the%20path%20you%20defined%20in%20your%20%3CA%20href%3D%22http%3A%2F%2Fwww.config%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.config%3C%2FA%3E%20file.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Hanli_Ren_1-1649062145171.png%22%20style%3D%22width%3A%20719px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361045iBBB2379CBFB729B2%2Fimage-dimensions%2F719x144%3Fv%3Dv2%22%20width%3D%22719%22%20height%3D%22144%22%20role%3D%22button%22%20title%3D%22Hanli_Ren_1-1649062145171.png%22%20alt%3D%22Hanli_Ren_1-1649062145171.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId--1413669672%22%20id%3D%22toc-hId--1391560042%22%3EHow%20to%20Enable%20php-fpm%20slow%20requests%20log%3C%2FH2%3E%0A%3CP%3EWe%20can%20also%20enable%20php-fpm%20slow%20log%20to%20get%20more%20detailed%20php%20call%20stacks%20to%20analysis%20requests%20slowness%20issues.%3C%2FP%3E%0A%3CP%3EWe%20can%20enable%20slow%20log%20with%20the%20following%20steps%3A%3C%2FP%3E%0A%3CP%3E1.%20Make%20a%20copy%20of%20%3CA%20href%3D%22http%3A%2F%2Fwww.conf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.conf%3C%2FA%3E%20from%3CSTRONG%3E%20%2Fusr%2Flocal%2Fetc%2Fphp-fpm.d%2F%3CA%20href%3D%22http%3A%2F%2Fwww.conf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.conf%3C%2FA%3E%3C%2FSTRONG%3E%20to%20%3CSTRONG%3E%2Fhome%2F%3CA%20href%3D%22http%3A%2F%2Fwww.conf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.conf%3C%2FA%3E%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Ecp%20%2Fusr%2Flocal%2Fetc%2Fphp-fpm.d%2Fwww.conf%20%2Fhome%2Fwww.conf%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E2.%20Enable%20slowlog%20by%20uncomment%20the%20following%20two%20lines%20in%20the%20%2Fhome%2F%3CA%20href%3D%22http%3A%2F%2Fwww.conf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.conf%3C%2FA%3E%20file%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Evi%20%2Fhome%2Fwww.conf%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EDefine%20your%20slowlog%20file%20path.%20(We%20suggest%20put%20it%20anywhere%20under%20%2Fhome%2FLogfiles%2F%20folder)%3CBR%20%2F%3EDefine%20the%20request_slowlog_timeout%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Hanli_Ren_2-1649062387969.png%22%20style%3D%22width%3A%20587px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361047i71F6DBCC856AD755%2Fimage-dimensions%2F587x316%3Fv%3Dv2%22%20width%3D%22587%22%20height%3D%22316%22%20role%3D%22button%22%20title%3D%22Hanli_Ren_2-1649062387969.png%22%20alt%3D%22Hanli_Ren_2-1649062387969.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E3.%20Change%20the%20customer%20startup%20script%20to%20overwrite%20the%20originally%20%3CA%20href%3D%22http%3A%2F%2Fwww.config%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.config%3C%2FA%3E%20file%20with%20your%20customized%20one.%3C%2FP%3E%0A%3CP%3EPut%20the%20following%20command%20in%20the%20startup%20script%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Ecp%20%2Fhome%2Fwww.conf%20%2Fusr%2Flocal%2Fetc%2Fphp-fpm.d%2Fwww.conf%3B%20service%20nginx%20restart%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Hanli_Ren_3-1649062475268.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361048iE181A9E468C7B836%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Hanli_Ren_3-1649062475268.png%22%20alt%3D%22Hanli_Ren_3-1649062475268.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E4.%20After%20Restart%20the%20App%20Service%2C%20you%20should%20be%20able%20to%20see%20the%20php-fpm%20slow%20log%20in%20the%20path%20you%20defined%20in%20your%20%3CA%20href%3D%22http%3A%2F%2Fwww.config%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.config%3C%2FA%3E%20file.%3C%2FP%3E%0A%3CP%3EFor%20example%2C%20I%20create%20a%20very%20simple%20slow%20request%20sample.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3Eindex.php%20calls%20test.php%3C%2FLI%3E%0A%3CLI%3Etest.php%20sleeps%2010%20seconds%20when%20processing%20the%20request.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Hanli_Ren_4-1649062557372.png%22%20style%3D%22width%3A%20355px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361049i68855CE286C3194C%2Fimage-dimensions%2F355x323%3Fv%3Dv2%22%20width%3D%22355%22%20height%3D%22323%22%20role%3D%22button%22%20title%3D%22Hanli_Ren_4-1649062557372.png%22%20alt%3D%22Hanli_Ren_4-1649062557372.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EIn%20my%20%2Fhome%2FLogfiles%2F%3CA%20href%3D%22http%3A%2F%2Fwww.log.slow%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.log.slow%3C%2FA%3E%20record%2C%20I%20can%20see%20detailed%20call%20stack%20in%20the%20log%20for%20the%20slow%20requests.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Hanli_Ren_5-1649062607160.png%22%20style%3D%22width%3A%20504px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361050i9AC3A87B4287BA83%2Fimage-dimensions%2F504x173%3Fv%3Dv2%22%20width%3D%22504%22%20height%3D%22173%22%20role%3D%22button%22%20title%3D%22Hanli_Ren_5-1649062607160.png%22%20alt%3D%22Hanli_Ren_5-1649062607160.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22toc-hId-1073843161%22%20id%3D%22toc-hId-1095952791%22%3EHow%20to%20check%20php-fpm%20status%3C%2FH2%3E%0A%3CP%3ESometimes%20we%20need%20to%20check%20php-fpm%20status%20for%20performance%20tuning.%3CBR%20%2F%3EFor%20example%2C%20we%20can%20check%20%22max%20active%20process%22%20and%20%22max%20children%20reached%22%20number%20to%20decide%20whether%20we%20need%20to%20increase%20the%20pm.max_children%20in%20the%20php-fpm%20configuration.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20can%20check%20php-fpm%20status%20with%20the%20following%20steps%3A%3C%2FP%3E%0A%3CP%3E1.%20Make%20a%20copy%20of%20%3CA%20href%3D%22http%3A%2F%2Fwww.conf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.conf%3C%2FA%3E%20from%20%2Fusr%2Flocal%2Fetc%2Fphp-fpm.d%2F%3CA%20href%3D%22http%3A%2F%2Fwww.conf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.conf%3C%2FA%3E%20to%20%2Fhome%2F%3CA%20href%3D%22http%3A%2F%2Fwww.conf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.conf%3C%2FA%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Ecp%20%2Fusr%2Flocal%2Fetc%2Fphp-fpm.d%2Fwww.conf%20%2Fhome%2Fwww.conf%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E2.%20Enable%20%3CSTRONG%3Epm.status_path%3C%2FSTRONG%3E%20by%20uncomment%20the%20following%20line%20in%20the%20%2Fhome%2F%3CA%20href%3D%22http%3A%2F%2Fwww.conf%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ewww.conf%3C%2FA%3E%20file%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Hanli_Ren_0-1649062804874.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361051i9B1E49CAAB4082FF%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Hanli_Ren_0-1649062804874.png%22%20alt%3D%22Hanli_Ren_0-1649062804874.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E3.%20Make%20a%20copy%20of%20Nginx%20configure%20file%20from%20%3CSTRONG%3E%2Fetc%2Fnginx%2Fsites-enabled%2Fdefault%3C%2FSTRONG%3E%20to%3CSTRONG%3E%20%2Fhome%2Fdefault%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Ecp%20%2Fetc%2Fnginx%2Fsites-enabled%2Fdefault%20%2Fhome%2Fdefault%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E4.%20Add%20location%20for%20php-fpm%20status%20check%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3E%23%20Add%20location%20for%20php-fpm%20status%20check%0A%20%20%20%20location%20%3D%20%2Fstatus%20%7B%0A%20%20%20%20%20%20%20include%20fastcgi_params%3B%0A%20%20%20%20%20%20%20fastcgi_param%20SCRIPT_NAME%20'%2Fstatus'%3B%0A%20%20%20%20%20%20%20fastcgi_param%20SCRIPT_FILENAME%20'%2Fstatus'%3B%0A%20%20%20%20%20%20%20fastcgi_pass%20127.0.0.1%3A9000%3B%0A%20%20%20%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Hanli_Ren_1-1649062926895.png%22%20style%3D%22width%3A%20514px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361053iA60352A0B2317031%2Fimage-dimensions%2F514x371%3Fv%3Dv2%22%20width%3D%22514%22%20height%3D%22371%22%20role%3D%22button%22%20title%3D%22Hanli_Ren_1-1649062926895.png%22%20alt%3D%22Hanli_Ren_1-1649062926895.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E5.%20Modify%20customer%20startup%20command%20to%20overwrite%20Nginx%20and%20php-fpm%20config%20file%20with%20your%20customized%20settings%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%3CSPAN%3EPut%20the%20following%20command%20in%20the%20startup%20script%3A%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-bash%22%3E%3CCODE%3Ecp%20%2Fhome%2Fwww.conf%20%2Fusr%2Flocal%2Fetc%2Fphp-fpm.d%2Fwww.conf%3B%20cp%20%2Fhome%2Fdefault%20%2Fetc%2Fnginx%2Fsites-enabled%2Fdefault%3B%20service%20nginx%20restart%0A%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Hanli_Ren_2-1649063040793.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361054i2E675C39B78BD2C6%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Hanli_Ren_2-1649063040793.png%22%20alt%3D%22Hanli_Ren_2-1649063040793.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E6.%20By%20accessing%20the%20%3CA%20href%3D%22https%3A%2F%2F%26lt%3Bwebapp-name%26gt%3B.azurewebsites.net%2Fstatus%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2F%3CWEBAPP-NAME%3E.azurewebsites.net%2Fstatus%3C%2FWEBAPP-NAME%3E%3C%2FA%3E%26nbsp%3Buri%20of%20your%20App%20Service%2C%20you%20should%20be%20able%20to%20monitor%20the%20php-fpm%20usage%20status%20in%20live%20time.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Hanli_Ren_3-1649063105738.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F361055iD056A51F909E4DEE%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Hanli_Ren_3-1649063105738.png%22%20alt%3D%22Hanli_Ren_3-1649063105738.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3275136%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EPHP%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Apr 04 2022 02:07 AM
Updated by: