Setting Up Proxmox VE with VMs, Databases, and Applications

Answered using GPT-4o Mini by GPT4oMini.app

Question:

explain the steps on the following:

  1. Install Proxmox VE for my actual server, and set internal ip address to 192.168.1.0

  2. In the server, create two Virtual Machines.

  • One Application VM for running Ubuntu and PHP applications and set internal ip address to 192.168.1.1.
  • Another Database VM for managing the MariaDB database set internal ip address to 192.168.1.2.
  1. Establish two subdirectories under the Application VM.
  • One for the internet application system named edge.
  • One for the web application system named platform.
  1. Create two databases in the MariaDB under the Database VM.
  • One for the internet application system.
  • One for the web application system.

Then, create sample application to veirfy the two application is setup and can connect to respective database.

Answer:

Here’s a step-by-step guide to install Proxmox VE, set up virtual machines, create subdirectories, and establish databases as per your requirements.

Step 1: Install Proxmox VE

  1. Download Proxmox VE ISO:

  2. Create a Bootable USB:

    • Use a tool like Rufus (Windows) or Etcher (Linux/Mac) to create a bootable USB drive with the Proxmox VE ISO.
  3. Boot from USB:

    • Insert the USB drive into your server and boot from it. You may need to change the boot order in the BIOS/UEFI settings.
  4. Install Proxmox VE:

    • Follow the installation prompts. Select the target hard drive, configure the management network, and set the internal IP address to 192.168.1.0 (note: this is typically reserved for network identification; you might want to use 192.168.1.10 or another address instead).
    • Set the hostname and other settings as prompted.
  5. Complete Installation:

    • Once the installation is complete, remove the USB drive and reboot the server. Access the Proxmox web interface by navigating to https://192.168.1.0:8006 in your web browser.

Step 2: Create Two Virtual Machines

  1. Log in to Proxmox Web Interface:

    • Use your web browser to access the Proxmox web interface.
  2. Create Application VM:

    • Click on "Create VM" in the top right corner.
    • Name the VM (e.g., "Application VM").
    • Select the ISO image for Ubuntu (you may need to upload it to Proxmox first).
    • Configure the VM settings (CPU, Memory, Disk).
    • In the "Network" tab, set the internal IP address to 192.168.1.1.
    • Complete the VM creation.
  3. Create Database VM:

    • Repeat the steps above to create another VM (e.g., "Database VM").
    • Set the internal IP address to 192.168.1.2.
    • Install MariaDB on this VM after the OS installation.

Step 3: Establish Subdirectories under the Application VM

  1. Access the Application VM:

    • Use SSH or the console in the Proxmox web interface to log into the Application VM.
  2. Create Subdirectories:

    sudo mkdir /var/www/html/edge
    sudo mkdir /var/www/html/platform
    
  3. Set Permissions:

    sudo chown -R www-data:www-data /var/www/html/edge
    sudo chown -R www-data:www-data /var/www/html/platform
    

Step 4: Create Two Databases in MariaDB

  1. Access the Database VM:

    • Log into the Database VM.
  2. Install MariaDB:

    sudo apt update
    sudo apt install mariadb-server
    
  3. Secure MariaDB Installation:

    sudo mysql_secure_installation
    
  4. Log into MariaDB:

    sudo mysql -u root -p
    
  5. Create Databases:

    CREATE DATABASE edge_db;
    CREATE DATABASE platform_db;
    
  6. Create Users and Grant Permissions (optional):

    CREATE USER 'edge_user'@'%' IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON edge_db.* TO 'edge_user'@'%';
    
    CREATE USER 'platform_user'@'%' IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON platform_db.* TO 'platform_user'@'%';
    
    FLUSH PRIVILEGES;
    EXIT;
    

Step 5: Create Sample Applications

  1. Create Sample PHP Files:

    • On the Application VM, create a sample PHP file in each subdirectory.

    For the edge directory:

    echo "<?php
    \$conn = new mysqli('192.168.1.2', 'edge_user', 'password', 'edge_db');
    if (\$conn->connect_error) {
        die('Connection failed: ' . \$conn->connect_error);
    }
    echo 'Connected successfully to edge_db';
    ?>" | sudo tee /var/www/html/edge/index.php
    

    For the platform directory:

    echo "<?php
    \$conn = new mysqli('192.168.1.2', 'platform_user', 'password', 'platform_db');
    if (\$conn->connect_error) {
        die('Connection failed: ' . \$conn->connect_error);
    }
    echo 'Connected successfully to platform_db';
    ?>" | sudo tee /var/www/html/platform/index.php
    
  2. Test the Applications:

    • Open a web browser and navigate to http://192.168.1.1/edge/index.php and http://192.168.1.1/platform/index.php to verify that both applications can connect to their respective databases.

Conclusion

You have successfully installed Proxmox VE, created two virtual machines, established subdirectories, created databases, and set up sample applications to verify the connections. Make sure to adjust firewall settings and security configurations as needed for your environment.