Documentation Index
Fetch the complete documentation index at: https://docs.valyent.cloud/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
PHP is a popular server-side scripting language that makes it easy to create dynamic web pages. This guide will help you deploy a simple PHP application.
Prerequisites
- a UNIX-like system (see WSL if you are using Windows), in order to use the Valyent CLI
- a Valyent account, with a registered payment method (you can sign up here)
- PHP installed on your machine
Installing the CLI
curl -L https://cli.valyent.cloud | sh
You can inspect the installation script here and the GitHub repository.
Authenticating
Initializing the project
First, let’s create a new directory and add our PHP file:
mkdir php-app && cd php-app
touch index.php
In the index.php file, add this simple code:
<?php
echo "Hello, World!";
Now, initialize the valyent.toml configuration file:
This command will ask you to select/create a project and an associated application.
Adding the Dockerfile
Create a Dockerfile for the application:
Add the following content:
# Use the official PHP Apache image
FROM php:8.2-apache
# Copy the application files to the web server's document root
COPY . /var/www/html/
# Set appropriate permissions for the document root
RUN chown -R www-data:www-data /var/www/html
# Expose port 80
EXPOSE 80
Deploy the project
To expose the application’s port, we need to set up a gateway (in this case, the port 80):
Deploy your application to Valyent:
Once the deployment is finished, open your application:
Your simple PHP application should now display “Hello, World!” in the browser.