php
47 TopicsAzure App Service Logging: How to Monitor Your Web Apps in Real-Time
As a developer, having visibility into the behavior of your applications is crucial to maintaining the reliability and performance of your software. Luckily, Azure App Service provides two powerful logging features to help you monitor your web apps in real-time: App Service Logs and Log Stream. In this blog post, we'll explore how to configure these features for both Windows and Linux Web Apps in Azure App Service.92KViews8likes9CommentsConfigure Nginx for PHP 8 Linux Azure App Service
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. If you previously defined custom rules in .htaccess will be lost and will highly possible break your app. But Nginx does not have an equivalent to the .htaccess file, you need to update the main configuration and reload Nginx for any changes to take effect. NGINX is designed to be efficient. While using .htaccess can do harm to performance. For more details, please refer to https://www.nginx.com/resources/wiki/start/topics/examples/likeapache-htaccess/. This article shows how to deploy a customized Nginx configuration in PHP 8 Linux App Service. Inside App Service built-in PHP 8 docker image, the Nginx configuration is stored in /etc/nginx/sites-enabled/default file. The following steps can be used to create your own customized Nginx configuration based on the default one. 1. Firstly, we need to copy /etc/nginx/sites-enabled/default to the /home folder By default, App Service set WEBSITES_ENABLE_APP_SERVICE_STORAGE = true. Files stored in /home path are persisted in an Azure Storage file share, which can survive restart and shared across scale instances. So we need to save your own Nginx configure file under /home path. Go to App Service WEBSSH via https://<AppServiceName>.scm.azurewebsites.net/webssh/host cp /etc/nginx/sites-enabled/default /home/default 2. Make Nginx configuration changes to the /home/default file. vi /home/default For example, we can turn off absolute_redirect, change root path, add rewrite rules, etc. 3. Use custom startup script to overwrite original Nginx config file. So the platform can use your configuration to start the Nginx server every time the App Service being started. Go to “Configuration” --> “General settings” in the App service Portal. Add the following command in the “Startup Command” cp /home/default /etc/nginx/sites-enabled/default; service nginx restart When you change the Startup Command and save the setting, the App Service will be Restarted and begin to use your customized configuration to start the Nginx server. More Reference Documents: Full example of nginx.conf Nginx PHP FastCGI Example Apache .htaccess to NGINX converter Nginx config for WordPress65KViews3likes7CommentsAnnouncing the General Availability of WordPress on Azure App Service
We are thrilled to announce that WordPress on Azure App Service, which was running on Public Preview since 15 February 2022, has been made Generally Available on 8 August 2022. To read the Public Preview Announcement read the blog post on The new and better ‘WordPress on App Service’ - Microsoft Tech Community.28KViews9likes6CommentsWhat's New in Azure App Service at Build 2022
See what new features the Azure App Service team is announcing at Build 2022 including gRPC support, an updated Azure Migrate experience, virtual network support in Basic tier and architecture guidance with a new Landing Zone Accelerator!25KViews4likes3CommentsUse php-fpm log to troubleshoot PHP 8 Linux Azure App Service
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. The meaning of the format arguments are provided in the www.conf file 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 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. 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 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 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. In my /home/Logfiles/www.log.slow record, I can see detailed call stack in the log for the slow requests. 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 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; } 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 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.20KViews1like1CommentAdd MIME Types to Nginx - Linux App Service (PHP 8.x blessed image)
The document helps in resolving the following common error message from nginx: Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec. by adding MIME Type support for same.18KViews1like1Comment