back_image
blog-image

How to Install PHP8.3 and MySQL 8.0 on Ubuntu 22.04 in Microsoft Azure using NGINX Server?

13 minutes
Author Image By Tech Team

Last Updated: May 2, 2024

13 minutes

This blog tutorial will assist you in understanding the installation concept of PHP8.3 and MySQL 8.0 on Ubuntu 22.04 using the NGINX server on Microsoft Azure.

Here, we’ll go over all the requirements and other information you need to install PHP 8.3 and MySQL 8.0 on Ubuntu 22.04 on Microsoft Azure using the NGINX Server.

Furthermore, we will comprehend the distinction between utilizing PHP in FPM as opposed to PHP alone, as well as the advantages of NGINX over Apache.

So, move your eyeball with the content and implement the procedure gradually to drive smoothen installation. Let’s Begin!


What is a VM (Virtual Machine) and Why do you need it?


Establishing a VM (Virtual Machine) is a prerequisite for installing PHP 8.3 and MySQL 8.0 on Ubuntu 22.04 on Microsoft Azure with NGINX Server. Let me tell you about the virtual machine (VM) and how it operates for now.

What it is —- A virtual machine (VM) is a software emulation made up of a physical computer that enables you to run on a single physical machine on multiple operating systems. A VM (Virtual Machine) will assist you in offering a virtualized environment for deploying and managing software components independently like installing PHP 8.3 and MySQL 8.0 on Ubuntu 22.04 in Microsoft Azure using an NGINX server.

How will it assist you —- Creating a virtual machine (VM) is essential to set up PHP 8.3, MySQL 8.0, and NGINX on Ubuntu 22.04 in Microsoft Azure since it offers a dedicated, isolated, flexible, scalable, secure, manageable, and compatible environment for cloud services like the mention components.

The VM allows for customization, and efficient resource allocation and makes the PHP 8.3 installation process easier to manage and maintain in secure environments. Virtual Machine creation ensures that PHP 8.3 and MySQL 8.0 run smoothly on Ubuntu 22.04 while working with the NGINX web server.


How to Establish a VM? | Prerequisites for Installing PHP 8.3


In order to install PHP8.3 and MySQL 8.0 on Ubuntu 22.04 in Microsoft Azure using NGINX Server, you must first follow the instructions below to easily establish a virtual machine (VM).


First, go to https://portal.azure.com/ home page and click on “Create a Resource” (+ icon) from Azure Services.



Next, you have to choose Ubuntu 22.04 and have to click on the —- “Start button” among all three available options.



Click on the —- “Start Free” button and execute your signing-in procedure. Once, it’s done, then it’ll ask you to follow the payment processing details, so fill out them.



Once, it’s done, you’ll come to the “Create a Virtual Machine” option.

Here the “Create your Virtual Machine (VM)” procedure will open to you.



So, you need to choose the details like Machine name, availability, security type, image, public ports, Ubuntu version, and size of the machine with their respective pricing. Plus, user name, license, key pair name, inbound ports, etc, and finally click on the —- “Next: Disk” option.



Once, you have clicked on the —- Next: disk button, then you have to choose the requirements like OS disk size, disk type, key management, and so on. Consequently, click on the —- “Create and attach a new disk” option.



Under the “Create and attach new disk” option, choose the details like your new disk name, source type, size, and key management, and choose your disk size as well. For this, Click on the —- size option.



From here, you have to select the ideal size for your disk along with the performance tier, provisioned IOPS, provisioned throughput, Max share, Max burst IOPS, custom disk name, and more. As a consequence, have to click on the —- Ok button.


After reviewing your entire details and making the required changes, click on the —- “Review + Create button”.



Here, your Virtual Machine (VM) has been created. Once, you have created your VM, then you are ready to install PHP 8.3 and operate it for further usage.


How To Install PHP 8.3? | A stepwise Installation Guide


Once you have established a VM (Virtual Machine) then you directly can install PHP 8.3 and MySQL 8.0 on Ubuntu 22.04 in Microsoft Azure using NGINX Server. For this, let’s follow the steps:



Click on your —- established VM (Virtual Machine) from the dashboard of the VM.

Click on the —- Connect Option showing on the top mid and select only the connect option.

Next click on the —- Select option of SSH Using Azure CLI, here you need to click on the retectgular box to accept the guidelines and click on the —- Close button showing down to Configure + Connect button.

Doing this, the command box or terminal will open to you. Here, you have to give the following commands and run them respectively.

Now, the terminal will give you —- Welcome to Azure – Cloud shell along with a dialogue box.

From the dialogue box, you have to click on the —- Continue option.


Next, Terminal will ask you to request with the text —- Are you Sure you wanna continue connecting (Yes/No)?


Now, you have to write —- Yes and press enter.

For further process, you have to run commands like:


sudo su
apt update
apt upgrade
apt install nginx

Next, it will ask you for further continuation with the text —- Do you wanna continue (Yes/No)?


Again, you have to write —- Yes and press enter.

Next to this, a dialogue box will appear to you with the text —- Pending Kernal Configuration, Hence you have to click on the —- Ok button.

