php
49 TopicsAnnouncing 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.28KViews9likes6CommentsReference Architecture for a High Scale Moodle Environment on Azure
Introduction Moodle is an open-source learning platform that was developed in 1999 by Martin Dougiamas, a computer scientist and educator from Australia. Moodle stands for Modular Object-Oriented Dynamic Learning Environment, and it is written in PHP, a popular web programming language. Moodle aims to provide educators and learners with a flexible and customizable online environment for teaching and learning, where they can create and access courses, activities, resources, and assessments. Moodle also supports collaboration, communication, and feedback among users, as well as various plugins and integrations with other systems and tools. Moodle is widely used around the world by schools, universities, businesses, and other organizations, with over 100 million registered users and 250,000 registered sites as of 2020. Moodle is also supported by a large and active community of developers, educators, and users, who contribute to its development, documentation, translation, and support. [URL] is the official website of the Moodle project, where anyone can download the software, join the forums, access the documentation, participate in events, and find out more about Moodle. Goal The goal for this architecture is to have a Moodle environment that can handle 400k concurrent users and scale in and out its application resources according to usage. Using Azure managed services to minimize operational burden was a design premise because standard Moodle reference architectures are based on Virtual Machines that comes with a heavy operational cost. Challenges Being a monolith application, scaling Moodle in a modern cloud native environment is challenging. We choose to use Kubernetes as its computing provider due to the fact that it allow us to build a Moodle artifact in an immutable way that allows it to scale out and in when needed in a fast and automatic way and also recover from potential failures by simply recreating its Deployments without the need to maintain Virtual Machine resources, introducing the concept of pets vs cattle[1] to a scenario that at first glance wouldn't be feasible. Since Moodle is written in PHP it has no concept of database polling, creating a scenario where its underlying database is heavily impacted by new client requests, making it necessary to use an external database pooling solution that had to be custom tailored in order to handle the amount of connections for a heavy-traffic setup like this instead of using Azure Database for PostgreSQL's built-in pgbouncer. The same effect is also observed in its Redis implementation, where a custom Redis cluster had to be created, whereas using Azure Cache for Redis would incur prohibitive costs due to the way it is set up for a more general usage. 1 - https://learn.microsoft.com/en-us/dotnet/architecture/cloud-native/definition#the-cloud Architecture This architecture uses Azure managed (PaaS) components to minimize operational burden by using Azure Kubernetes Service to run Moodle, Azure Storage Account to host course content, Azure Database for PostgreSQL Flexible Server as its database and Azure Front Door to expose the application to the public as well as caching commonly used assets. The solution also leverages Azure Availability Zones to distribute its component across different zones in the region to optimize its availability. Provisioning the solution The provisioning has two parts: setting up the infrastructure and the application. The first part uses Terraform to deploy easily. The second part involves creating Moodle's database and configuring the application for optimal performance based on the templates, number of users, etc. and installing templates, courses, plugins etc. The following steps walk you through all tasks needed to have this job done. Clone the repository $ git clone https://github.com/Azure-Samples/moodle-high-scale Provision the infrastructure $ cd infra/ $ az login $ az group create --name moodle-high-scale --location <region> $ terraform init $ terraform plan -var moodle-environment=production $ terraform apply -var moodle-environment=production $ az aks get-credentials --name moodle-high-scale --resource-group moodle-high-scale Provision the Redis Cluster $ cd ../manifests/redis-cluster $ kubectl apply -f redis-configmap.yaml $ kubectl apply -f redis-cluster.yaml $ kubectl apply -f redis-service.yaml Wait for all the replicas to be running $ ./init.sh Type 'yes' when prompted. Deploy Moodle and its services Change image in moodle-service.yaml and also adjust the moodle data storage account name in the nfs-pv.yaml (see commented lines in the files) $ cd ../../images/moodle $ az acr build --registry moodlehighscale<suffix> -t moodle:v0.1 --file Dockerfile . $ cd ../../manifests $ kubectl apply -f pgbouncer-deployment.yaml $ kubectl apply -f nfs-pv.yaml $ kubectl apply -f nfs-pvc.yaml $ kubectl apply -f moodle-service.yaml $ kubectl -n moodle get svc –watch Provision the frontend configuration that will be used to expose Moodle and its assets publicly $ cd ../frontend $ terraform init $ terraform plan $ terraform apply Approve the private endpoint connection request from Frontdoor in moodle-svc-pls resource. Private Link Services > moodle-svc-pls > Private Endpoint Connections > Select the request from Front Door and click on Approve. Install database $ kubectl -n moodle exec -it deployment/moodle-deployment -- /bin/bash $ php /var/www/html/admin/cli/install_database.php --adminuser=admin_user --adminpass=admin_pass --agree-license Deploy Moodle Cron Change image in moodle-cron.yaml $ cd ../manifests $ kubectl apply -f moodle-cron.yaml Your Moodle installation is now ready to use! Conclusion You can create a Moodle environment that is scalable and reliable in minutes with a very simple approach, without having to deal with the hassle of operating its parts that normally comes with standard Moodle installations.921Views8likes0CommentsAzure 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.92KViews8likes9CommentsWhat'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!25KViews4likes3CommentsWhat's New in Azure App Service at Build 2024
The team will be covering the latest AI enhancements for migrating web applications, how AI helps developers to monitor and troubleshoot applications, examples of integrating generative AI into both classic ASP.NET and .Net Core apps, and platform enhancements for scaling, load testing, observability, WebJobs and sidecar extensibility.10KViews3likes1CommentEasy way to migrate an existing PHP site with MySQL to Azure App Service.
In this blog, we will cover the easy way to migrate an existing PHP site with MySQL to Azure App Service. In case you do not have an existing App Service and Azure Database for MySQL setup, you can follow this blog: Tutorial: PHP app with MySQL - Azure App Service | Microsoft Learn. This setup will create a VNET and MySQL database where the MySQL access will be locked down and not exposed to the public internet, which is compliant with recommended best practices for security. To migrate your PHP code to Azure App Service, we can use one of the deployment methods such as Zip Deploy: Run your app from a ZIP package - Azure App Service | Microsoft Learn During the deployment to install any application dependencies like composer packages add an app setting, SCM_DO_BUILD_DURING_DEPLOYMENT , and setting it to 1 . To migrate the MySQL database, we can use the Azure App Service Kudu console. The easiest way to get to the Kudu console would be to go directly to http://yoursitename.scm.azurewebsites.net/newui (replace "yoursitename" with your actual Web App name) through the browser. You can also launch the Kudu console from the Azure portal: Select "File Manager" and drag or upload the "dump.sql" file to the /home/site directory and the certificate needed to communicate over SSL, which you can get from the Azure Portal. Select "WebSSH" and go to /home/site, run the below command to import the sql dump after replacing Username, Password, Hostname, port (which is 3306 by default), and destination database name: mysql -h Hostname -u Username -p --ssl-ca=/home/site/DigiCertGlobalRootCA.crt.pem destination_database_name < dump.sql This should populate all your data from "dump.sql" into the Azure MySQL - Flexible MySQL database over a secure connection. To establish a secure connection to Azure Database for MySQL over SSL from your application, refer to the following code samples: Configure SSL - Azure Database for MySQL | Microsoft Learn For a Drupal application secure database connection, use the below code: $databases['default']['default'] = array ( 'database' => 'quickstartdb', 'username' => ‘myadmin@mydemoserver, 'password' => ‘yourpassword', 'prefix' => '', 'host' => 'mydemoserver.mysql.database.azure.com ', 'port' => '3306', 'namespace' => 'Drupal\\mysql\\Driver\\Database\\mysql', 'driver' => 'mysql', 'autoload' => 'core/modules/mysql/src/Driver/Database/mysql/', 'pdo' => [ \PDO::MYSQL_ATTR_SSL_CA =>'/home/site/DigiCertGlobalRootCA.crt.pem', \PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false ], ); To modify the existing NGINX site configuration, please refer to: NGINX Rewrite Rules for Azure App Service Linux PHP 8.x - (azureossd.github.io)8.1KViews3likes0CommentsConfigure 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 WordPress65KViews3likes7CommentsTransition from Alpine Linux to Debian for WordPress on App Service
We are excited to share with you that we will be transitioning from Alpine to Debian as the default Linux distribution for WordPress on App Service. While Alpine has served us well with its lightweight and performant nature, our evolving needs require a more feature-rich environment. Debian is the ideal candidate to support our next phase of development and growth. This transition will also align us with App Service Linux, which already utilizes Debian as the default Linux distribution.9.6KViews2likes11Comments