Setting Up Proxmox VE with VMs and Databases for Applications

Answered using GPT-4o Mini by GPT4oMini.app

Question:

explain the steps on the following:

  1. Install Proxmox VE for my actual server.

  2. In the server, create two Virtual Machines.

  • One Application VM for running Ubuntu and PHP applications.
  • Another Database VM for managing the MariaDB database.
  1. Establish two subdirectories under the Application VM.
  • One for the internet application system.
  • One for the web application system.
  1. Create two databases in the MariaDB under the Database VM.
  • One for the internet application system.
  • One for the web application system.
Answer:

Certainly! Below are the detailed steps to install Proxmox VE, create virtual machines, set up subdirectories, and create databases as per your requirements.

Step 1: Install Proxmox VE on Your Server

  1. Download Proxmox VE ISO:

  2. Create a Bootable USB Drive:

    • Use a tool like Rufus (Windows) or Etcher (macOS/Linux) 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 on-screen instructions to install Proxmox VE.
    • Select the target hard drive for installation.
    • Configure the management network settings (IP address, gateway, etc.).
    • Set a password for the Proxmox web interface and provide an email address for notifications.
  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://<your-server-ip>:8006 in a web browser.

Step 2: Create Two Virtual Machines

  1. Log in to Proxmox Web Interface:

    • Use the credentials you set during installation to log in.
  2. Create Application VM:

    • Click on "Create VM" in the top right corner.
    • Fill in the details:
      • Node: Select your Proxmox node.
      • VM ID: Automatically generated or specify.
      • Name: e.g., Application-VM.
    • OS: Select the ISO image for Ubuntu (you may need to upload it to Proxmox).
    • System: Configure BIOS and other settings as needed.
    • Hard Disk: Allocate disk space (e.g., 20GB).
    • CPU: Allocate CPU cores (e.g., 2 cores).
    • Memory: Allocate RAM (e.g., 2048MB).
    • Network: Configure the network settings (e.g., bridge mode).
    • Click "Finish" to create the VM.
  3. Create Database VM:

    • Repeat the above steps to create another VM for the database.
    • Name it Database-VM and allocate resources as needed.

Step 3: Establish Two Subdirectories under the Application VM

  1. Access the Application VM:

    • Start the Application VM and access it via the console in Proxmox or SSH into it.
  2. Install Required Packages:

    • Update the package list and install Apache, PHP, and any other required packages:
      sudo apt update
      sudo apt install apache2 php libapache2-mod-php
      
  3. Create Subdirectories:

    • Navigate to the web root directory (usually /var/www/html):
      cd /var/www/html
      
    • Create the subdirectories:
      sudo mkdir internet_application
      sudo mkdir web_application
      
  4. Set Permissions:

    • Set appropriate permissions for the directories:
      sudo chown -R www-data:www-data internet_application
      sudo chown -R www-data:www-data web_application
      

Step 4: Create Two Databases in MariaDB under the Database VM

  1. Access the Database VM:

    • Start the Database VM and access it via the console in Proxmox or SSH into it.
  2. Install MariaDB:

    • Update the package list and install MariaDB:
      sudo apt update
      sudo apt install mariadb-server
      
  3. Secure MariaDB Installation:

    • Run the security script to set the root password and secure the installation:
      sudo mysql_secure_installation
      
  4. Log in to MariaDB:

    • Log in to the MariaDB shell:
      sudo mysql -u root -p
      
  5. Create Databases:

    • Create the databases for your applications:
      CREATE DATABASE internet_application_db;
      CREATE DATABASE web_application_db;
      
  6. Create Users (Optional):

    • You may want to create users for each database:
      CREATE USER 'internet_user'@'localhost' IDENTIFIED BY 'password';
      GRANT ALL PRIVILEGES ON internet_application_db.* TO 'internet_user'@'localhost';
      
      CREATE USER 'web_user'@'localhost' IDENTIFIED BY 'password';
      GRANT ALL PRIVILEGES ON web_application_db.* TO 'web_user'@'localhost';
      
  7. Exit MariaDB:

    • Type exit; to leave the MariaDB shell.

Conclusion

You have now successfully installed Proxmox VE, created two virtual machines (one for applications and one for the database), established subdirectories in the Application VM, and created databases in the Database VM. You can now proceed to deploy your PHP applications and connect them to the MariaDB databases as needed.