Next, the directory will open to you along with the machine name you have given at the time of creation.

Now, we’ll move to install MySQL 8.0 which is available in the default Ubuntu repository. (Install MySQL 8.0).


apt install mysql-server
mysql_secure_installation

Next, you have to add the PHP repository and then install PHP 8.3 (Install PHP 8.3).


add-apt-repository ppa:ondrej/php
apt update
apt install php8.3-fpm php8.3-mysql php8.3-common php8.3-cli

Here, you need to create a new server block configuration file in the NGINX sites-available directory (Configure NGINX to work with PHP). Additionally, you’ve to replace example.com with your required domain name. Like this:


nano /etc/nginx/sites-available/example.com

Next to the previous step, you need to restart your NGINX server for further implementation with the given command.


systemctl restart nginx

Here, you are free to upload your Website Files:

  • Upload your website files to /var/www/example.com directory.

Additionally, free to test your Setup:

  • Open your web browser and navigate to your server’s IP address or domain name. You should see your website running.

Here, your PHP8.3 and MySQL 8.0 have been installed on Ubuntu 22.04 in Microsoft Azure using NGINX Server. Consequently, your PHP8.3 is prepared to carry out your next tasks..

Official Source: https://www.linuxtuto.com/how-to-install-php-8-3-on-ubuntu-22-04/#


In What Ways PHP in FPM is Beneficial? Why FPM is Essential?


Before counting on the benefits of PHP in FPM, let me introduce you to the concept of (FPM) FastCGI (Common Gateway Interface) Processing Manager and role.


What is FPM?


FPM is the abbreviation for FastCGI (Common Gateway Interface) Process Manager. The implementation of FastCGI (Common Gateway Interface) Process Manager assists you in managing and controlling PHP processes by serving as an additional feature of PHP.

FPM has been designed to improve the performance and scalability of PHP-based web applications by efficiently handling PHP requests.


The Role of PHP in FPM


PHP in FPM serves as the scripting language engine that processes the PHP code in response to web requests. FPM acts as a manager for PHP processes that handle tasks such as process creation, management, and termination based on the incoming workload. FPM offers a collection of PHP workers that helps in handling multiple concurrent requests, optimizing resource utilization, and response times.


Benefits of Using PHP in FPM


Performance Optimization:


FPM optimizes PHP performance by offering a pool of PHP processes that helps to reduce the overhead of process creation and termination compared to traditional CGI-based PHP setups.


Scalability:


FPM provides a configuration of multiple PHP process pools that enables horizontal scalability whereas each PHP process serves a specific set of requests. Which is very crucial for handling varying traffic loads effectively.


Resource Management:


FPM also provides control over PHP process resources, such as memory usage, enhancing stability, execution time limits, and preventing resource exhaustion.


Process Isolation:


As we’ve mentioned, it offers FPM offers multiple PHP processes whereas each PHP process operates independently to ensure better isolation and security between different requests and also to reduce the risk of one request impacting others.


Fault Tolerance:


FPM includes features that aid in managing process failures, automatic restarts, and improving the overall reliability of PHP applications.


Why Should You Use PHP in FPM instead of using PHP Only?


Using PHP without FPM is just like (using Apache’s mod_php or CGI-based PHP), PHP in FPM offers better performance, scalability, better processing, and resource management compared to using only PHP.

FPM optimizes PHP process handling, enhances isolation, and allows for finer control over PHP resources that lead to more efficient and reliable web applications.


What Does Nginx Offer that Apache Doesn’t?


Nginx and Apache

The Nginx server is continuously emerging because of its incredible & innovative features, as well as developers, are perpetuating to use of Nginx instead of working on Apache.

Hence, let’s do a quick comparison between both servers and understand which one is better for you or how Nginx is better than Apache.


Nginx ServerApache Server
Solves the C10K Problem:

Within the NGINX server, you are allowed to handle a large number of clients simultaneously since it offers the features of the C10k problem that optimizes network sockets addressing the C10K problem.
Handling of Static Files:

Using the Apache server, you can get static files like HTML, CSS, images, and JavaScript directly without any additional processing.
Reverse Proxy:

Reverse Proxy is the most amazing feature of NGINX which maintains the incoming traffic and distributes it efficiently to backend servers including legacy systems and microservices.
Handling of Static Files:

Using the Apache server, you can get static files like HTML, CSS, images, and JavaScript directly without any additional processing.
HTTP/3 Support:

In the case of modern web application functionality, you can expect NGINX a perfect server as it supports to latest HTTP/3 protocol that helps improve performance, reduces latency and enriches gross security.
Loadable Dynamic Modules:

Operating Apache you’re allowed to have additional functionality for dynamic modules that will assist you in extending your server functionality. By doing this, you would be enabled to use features like handling different scripting languages like PHP or Perl.
Containerization Support:

NGINX seamlessly integrates with containerization platforms like Docker and Kubernetes to provide scalable and reliable application delivery within containerized environments.
Auto-Indexing:

In case, you don’t have an index file (like index.html) in your directory on the server, Apache will automatically generate a listing of the files in that directory for you to browse.
Minimized Tooling:

