This is a sample repository for deploying a PHP application and serving it on a domain using StackHead, the Open-Source Web Server management.
It provides examples for deploying a single and multi container applications.
In order to try out this sample project, you'll need the following:
- StackHead CLI binary file
- Ansible 2.10 or later
- a web server with root SSH access (we recommend renting a pay-per-use VPS at Hetzner. Get 20€ cloud balance for free)
- a top level (sub) domain with A record pointing to your server IP
Initialize StackHead by running the command below. This will install all dependencies required.
stackhead-cli init
stackhead-cli setup 159.69.20.148
After provisioning completed, you should see the Nginx default page when opening your domain in your browser.
The following sections describe how to configure the samples for your server and domain. There are two differently sized projects, consisting of one single container and multiple containers.
-
Adjust the project settings in
.stackhead/project/single-container.stackhead.yml
- Set your own domain in
domain
- Set your own domain in
-
Validate your project file using the
validate
command:stackhead-cli project validate ./.stackhead/project/single-container.stackhead.yml
-
Deploy the application. Make sure to replace
159.69.20.148
with your servers IP address.stackhead-cli project deploy ./.stackhead/project/single-container.stackhead.yml 159.69.20.148
-
After deployment, open the domain in your web browser. You should see a page that prints "Hello world!" alongside the PHP version and successful database connection.
-
Remove the application:
stackhead-cli project destroy ./.stackhead/project/single-container.stackhead.yml
-
Adjust the project settings in
.stackhead/project/multi-container.stackhead.yml
- Set your own domain in
domain
- Set your own domain in
-
Validate your project file using the
validate
command:stackhead-cli project validate ./.stackhead/project/multi-container.stackhead.yml
-
Deploy the application. Make sure to replace
159.69.20.148
with your servers IP address.stackhead-cli project deploy ./.stackhead/project/multi-container.stackhead.yml 159.69.20.148
-
After deployment, open the domain in your web browser. You should see a page that prints "Hello world!" alongside the PHP version and successful database connection.
You can access PhpMyAdmin on port 81 (no HTTPS).
-
Remove the application:
stackhead-cli project destroy ./.stackhead/project/multi-container.stackhead.yml