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:

Sure! Here’s a step-by-step guide to help you install Proxmox VE, create virtual machines, set up directories, and create databases.

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 VM ID, Name (e.g., "Application-VM"), and select the OS type (Linux).
    • Choose the ISO image for Ubuntu (you may need to upload it to Proxmox first).
    • Configure the VM settings (CPU, Memory, Disk size) according to your needs.
    • Click "Finish" to create the VM.
  3. Create Database VM:

    • Repeat the same steps to create another VM (e.g., "Database-VM") for MariaDB.
    • Select the appropriate ISO for the database VM (you can use Ubuntu or a minimal installation).

Step 3: Establish Subdirectories under the Application VM

  1. Access the Application VM:

    • Start the Application VM and open the console from the Proxmox web interface.
    • Log in to the VM using the credentials you set during the Ubuntu installation.
  2. Create Subdirectories:

    • Open a terminal in the Application VM.
    • Use the following commands to create the subdirectories:
      sudo mkdir -p /var/www/internet_application
      sudo mkdir -p /var/www/web_application
      
  3. Set Permissions (Optional):

    • You may want to set permissions for the web server (e.g., Apache or Nginx) to access these directories:
      sudo chown -R www-data:www-data /var/www/internet_application
      sudo chown -R www-data:www-data /var/www/web_application
      

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

  1. Access the Database VM:

    • Start the Database VM and open the console from the Proxmox web interface.
    • Log in to the VM using the credentials you set during the Ubuntu installation.
  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:

    • Access the MariaDB shell:
      sudo mysql -u root -p
      
  5. Create Databases:

    • Run the following commands to create the databases:
      CREATE DATABASE internet_application_db;
      CREATE DATABASE web_application_db;
      
  6. Create Users and Grant Permissions (Optional):

    • You can create users and grant them permissions to the databases:
      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';
      
      FLUSH PRIVILEGES;
      
  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 two databases in the MariaDB under the Database VM. You can now proceed to deploy your PHP applications and connect them to the respective databases.