The multifunctionality of NGINX reduces the need for multiple tools and simplifies the configuration and maintenance of organizations.
.htaccess:

Apache used .htaccessas as a configuration file to apply directory-level configuration settings. It will help you to flow things better like password protection, URL redirection, and custom error pages without having access to the main server configuration file.
Cloud-Native Integration:

NGINX as light and smooth as you can seamlessly integrates it with cloud platforms like AWS, Azure, Google Cloud, and more to leverage cloud-native features and scale their applications dynamically.
Compatible with IPv6:

Apache now supports IPv6, the newer version of the Internet Protocol that allows you to communicate over IPv6 networks.
Logging and Monitoring:

NGINX offers comprehensive logging and monitoring capabilities that allow administrators to track the server’s performance, analyze the traffic patterns, and troubleshoot issues effectively.
Supports HTTP/2:

Using the Apache server, you also don’t need to be concerned about better performance and efficiency since the HTTP/2 protocol offers very high performance and efficiency compared to HTTP/1.1.
Multifunctional Tool:

NGINX serves as a load balancer, reverse proxy, content cache, and web server, that reduces the need for multiple tools and configurations.
FTP Connections:

Apache offers the feature for configuration and is compatible with an FTP connection. Consequently, you’re allowed to configure Apache to make it supportable for FTP (File Transfer Protocol) connections & to upload and download files to and from the server.
Dynamic Content Handling:

NGINX efficiently manages dynamic content including tasks like processing PHP, Python, and other scripting languages to improve the responsiveness of the website.
Gzip Compression and Decompression:

Within this innovative feature, Apache will automatically compress content before sending it to clients, reduce bandwidth usage, and improve page load times. Along with this, Apache can also decompress compressed content that it receives from clients.
Scalable Architecture:

The scalable architecture of NGINX is suitable for various web-based tasks beyond content serving and making it versatile for different web applications.
Bandwidth Throttling:

Apache can limit the amount of bandwidth for a particular client or group of clients used, which is completely usable for managing server resources as well as for preventing abuse.
Extensive Community Support:

NGINX carries a large and active community support that provides resources and documentation, to make the deployment and managing procedure easier.
Perl, PHP, Lua Scripts:

As all know, Apache supports various scripting languages like Perl, PHP, and Lua, which make developers ready to create dynamic web applications fluently and rapidly without any hustle.
Fastest Web Server:

NGINX has been designed with the aim of the fastest web working server which consistently implements its role and outperforms its competitors like Apache in performance benchmarks.
Load Balancing:

Apache is also flexible in balancing the load by distributing the incoming web traffic across multiple servers and improving performance, scalability, and reliability.
Industry Usage:

Nginx offers the feature of High-traffic website usage which is why brands like Dropbox, Netflix, Zynga, and more are using NGINX for web server and application delivery.
Session Tracking:

Apache become a very compliant server when it comes to tracking user sessions which is essential for maintaining stateful interactions in web applications (e.g., shopping carts, logged-in sessions).
Versatility:

Alongside serving content, the NGINX server also plays a better role as a reverse proxy and load balancer for managing incoming traffic as well as distributing itself to upstream servers.
URL Rewriting:

To make your URLs search engine-friendly and to redirect old URLs to new ones, Apache’s mod_rewrite modules offer the feature of rewriting the URLs on the fly.
Performance Optimization:

NGINX efficiently handles tasks like SSL/TLS negotiation, content compression, caching, etc to improve the overall web server performance as well as user experience.
Geolocation Based on IP Address:

Using the IP addresses, Apache can determine the geographical location of users, which can be used for various purposes such as content localization, access control, and so on.
Global Content Delivery:

The content-covering capabilities and edge caching features of NGINX enable content delivery networks (CDNs) universally and reduce latency as well.
Security:

Within the features of Might security of NGINX including SSL/TLS termination, DDoS protection, IP whitelisting, and access control you can enhance your overall server and application security.
Continual Improvement:

NGINX Plus continually adds features for seamless application delivery, such as JavaScript-based configuration and dynamic module support
Efficient Handling:

In order to increase the performance of the web server performance, NGINX manages tasks such as SSL/TLS negotiation, content compression, and caching efficiently.
Global Reach:

Nginx has a Global reach for rapid, smooth, and well-working servers, consequently, over 350 million websites worldwide rely on NGINX for fast, reliable, and secure content delivery.
NGINX Plus Features:

NGINX Plus consistently adds innovative functionalities for hasty and flawless application delivery, such as JavaScript configuration that supports dynamic modules.

Let’s Recap Before You Go!

This blog post will give you comprehensive & step-by-step guidance that will catch all the information & every executing point for Installing PHP8.3 & MySQL 8.0. Whereas, we will use Ubuntu 22.04 OS version and NGINX Server in Microsoft Azure. Along with this, here you’ll get prerequisites, benefits of the NGINX server over Apache, & other additional information like the significance of PHP in FPM instead of PHP alone. Therefore, without causing a delay, follow the steps and install PHP8.3 for a smoother workflow.

Stay updated by signing up for our newsletter

Read our full Privacy Policy here.