This guide explains how to connect the Cursor AI Code Editor directly to your hardened Systron server. This setup allows Cursor's AI Chat and Composer modes to read, create, and modify your PHP/MySQL applications live on the server without manual file transfers or complex FTP sync plugins.
Prerequisites
- A Systron VPS or Dedicated Server with Root SSH access enabled.
- An active Control Panel installed (aaPanel or Plesk).
- Cursor Editor installed on your local computer.
Step 1: Locate Your Web Document Root
Before connecting, verify the exact absolute path where your domain's files are hosted on the server:
- For aaPanel:
/www/wwwroot/://yourdomain.com - For Plesk:
/var/www/vhosts/://yourdomain.comhttpdocs/
Step 2: Connect Cursor via Remote SSH
- Launch Cursor on your local machine.
- Open the Command Palette by pressing
Ctrl + Shift + P(Windows/Linux) orCmd + Shift + P(macOS). - Type
Remote-SSH: Connect to Host...and press Enter. - Select
Add New SSH Host.... - Enter your connection string using your server's root details:
ssh root@your_server_ip
- Select the default configuration file location to save the host profile.
- When prompted on the connection dialog, click Connect and type your server's root password (or authenticate via your SSH Key if password access is disabled during hardening).
Step 3: Open Your Live Project Folder
- Look at the bottom-left corner of Cursor. It should display
SSH: your_server_ipindicating a successful connection. - Go to the top navigation bar and select
File > Open Folder. - In the search box, paste your absolute web path found in Step 1 (e.g.,
/www/wwwroot/://yourdomain.com) and click OK. - The remote folder structure will load directly inside your left sidebar.
Step 4: Configure Local Control Panel Database Credentials
Before asking the AI to build logic, generate a secure database within your hosting environment:
- Log in to your aaPanel or Plesk web UI interface.
- Navigate to the Databases section and create a new database along with a dedicated database user.
- Assign a strong, randomized password to that database user.
- Note that the Database Host will always be
localhostor127.0.0.1since the database resides on your local Systron machine.
Step 5: Build Your PHP/MySQL App Using AI Chat
Now that the AI editor is directly mapped to your environment, you can use Cursor's Composer Mode to build out the application scaffolding natively.
- Open the Composer Interface by pressing
Ctrl + I(Windows) orCmd + I(macOS). - Copy and paste the initialization prompt template below into the chat field:
"I want to build a PHP/MySQL application. Create a secure database connection file using PDO with prepared statements. Also, create a config file to store the DB credentials securely, a schema.sql file to create a sample table, and an index.php file to test the configuration."
- Click Submit. The AI will write the files directly onto your Systron filesystem.
- Review the code diffs visual overlays and click Accept All to finalize the file creation.
Production-Ready Secure Database Blueprint
To ensure your application complies with proper server hardening standards, verify that the AI structures your configuration using the production-ready PDO paradigm below. You can reference this script directly in your chat requests:
1. Secure Configuration File (config.php)
<?php
define('DB_HOST', '127.0.0.1');
define('DB_NAME', 'your_database_name');
define('DB_USER', 'your_database_user');
define('DB_PASS', 'your_hardened_password_here');
define('DB_CHARSET', 'utf8mb4');
?>
2. Hardened PDO Connection Module (db.php)
<?php
require_once __DIR__ . '/config.php';
$dsn = "mysql:host=" . DB_HOST . ";dbname=" . DB_NAME . ";charset=" . DB_CHARSET;
$options = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
PDO::ATTR_EMULATE_PREPARES => false,
];
try {
$pdo = new PDO($dsn, DB_USER, DB_PASS, $options);
} catch (\PDOException $e) {
// Secure logging: prevent leaking sensitive database strings to public screens
error_log($e->getMessage());
die("Database error occurred. Please check system logs.");
}
?>
3. Testing Connection Script (index.php)
<?php
require_once __DIR__ . '/db.php';
try {
$stmt = $pdo->query("SELECT VERSION() as version");
$row = $stmt->fetch();
echo "<h1 style='color:green;'>✔ Connection Successful!</h1>";
echo "<p>MySQL Server Version: " . htmlspecialchars($row['version']) . "</p>";
} catch (\PDOException $e) {
echo "<h1 style='color:red;'>✘ Connection Failed</h1>";
}
?>
Best Practices for Live Development
- Leverage the Context Token (@): In Cursor Chat, type
@filename(e.g.,@db.php) to pinpoint files for the AI when asking it to debug errors or add specific landing pages. - Enforce Secure PDO: Always instruct the AI to construct SQL operations using PHP Data Objects (PDO) and parameter binding to protect your live web application from SQL Injection attacks.
- Restrict File Permissions: After the AI creates files, use your panel file manager or SSH terminal to ensure sensitive credential files (like
config.php) have restrictive read/write permissions (e.g.,644or600).