Skip to content

Commit d438455

Browse files
authored
Merge pull request #2376 from odidev/php_LP
Deploy PHP on Google Cloud C4A (Arm-based Axion VMs)
2 parents d90e7d6 + bfa2402 commit d438455

File tree

9 files changed

+504
-0
lines changed

9 files changed

+504
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: Deploy PHP on Google Cloud C4A (Arm-based Axion VMs)
3+
4+
draft: true
5+
cascade:
6+
draft: true
7+
8+
minutes_to_complete: 30
9+
10+
who_is_this_for: This is an introductory topic for software developers migrating PHP workloads from x86_64 to Arm-based servers, specifically on Google Cloud C4A virtual machines built on Axion processors.
11+
12+
13+
learning_objectives:
14+
- Provision an Arm-based SUSE SLES virtual machine on Google Cloud (C4A with Axion processors)
15+
- Install PHP on a SUSE Arm64 (C4A) instance
16+
- Validate PHP functionality with baseline HTTP server tests
17+
- Benchmark PHP performance using PHPBench on Arm64 (Aarch64) architecture
18+
19+
20+
prerequisites:
21+
- A [Google Cloud Platform (GCP)](https://cloud.google.com/free) account with billing enabled
22+
- Basic familiarity with web servers and PHP scripting
23+
author: Pareena Verma
24+
25+
##### Tags
26+
skilllevels: Introductory
27+
subjects: Web
28+
cloud_service_providers: Google Cloud
29+
30+
armips:
31+
- Neoverse
32+
33+
tools_software_languages:
34+
- PHP
35+
- apache
36+
- PHPBench
37+
38+
operatingsystems:
39+
- Linux
40+
41+
# ================================================================================
42+
# FIXED, DO NOT MODIFY
43+
# ================================================================================
44+
further_reading:
45+
- resource:
46+
title: Google Cloud documentation
47+
link: https://cloud.google.com/docs
48+
type: documentation
49+
50+
- resource:
51+
title: PHP documentation
52+
link: https://www.php.net/
53+
type: documentation
54+
55+
- resource:
56+
title: PHPBench documentation
57+
link: https://github.com/phpbench/phpbench
58+
type: documentation
59+
60+
weight: 1
61+
layout: "learningpathall"
62+
learning_path_main_page: "yes"
63+
---
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# ================================================================================
3+
# FIXED, DO NOT MODIFY THIS FILE
4+
# ================================================================================
5+
weight: 21 # Set to always be larger than the content in this path to be at the end of the navigation.
6+
title: "Next Steps" # Always the same, html page title.
7+
layout: "learningpathall" # All files under learning paths have this same wrapper for Hugo processing.
8+
---
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
title: Getting started with PHP on Google Axion C4A (Arm Neoverse-V2)
3+
4+
weight: 2
5+
6+
layout: "learningpathall"
7+
---
8+
9+
## Google Axion C4A Arm instances in Google Cloud
10+
11+
Google Axion C4A is a family of Arm-based virtual machines built on Google’s custom Axion CPU, which is based on Arm Neoverse-V2 cores. Designed for high-performance and energy-efficient computing, these virtual machines offer strong performance for modern cloud workloads such as CI/CD pipelines, microservices, media processing, and general-purpose applications.
12+
13+
The C4A series provides a cost-effective alternative to x86 virtual machines while leveraging the scalability and performance benefits of the Arm architecture in Google Cloud.
14+
15+
To learn more about Google Axion, refer to the [Introducing Google Axion Processors, our new Arm-based CPUs](https://cloud.google.com/blog/products/compute/introducing-googles-new-arm-based-cpu) blog.
16+
17+
## PHP
18+
19+
PHP (Hypertext Preprocessor) is an open-source, server-side scripting language designed for web development.
20+
21+
It allows developers to create dynamic web pages, interact with databases, handle forms, and build web applications. PHP can be embedded directly into HTML, making it easy to generate content dynamically on the server before sending it to the browser.
22+
23+
PHP is widely used for websites, web applications, content management systems (CMS), and APIs. Learn more from the [PHP official website](https://www.php.net/) and its [official documentation](https://www.php.net/docs.php).
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
---
2+
title: PHP baseline testing on Google Axion C4A Arm Virtual Machine
3+
weight: 5
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
10+
## Baseline Setup for PHP-FPM
11+
This section covers the installation and configuration of **PHP and Apache** on a SUSE Arm-based GCP VM. It includes setting up **PHP-FPM** with a Unix socket, verifying PHP functionality via a test page, and ensuring Apache and PHP-FPM work together correctly.
12+
13+
### Configure the PHP-FPM Pool
14+
15+
**PHP-FPM:** A FastCGI Process Manager that runs PHP scripts efficiently, handling multiple requests separately from the web server for better performance and security.
16+
17+
A **pool** is basically a set of PHP worker processes that handle requests.
18+
19+
### Copy the Default Configuration (if missing)
20+
21+
Run this command to create a working config file:
22+
23+
```console
24+
sudo cp /etc/php8/fpm/php-fpm.d/www.conf.default /etc/php8/fpm/php-fpm.d/www.conf
25+
```
26+
27+
### Edit the Configuration
28+
29+
Open the config file in a text editor:
30+
31+
```console
32+
sudo vi /etc/php8/fpm/php-fpm.d/www.conf
33+
```
34+
35+
Update the file to use a Unix socket:
36+
37+
Find this line `; listen = 127.0.0.1:9000`. Replace it with these lines.
38+
39+
```ini
40+
listen = /run/php-fpm/www.sock
41+
listen.owner = wwwrun
42+
listen.group = www
43+
listen.mode = 0660
44+
```
45+
- `listen = /run/php-fpm/www.sock` → PHP will talk to Apache using a local “socket file” instead of a network port.
46+
- `listen.owner = wwwrun``wwwrun` is Apache’s default user on SUSE, so Apache can access the socket.
47+
- `listen.group = www` → sets the group to match Apache’s group.
48+
- `listen.mode = 0660` → gives read/write permission to both Apache and PHP-FPM.
49+
50+
### Start and Enable PHP-FPM
51+
52+
Restart PHP-FPM so it picks up the changes:
53+
54+
```console
55+
sudo systemctl restart php-fpm
56+
```
57+
58+
## Test PHP
59+
Now that PHP and Apache are installed, let’s verify that everything is working correctly.
60+
61+
### Create a Test Page
62+
We will make a simple PHP file that shows details about the PHP setup.
63+
64+
```console
65+
echo "<?php phpinfo(); ?>" | sudo tee /srv/www/htdocs/info.php
66+
```
67+
This creates a file named **info.php** inside Apache’s web root directory `(/srv/www/htdocs/)`. When you open this file in a browser, it will display the PHP configuration page.
68+
69+
### Test from Inside the VM
70+
Run the following command:
71+
72+
```console
73+
curl http://localhost/info.php
74+
```
75+
- `curl` fetches the page from the local Apache server.
76+
- If PHP is working, you’ll see a large block of HTML code as output.
77+
- This confirms that PHP is correctly connected with Apache.
78+
79+
You should see an output similar to:
80+
81+
```output
82+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
83+
<html xmlns="http://www.w3.org/1999/xhtml"><head>
84+
<style type="text/css">
85+
body {background-color: #fff; color: #222; font-family: sans-serif;}
86+
pre {margin: 0; font-family: monospace;}
87+
a:link {color: #009; text-decoration: none; background-color: #fff;}
88+
a:hover {text-decoration: underline;}
89+
table {border-collapse: collapse; border: 0; width: 934px; box-shadow: 1px 2px 3px rgba(0, 0, 0, 0.2);}
90+
.center {text-align: center;}
91+
.center table {margin: 1em auto; text-align: left;}
92+
.center th {text-align: center !important;}
93+
td, th {border: 1px solid #666; font-size: 75%; vertical-align: baseline; padding: 4px 5px;}
94+
th {position: sticky; top: 0; background: inherit;}
95+
h1 {font-size: 150%;}
96+
h2 {font-size: 125%;}
97+
h2 a:link, h2 a:visited{color: inherit; background: inherit;}
98+
```
99+
Basically, it is the HTML output that confirms PHP is working.
100+
101+
### Test from Your Browser
102+
Now, let’s test it from outside the VM. Open a web browser on your local machine (Chrome, Firefox, Edge, etc.) and enter the following URL in the address bar:
103+
104+
```console
105+
http://<YOUR_VM_PUBLIC_IP>/info.php
106+
```
107+
- Replace `<YOUR_VM_PUBLIC_IP>` with the public IP of your GCP VM.
108+
109+
If everything is set up correctly, you will see a PHP Info page in your browser. It looks like this:
110+
111+
![PHP-info page alt-text#center](images/php-web.png "Figure 1: PHP info")
112+
113+
This verifies the basic functionality of the PHP installation before proceeding to the benchmarking.

0 commit comments

Comments
 (0)