Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/components/Docs/Navigation.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>
<nav>
<ul role="list">
<li class="relative my-6">
<li class="relative my-6" v-if="navigation[0]._path != '/docs'">
<h2 class="text-xs font-semibold text-white">
{{ navigation[0].title }}
</h2>
Expand Down
139 changes: 139 additions & 0 deletions docs/content/docs/2.getting-started/1.quickstart.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
---
head.title: 'Quickstart - Docker PHP - Server Side Up'
description: 'Get started with serversideup/php Docker Images.'
layout: docs
---

# Quickstart

**serversideup/php** provides a variety of PHP Docker images that are optimized for production use. You can find the list of available images in the [installation guide](/docs/getting-started/installation). For this quickstart guide, we'll use the `serversideup/php:8.4-fpm-nginx-alpine` image.

## Setting Up Your Demo Application

Create a simple PHP application structure:

::code-panel
---
label: Directory Structure
---
```shell
.
├── demo-app
│   └── public
│       └── index.php
├── docker-compose.yaml
└── Dockerfile
````
::

Next, create the `index.php` file inside the `demo-app/public` directory with the following content:

::code-panel
---
label: index.php
---
```php
<?php

phpinfo();
```
::

## Docker Examples

Depending on your production environment, you may have a single small server with docker installed, or you may have kubernetes cluster. Regardless, we'll cover both docker compose and dockerfile options.

The `serversideup/php:8.4-fpm-nginx-alpine` image includes Nginx, pre-configured to serve files from the `/var/www/html/public` directory. For more information on default configurations and environment variables, refer to our [default configurations](/docs/getting-started/default-configurations) and the [environment variable specification](/docs/reference/environment-variable-specification).

### 1\. Running with Docker Compose

Docker Compose is used to define and run multi-container Docker applications, simplifying environment setup and execution.

Create a `docker-compose.yaml` file in your project's root directory:

::code-panel
---
label: docker-compose.yaml
---
```yaml
services:
sample-app:
image: serversideup/php:8.4-fpm-nginx-alpine
ports:
- "80:8080"
environment:
- PHP_OPCACHE_ENABLE=1
volumes:
- ./demo-app:/var/www/html
```
::

**Explanation:**

* `image: serversideup/php:8.4-fpm-nginx-alpine`: Specifies the Docker image.
* `ports: - "80:8080"`: Maps host port `80` to container port `8080` (where Nginx listens).
* `environment: - PHP_OPCACHE_ENABLE=1`: Activates **OPcache**, a PHP extension for performance improvement.
* `volumes: - ./demo-app:/var/www/html`: Mounts your local `demo-app` directory into the container's `/var/www/html` path. Local file changes are reflected in the running container.

To run your application, navigate to your project's root directory in your terminal and execute:

::code-panel
---
label: Run Docker Compose
---
```bash
docker compose up
```
::

Visit [http://localhost](http://localhost) in your web browser. The `phpinfo()` output confirms your application is running.

### 2\. Building with a Dockerfile

A Dockerfile allows you to create a custom, self-contained image that includes your application. This method is suitable for building deployable images.

Create a `Dockerfile` in your project's root directory:

::code-panel
---
label: "Dockerfile"
---
```dockerfile
FROM serversideup/php:8.4-fpm-nginx-alpine

COPY ./demo-app /var/www/html

ENV PHP_OPCACHE_ENABLE=1
```
::

**Explanation:**

* `FROM serversideup/php:8.4-fpm-nginx-alpine`: Sets the base image for your Docker build.
* `COPY ./demo-app /var/www/html`: Copies the contents of your local `demo-app` directory into the `/var/www/html` path inside the Docker image.
* `ENV PHP_OPCACHE_ENABLE=1`: Sets the environment variable to enable OPcache.

To build and run your image: First, build your Docker image, tagging it as `sample-app` then run the built image, mapping the necessary ports:

::code-panel
---
label: Build and Run Dockerfile
---
```bash
docker build -t sample-app .
docker run -p 80:8080 sample-app
```
::

Then, visit [http://localhost](http://localhost) in your browser. The `phpinfo()` output indicates your Dockerfile-built application is running.

## Next Steps

For further details and advanced usage, refer to the comprehensive documentation.

* [Installation](/docs/getting-started/installation)
* [Default Configurations](/docs/getting-started/default-configurations)
* [Laravel Automations](/docs/laravel/laravel-automations)
* [Environment Variable Specification](/docs/reference/environment-variable-specification)
* [Customizing the Image](/docs/customizing-the-image)
* [Installing Additional PHP Extensions](/docs/customizing-the-image/installing-additional-php-extensions)
8 changes: 7 additions & 1 deletion docs/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,5 +83,11 @@ export default defineNuxtConfig({
plugins: [tailwindTypography]
},
cssPath: '~/assets/css/tailwind.css',
}
},

routeRules: {
"/docs": {
redirect: "/docs/prologue/introduction",
},
},
})