Automated LAMP Stack Server Provisioning via SSH - n8n Workflow

Use this powerful n8n workflow to fully automate the installation and configuration of a LAMP (Linux, Apache, MySQL, PHP) stack, development tools, and user setup on any remote server using SSH.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • DevOps Engineers: Who need repeatable, infrastructure-as-code solutions for spinning up test or staging environments.

  • Web Developers: Who want a fast way to initialize a development server with specific PHP and MySQL versions.

  • System Administrators: Looking to standardize server deployment using a low-code automation platform like n8n.

  • Automation Specialists: Seeking advanced examples of using the SSH n8n node for complex remote operations.

Overview

Setting up a complete LAMP (Linux, Apache, MySQL, PHP) development server—including virtual hosts, security hardening, user creation, and installing necessary developer tools like Composer and WP-CLI—can take significant manual time. This robust n8n workflow eliminates that inefficiency. It converts hours of repetitive terminal commands into a single, reliable automation run, saving immense time and ensuring consistency across all your server deployments. The entire process is orchestrated through a sequence of SSH commands managed by the n8n platform, demonstrating the power of using n8n templates for advanced DevOps tasks. This specific n8n workflow is highly customizable via initial parameters, allowing you to define the PHP version, MySQL password, and developer credentials upfront.

How it Works

This automation starts with a manual n8n trigger, initiating the sequential deployment process.


  1. Parameter Definition (Set n8n node): The workflow first defines crucial variables, including server connection details (host, user), database credentials (mysqlrootpassword), desired phpversion, and new developer user credentials (username, userpassword). This data is passed throughout the subsequent SSH n8n node calls.

  2. System Preparation: The first SSH n8n node updates the operating system and installs essential system dependencies (like curl, git, wget).

  3. Apache Installation: The workflow installs Apache, enables common modules (rewrite, ssl), and creates a dynamic virtual host configuration based on the provided domain_name parameter.

  4. MySQL & phpMyAdmin: MySQL server is installed, root security measures are applied, and the workflow pre-configures and installs phpMyAdmin for easy database management.

  5. PHP & Composer Setup: The automation adds the required PHP repository and installs the specified PHP version (defaulting to 8.2) along with all necessary extensions (e.g., php-mysql, php-mbstring). It also installs Composer globally and adjusts common PHP settings in php.ini.

  6. Developer Tooling: Subsequent SSH n8n node steps install modern development utilities, including Node.js, npm, WP-CLI, and Laravel/Symfony CLI tools.

  7. User Creation & Permissions: A new, non-root developer user is created, added to the www-data group, and SSH keys are generated for them. Permissions on /var/www/html are correctly set.

  8. Final Configuration: The final SSH step configures the UFW firewall and deploys a custom index.php landing page that visually confirms the status of Apache, MySQL, and PHP, concluding the successful n8n workflow execution.

Installation Guide

To deploy this comprehensive n8n workflow, follow these steps:


  1. Import the n8n template: Copy the provided JSON code and import it directly into your n8n instance via the 'Workflows' section.

  2. Setup SSH Credentials: This n8n workflow relies heavily on the SSH n8n node, which requires authentication.

Click on any 'SSH' n8n node (e.g., 'System Preparation').
Select or create a new 'SSH Private Key' credential (ID: ilPh8oO4GfSlc0Qy).
You must provide the private key and, optionally, a password for the key that can connect to your remote Linux server (must be run as root or a user with sudo access).

  1. Customize Parameters: Locate the 'Set Parameters' n8n node.

Update the default values for serverhost, serveruser, mysqlrootpassword, php_version, and username to match your desired setup.

  1. Execute the n8n workflow: Run the n8n trigger manually to start the server provisioning.

Node Details

This n8n workflow utilizes core nodes essential for orchestration and remote execution:

Start (n8n trigger): n8n-nodes-base.manualTrigger
Function: Serves as the immediate n8n trigger to begin the automated server setup process.
Key Configuration: Activated manually when the server provisioning is required.

Set Parameters (Set n8n node): n8n-nodes-base.set
Function: Defines all customizable environment variables (host, passwords, versions) that subsequent SSH nodes will use for dynamic script execution, making this n8n template highly reusable.
Key Configuration: Stores variables like phpversion ('8.2') and mysqlrootpassword.

System Preparation, Install Apache, Install MySQL, Install PHP, Install Dev Tools, Create Dev User, Final Configuration (SSH n8n node): n8n-nodes-base.ssh
Function: The central component of this n8n workflow. Each SSH n8n node connects to the remote server using the defined SSH Private Key credentials and executes a complex, multi-line bash script to install, configure, and secure the respective component (Apache, MySQL, PHP, etc.).
Key Configuration: All nodes use the same SSH credential and contain comprehensive, embedded shell scripts that leverage parameters defined earlier (e.g., using {{ $json.phpversion }} within the script).

Setup Complete (Set n8n node): n8n-nodes-base.set
* Function: Aggregates the resulting information and key access URLs (server URL, phpMyAdmin link) to provide a clean, accessible summary output item after the n8n workflow finishes executing.

Related n8n Workflows

Free

Nodes: 4 Nodes
Updated: December 26 2025
View all
Created by

The AI Squad Initiative is a pioneering effort to build, automate and scale AI-powered workflows using n8n.io. Our mission is to help individuals and businesses integrate AI agents seamlessly into their daily operations from automating tasks and enhancing productivity to creating innovative, intelligent solutions. We design modular, reusable AI workflow templates that empower creators, developers and teams to supercharge their automation with minimal effort and maximum impact.

Featured*