{"id":25419491,"url":"https://github.com/iambotcoder/host-website-vagrant","last_synced_at":"2025-05-12T15:44:24.967Z","repository":{"id":277186561,"uuid":"931609840","full_name":"iambotcoder/host-website-vagrant","owner":"iambotcoder","description":null,"archived":false,"fork":false,"pushed_at":"2025-02-12T15:41:14.000Z","size":21,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-12T16:28:23.897Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iambotcoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-02-12T15:09:43.000Z","updated_at":"2025-02-12T15:41:17.000Z","dependencies_parsed_at":"2025-02-12T16:38:58.230Z","dependency_job_id":null,"html_url":"https://github.com/iambotcoder/host-website-vagrant","commit_stats":null,"previous_names":["iambotcoder/host-website-vagrant"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iambotcoder%2Fhost-website-vagrant","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iambotcoder%2Fhost-website-vagrant/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iambotcoder%2Fhost-website-vagrant/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iambotcoder%2Fhost-website-vagrant/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iambotcoder","download_url":"https://codeload.github.com/iambotcoder/host-website-vagrant/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253767487,"owners_count":21961116,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-16T18:48:54.785Z","updated_at":"2025-05-12T15:44:24.945Z","avatar_url":"https://github.com/iambotcoder.png","language":null,"readme":"# 🚀 VProfile Project\n\n---\n\n## 📖 Overview\nVProfile is a multi-tier web application designed to demonstrate infrastructure automation using Vagrant and VirtualBox. It includes various services such as a web server, application server, message broker, caching service, search indexing, and a database. The project automates provisioning using Vagrant and sets up a complete working environment for deployment.\n\n---\n\n## 📑 Table of Contents\n1. Prerequisites\n2. Architecture\n3. Workflow\n4. Task Execution\n5. Cleaning Up Resources\n6. Conclusion\n7. Instructor\n\n---\n\n## 🔑 Prerequisites\nBefore you start, ensure you have the following:\n1. **Oracle VM VirtualBox** - For virtualization\n2. **Vagrant** - To automate VM setup\n3. **Vagrant Plugins** - Required for network and provisioning\n\n---\n\n## 🗺️ Architecture\n![Screenshot 2025-02-12 224814](https://github.com/user-attachments/assets/70f69ec2-970e-4015-be7a-43d518a83c65)\n\n### 🔄 Workflow:\nThe provisioning process follows this sequence:\n\n1. **Nginx** → Web Service\n2. **Tomcat** → Application Server\n3. **RabbitMQ** → Broker/Queuing Agent\n4. **Memcache** → DB Caching\n5. **ElasticSearch** → Indexing/Search Service\n6. **MySQL** → SQL Database\n\n**Setup Order:**\n1. **MySQL** (Database Service)\n2. **Memcache** (DB Caching Service)\n3. **RabbitMQ** (Broker/Queue Service)\n4. **Tomcat** (Application Service)\n5. **Nginx** (Web Service)\n\n---\n\n### 📜 **Vagrantfile**\nCreate a file named **Vagrantfile** and add the following code:\n\n```ruby\nVagrant.configure(\"2\") do |config|\n  config.hostmanager.enabled = true \n  config.hostmanager.manage_host = true\n\n  ### DB VM ###\n  config.vm.define \"db01\" do |db01|\n    db01.vm.box = \"eurolinux-vagrant/centos-stream-9\"\n    #db01.vm.box_version = \"9.0.48\"  # Commented to avoid installation errors\n    db01.vm.hostname = \"db01\"\n\n    # Port Forwarding\n    db01.vm.network \"forwarded_port\", guest: 22, host: 2222\n    db01.vm.network \"private_network\", ip: \"192.168.56.15\"\n    \n    db01.vm.provider \"virtualbox\" do |vb|\n      vb.memory = \"600\"\n    end\n  end\n\n  ### Memcache VM ###\n  config.vm.define \"mc01\" do |mc01|\n    mc01.vm.box = \"eurolinux-vagrant/centos-stream-9\"\n    #mc01.vm.box_version = \"9.0.48\"\n    mc01.vm.hostname = \"mc01\"\n\n    # Port Forwarding\n    mc01.vm.network \"forwarded_port\", guest: 22, host: 2207\n    mc01.vm.network \"private_network\", ip: \"192.168.56.14\"\n    \n    mc01.vm.provider \"virtualbox\" do |vb|\n      vb.memory = \"600\"\n    end\n  end\n\n  ### RabbitMQ VM ###\n  config.vm.define \"rmq01\" do |rmq01|\n    rmq01.vm.box = \"eurolinux-vagrant/centos-stream-9\"\n    #rmq01.vm.box_version = \"9.0.48\"\n    rmq01.vm.hostname = \"rmq01\"\n\n    # Port Forwarding\n    rmq01.vm.network \"forwarded_port\", guest: 22, host: 2204\n    rmq01.vm.network \"private_network\", ip: \"192.168.56.13\"\n\n    rmq01.vm.provider \"virtualbox\" do |vb|\n      vb.memory = \"600\"\n    end\n  end\n\n  ### Tomcat VM ###\n  config.vm.define \"app01\" do |app01|\n    app01.vm.box = \"eurolinux-vagrant/centos-stream-9\"\n    #app01.vm.box_version = \"9.0.48\"\n    app01.vm.hostname = \"app01\"\n\n    # Port Forwarding\n    app01.vm.network \"forwarded_port\", guest: 22, host: 2205\n    app01.vm.network \"private_network\", ip: \"192.168.56.12\"\n\n    app01.vm.provider \"virtualbox\" do |vb|\n      vb.memory = \"800\"\n    end\n  end\n\n  ### Nginx VM ###\n  config.vm.define \"web01\" do |web01|\n    web01.vm.box = \"ubuntu/jammy64\"\n    web01.vm.hostname = \"web01\"\n\n    # Port Forwarding\n    web01.vm.network \"forwarded_port\", guest: 22, host: 2206\n    web01.vm.network \"private_network\", ip: \"192.168.56.11\"\n\n    web01.vm.provider \"virtualbox\" do |vb|\n      # First provision with GUI enabled, then disable it after setup\n      # vb.gui = true  \n      vb.memory = \"800\"\n    end\n  end\nend\n```\n\n---\n\n\n## 🚀 Setup Instructions\n\n#### 1️⃣ Install Dependencies\n\nEnsure the following are installed:\n\n- [Vagrant](https://www.vagrantup.com/)\n- [VirtualBox](https://www.virtualbox.org/)\n\n#### 2️⃣ Clone the Repository\n\n```sh\ngit clone https://github.com/hkhcoder/vprofile-project.git\ncd vagrant-setup\n```\n\n#### 3️⃣ Provision the Virtual Machines\n\nRun the following command to start all VMs:\n```sh\nvagrant up\n```\n\n#### 4️⃣ SSH into a Virtual Machine\n\nTo access a specific VM, use:\n```sh\nvagrant ssh \u003cvm-name\u003e\n```\nFor example:\n```sh\nvagrant ssh web01\n```\n\n#### 5️⃣ Managing VMs\n\n- **Stop all VMs:** `vagrant halt`\n- **Restart all VMs:** `vagrant reload`\n- **Destroy all VMs:** `vagrant destroy`\n- **List running VMs:** `vagrant status`\n\n### 📝 Notes\n\n- **Nginx VM (`web01`) requires manual network configuration**:\n  1. **First Boot** → Enable `vb.gui = true` in `Vagrantfile`\n  2. Set up the network in VirtualBox:\n     - **Adapter 1:** NAT\n     - **Adapter 2:** Bridged Adapter\n  3. Once installed, disable the GUI (`vb.gui = false`) and run `vagrant reload`.\n\n\n\n---\n\n## **1. MySQL Setup**  \n\n1. Login to the database VM:  \n   ```bash\n   vagrant ssh db01\n   ```\n   \n2. Verify and update `/etc/hosts` if necessary: \n    \n   ```bash\n   cat /etc/hosts\n   ```\n   \n3. Update OS with latest patches:  \n   \n   ```bash\n   dnf update -y\n   ```\n   \n4. Set repository:\n     \n   ```bash\n   dnf install epel-release -y\n   ```\n   \n5. Install MariaDB package:  \n   \n   ```bash\n   dnf install git mariadb-server -y\n   ```\n   \n6. Start and enable MariaDB service: \n    \n   ```bash\n   systemctl start mariadb\n   systemctl enable mariadb\n   ```\n   \n7. Run MySQL secure installation script:\n     \n   ```bash\n   mysql_secure_installation\n   ```\n   \n   - Set root password (`admin123`)  \n   - Remove anonymous users  \n   - Disallow root login remotely (No)  \n   - Remove test database  \n   - Reload privilege tables\n    \n8. Create database and user:\n     \n   ```bash\n   mysql -u root -padmin123\n   ```\n   \n   ```sql\n   mysql\u003e CREATE DATABASE accounts;\n   mysql\u003e GRANT ALL PRIVILEGES ON accounts.* TO 'admin'@'localhost' IDENTIFIED BY 'admin123';\n   mysql\u003e GRANT ALL PRIVILEGES ON accounts.* TO 'admin'@'%' IDENTIFIED BY 'admin123';\n   mysql\u003e FLUSH PRIVILEGES;\n   mysql\u003e exit;\n   ```\n   \n9. Download source code and initialize the database:  \n   \n   ```bash\n   cd /tmp/\n   git clone -b local https://github.com/hkhcoder/vprofile-project.git\n   cd vprofile-project\n   mysql -u root -padmin123 accounts \u003c src/main/resources/db_backup.sql\n   mysql -u root -padmin123 accounts\n   ```\n   \n   ```sql\n   mysql\u003e SHOW TABLES;\n   mysql\u003e exit;\n   ```\n   \n10. Restart MariaDB:  \n   \n    ```bash\n    systemctl restart mariadb\n    ```\n\n---\n\n## **2. Memcache Setup**  \n\n1. Login to the Memcache VM:  \n   \n   ```bash\n   vagrant ssh mc01\n   ```\n   \n2. Verify and update `/etc/hosts` if necessary:  \n   \n   ```bash\n   cat /etc/hosts\n   ```\n   \n3. Update OS with latest patches:  \n   \n   ```bash\n   dnf update -y\n   ```\n   \n4. Install Memcache:  \n   \n   ```bash\n   sudo dnf install epel-release -y\n   sudo dnf install memcached -y\n   ```\n   \n5. Start and enable Memcache service:  \n   \n   ```bash\n   sudo systemctl start memcached\n   sudo systemctl enable memcached\n   sudo systemctl status memcached\n   ```\n6. Allow external connections:\n     \n   ```bash\n   sed -i 's/127.0.0.1/0.0.0.0/g' /etc/sysconfig/memcached\n   ```\n   \n7. Restart Memcached:  \n   \n   ```bash\n   sudo systemctl restart memcached\n   ```\n\n---\n\n## **3. RabbitMQ Setup**  \n\n1. Login to the RabbitMQ VM:  \n   \n   ```bash\n   vagrant ssh rmq01\n   ```\n   \n2. Verify and update `/etc/hosts` if necessary:  \n   \n   ```bash\n   cat /etc/hosts\n   ```\n   \n3. Update OS with latest patches:  \n   \n   ```bash\n   dnf update -y\n   ```\n   \n4. Install EPEL repository:  \n   \n   ```bash\n   dnf install epel-release -y\n   ```\n   \n5. Install dependencies:  \n   \n   ```bash\n   sudo dnf install wget -y\n   dnf -y install centos-release-rabbitmq-38\n   dnf --enablerepo=centos-rabbitmq-38 -y install rabbitmq-server\n   systemctl enable --now rabbitmq-server\n   ```\n   \n6. Configure RabbitMQ user:  \n   \n   ```bash\n   sudo sh -c 'echo \"[{rabbit, [{loopback_users, []}]}].\" \u003e /etc/rabbitmq/rabbitmq.config'\n   sudo rabbitmqctl add_user test test\n   sudo rabbitmqctl set_user_tags test administrator\n   sudo rabbitmqctl set_permissions -p / test \".*\" \".*\" \".*\"\n   ```\n   \n7. Restart RabbitMQ service:  \n   \n   ```bash\n   sudo systemctl restart rabbitmq-server\n   ```\n\n---\n\n## **4. Tomcat Setup**\n\n1. Login to the Tomcat VM:  \n   \n   ```bash\n   vagrant ssh app01\n   ```\n   \n2. Verify and update `/etc/hosts` if necessary:  \n   \n   ```bash\n   cat /etc/hosts\n   ```\n   \n3. Update OS with latest patches:  \n   \n   ```bash\n   dnf update -y\n   ```\n   \n4. Set repository:  \n   \n   ```bash\n   dnf install epel-release -y\n   ```\n   \n5. Install dependencies:  \n   \n   ```bash\n   dnf -y install java-17-openjdk java-17-openjdk-devel\n   dnf install git wget -y\n   ```\n   \n6. Change directory to `/tmp`:  \n   \n   ```bash\n   cd /tmp/\n   ```\n   \n7. Download and extract Tomcat:  \n   \n   ```bash\n   wget https://archive.apache.org/dist/tomcat/tomcat-10/v10.1.26/bin/apache-tomcat-10.1.26.tar.gz\n   tar xzvf apache-tomcat-10.1.26.tar.gz\n   ```\n   \n8. Create Tomcat user:  \n   \n   ```bash\n   useradd --home-dir /usr/local/tomcat --shell /sbin/nologin tomcat\n   ```\n   \n9. Copy Tomcat files to home directory:  \n   \n   ```bash\n   cp -r /tmp/apache-tomcat-10.1.26/* /usr/local/tomcat/\n   chown -R tomcat.tomcat /usr/local/tomcat\n   ```\n   \n## Setup systemctl command for tomcat   \n\n10. Create Tomcat service file:  \n   \n    ```bash\n    vi /etc/systemd/system/tomcat.service\n    ```\n   \n    - Add the provided service configuration\n      \n    ```ruby\n    \n     [Unit]\n     Description=Tomcat\n     After=network.target\n    \n     [Service]\n     User=tomcat\n     Group=tomcat\n     WorkingDirectory=/usr/local/tomcat\n     Environment=JAVA_HOME=/usr/lib/jvm/jre\n     Environment=CATALINA_PID=/var/tomcat/%i/run/tomcat.pid\n     Environment=CATALINA_HOME=/usr/local/tomcat\n     Environment=CATALINE_BASE=/usr/local/tomcat\n     ExecStart=/usr/local/tomcat/bin/catalina.sh run\n     ExecStop=/usr/local/tomcat/bin/shutdown.sh\n     RestartSec=10\n     Restart=always\n    \n     [Install]\n     WantedBy=multi-user.target\n    ```\n   \n11. Reload systemd and enable Tomcat:  \n    \n   ```bash\n    systemctl daemon-reload\n    systemctl start tomcat\n    systemctl enable tomcat\n   ```\n   \n12. Configure firewall:  \n    \n   ```bash\n    systemctl start firewalld\n    systemctl enable firewalld\n    firewall-cmd --zone=public --add-port=8080/tcp --permanent\n    firewall-cmd --reload\n   ```\n\n#### **Code Build \u0026 Deployment**\n\n1. Install Maven:  \n   \n   ```bash\n   cd /tmp/\n   wget https://archive.apache.org/dist/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.zip\n   unzip apache-maven-3.9.9-bin.zip\n   cp -r apache-maven-3.9.9 /usr/local/maven3.9\n   export MAVEN_OPTS=\"-Xmx512m\"\n   ```\n   \n2. Download source code:  \n   \n   ```bash\n   git clone -b local https://github.com/hkhcoder/vprofile-project.git\n   ```\n   \n3. Update configuration:  \n   \n   ```bash\n   cd vprofile-project\n   vim src/main/resources/application.properties\n   ```\n   \n4. Build the code:  \n   \n   ```bash\n   /usr/local/maven3.9/bin/mvn install\n   ```\n   \n5. Deploy artifact:  \n   \n   ```bash\n   systemctl stop tomcat\n   rm -rf /usr/local/tomcat/webapps/ROOT*\n   cp target/vprofile-v2.war /usr/local/tomcat/webapps/ROOT.war\n   systemctl start tomcat\n   chown tomcat.tomcat /usr/local/tomcat/webapps -R\n   systemctl restart tomcat\n   ```\n\n---\n\n## **5. Nginx Setup**\n\n1. Login to the Nginx VM:  \n   \n   ```bash\n   vagrant ssh web01\n   sudo -i\n   ```\n   \n2. Verify and update `/etc/hosts` if necessary:  \n   \n   ```bash\n   cat /etc/hosts\n   ```\n   \n3. Update OS with latest patches:  \n   \n   ```bash\n   apt update\n   apt upgrade\n   ```\n   \n4. Install Nginx:  \n   \n   ```bash\n   apt install nginx -y\n   ```\n   \n5. Create Nginx configuration file:  \n   \n   ```bash\n   vi /etc/nginx/sites-available/vproapp\n   ```\n   \n   - Add the provided configuration\n\n   ```ruby\n   \n   upstream vproapp {\n     server app01:8080;\n     }\n     server {\n       listen 80;\n       location / {\n         proxy_pass http://vproapp;\n       }\n   }\n \n   ```\n   \n7. Activate Nginx site:  \n   \n   ```bash\n   rm -rf /etc/nginx/sites-enabled/default\n   ln -s /etc/nginx/sites-available/vproapp /etc/nginx/sites-enabled/vproapp\n   ```\n   \n8. Restart Nginx:  \n   \n   ```bash\n   systemctl restart nginx\n   ```\n\n---\n\n## 💻 Validate the project\n\n![Screenshot 2025-02-11 154427_](https://github.com/user-attachments/assets/ead538f1-39bc-42d1-bd2f-959f43de2863)\n\n\n## 🗑️ Cleaning Up Resources\nTo remove all virtual machines and clean up resources, execute:\n\n```bash\n$ vagrant destroy --force\n```\n\n---\n\n## ✅ Conclusion\nIn this project, we successfully set up a **multi-tier web application** using **Vagrant and VirtualBox**, provisioning various services like MySQL, Memcache, RabbitMQ, Tomcat, and Nginx. The architecture supports scalability and ensures efficient load management.\n\n---\n\n## 👨‍🏫 Instructor\nThis project was completed under the mentorship of **Imran Teli**.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiambotcoder%2Fhost-website-vagrant","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiambotcoder%2Fhost-website-vagrant","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiambotcoder%2Fhost-website-vagrant/lists"}