A single-container LAMP stack (Linux, Apache, MariaDB, PHP) for development in VS Code and GitHub Codespaces. Perfect for introductory web development courses in PHP and HTML.
- Single Container: Everything runs in one container for simplicity
- Full LAMP Stack:
- Linux (Ubuntu 22.04)
- Apache 2.4 Web Server
- MariaDB 10.6 Database
- PHP 8.1 with common extensions
- Multiple Projects: Organize projects in subdirectories
- Auto-configured: Services start automatically
- Development-ready: Includes error reporting and helpful PHP settings
- Click the Code button on this repository
- Select Create codespace on main
- Wait for the container to build and start
- Access your web server at the forwarded port 80
- Install Docker Desktop
- Install the Dev Containers extension for VS Code
- Clone this repository
- Open the folder in VS Code
- When prompted, click "Reopen in Container" (or use Command Palette: "Dev Containers: Reopen in Container")
- Wait for the container to build and start
- Access your web server at
http://localhost
Simply create PHP files in the workspace root or any subdirectory:
<?php
// hello.php
echo "Hello, World!";
?>Access at: http://localhost/hello.php
Organize multiple projects in subdirectories:
/workspace
├── project1/
│ ├── index.php
│ └── about.php
├── project2/
│ └── index.html
└── shared/
└── config.php
- Project 1:
http://localhost/project1/ - Project 2:
http://localhost/project2/
Connection Details:
- Host:
localhost - Username:
root - Password: (empty)
- Port:
3306
Example PHP Connection:
<?php
$conn = new mysqli("localhost", "root", "");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
$conn->close();
?>Using MySQL Command Line:
mysql -u rootVisit these pages to verify everything is working:
http://localhost/welcome.html- Welcome page with infohttp://localhost/index.php- PHP info pagehttp://localhost/test-db.php- Database connection test
PHP is configured for development with:
- Error reporting enabled
- Display errors enabled
- 64MB upload limit
- Short open tags enabled
To modify PHP settings, edit /etc/php/8.1/apache2/php.ini inside the container.
Apache is configured to:
- Serve files from
/workspace(your repository root) - Allow
.htaccessoverrides - Enable
mod_rewritefor clean URLs - Support multiple directories
The Apache configuration is located at /etc/apache2/sites-available/000-default.conf.
Services start automatically, but you can also control them manually:
# Restart Apache
sudo service apache2 restart
# Restart MariaDB
sudo service mariadb restart
# Check service status
sudo service apache2 status
sudo service mariadb statusmysql -u root -e "CREATE DATABASE myapp;"Or in PHP:
<?php
$conn = new mysqli("localhost", "root", "");
$conn->query("CREATE DATABASE IF NOT EXISTS myapp");
$conn->close();
?>mysql -u root database_name < backup.sqlComposer is not included by default. Install it if needed:
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composerIf services aren't running, start them manually:
bash /usr/local/bin/start-services.shIf port 80 or 3306 is already in use on your host machine, you can modify the port forwarding in .devcontainer/devcontainer.json.
The container runs as the vscode user with sudo access. If you encounter permission issues:
sudo chown -R vscode:vscode /workspace- Base Image: Ubuntu 22.04
- User:
vscode(non-root with sudo) - Apache Version: 2.4
- PHP Version: 8.1
- MariaDB Version: 10.6
- Document Root:
/workspace(your repository directory)
This container is designed for teaching introductory web development with PHP. It provides:
- A simple, single-container setup (no Docker Compose complexity)
- Immediate feedback with error reporting enabled
- Easy database access without authentication barriers
- Support for multiple student projects in one workspace
- Real-world LAMP stack experience
- No database password
- Permissive Apache settings
- Enabled error display
- Root MySQL access from anywhere
Never use this configuration in production environments.
MIT License - Feel free to use this for educational purposes.