|
| 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 | + |
| 112 | + |
| 113 | +This verifies the basic functionality of the PHP installation before proceeding to the benchmarking. |
0 commit comments