VProfile-Local is a web application stack designed for local development, aiming to handle multiple services. finally to automate the setup process using Infrastructure as Code (IaC).
Tool | Use | Why Choose It |
---|---|---|
🧊 VirtualBox | Hypervisor for Virtualization | Easy to use |
🆅 Vagrant | Automation | Lightweight |
🐧 Linux (Ubuntu) | OS | Popular Linux distribution |
🐧 Linux (CentOS 9) | OS | Popular Linux distribution |
🌐 Nginx | Load Balancer | Web Service |
🐈 Apache Tomcat | Application Server | Popular for Java apps |
📨 RabbitMQ | Broker/Queuing Agent | For messaging tasks |
DB Caching | For database caching | |
🐬 MySQL Server | SQL Database | For data storage |
- Computer with at least 8GB RAM and approximately 10GB of free disk space (for running Linux in a virtual machine).
- Oracle VM VirtualBox
- Vagrant
- Vagrant plugin - vagrant-hostmanager (Adds hostnames and IP addresses from the Vagrantfile to every VM hostfile, i.e.,
/etc/hosts
). - Git bash
- Clone the source code:
git clone -b main https://github.com/myacov/vprofile-local.git
- Bring up the virtual machines
vagrant up
- Login to the 'db01' VM:
vagrant ssh db01
- Verify the hosts entry; if entries are missing, update them with the appropriate IP and hostnames:
cat /etc/hosts
- Update the OS with the latest patches:
sudo yum update -y
- Set up the repository:
sudo yum install epel-release -y
- Install MariaDB:
sudo yum install git mariadb-server -y
- Start and enable the MariaDB server:
sudo systemctl start mariadb sudo systemctl enable mariadb sudo systemctl status mariadb
- Run the MySQL secure installation script:
sudo mysql_secure_installation
NOTE: Set db root password Example password : admin123
- Setup Databa
8000
se name and users.
mysql -u root -padmin123
grant privileges to user admin (% = remote)
sql> create database accounts;
sql> grant all privileges on accounts.* TO 'admin'@'%' identified by 'admin123' ;
sql> FLUSH PRIVILEGES;
sql> exit;
- Download Source code & Initialize Database.
sudo -i
git clone -b main https://github.com/myacov/vprofile-local.git
cd vprofile-local
mysql -u root -padmin123 accounts < src/main/resources/db_backup.sql
mysql -u root -padmin123 accounts
sql> show tables;
- Restart the MariaDB server:
systemctl restart mariadb
- Login to the 'mc01' vm
vagrant ssh mc01
- Install, start, and enable Memcached on port 11211:
sudo -i
dnf install epel-release -y
dnf install memcached -y
systemctl start memcached
systemctl enable memcached
systemctl status memcached
- Allow listening for connections from different VMs (for Tomcat):
sed -i 's/127.0.0.1/0.0.0.0/g' /etc/sysconfig/memcached
sudo systemctl restart memcached
- Login to the RabbitMQ vm
vagrant ssh rmq01
- Update the OS and set up the EPEL repository:
sudo -i
yum update -y
yum install epel-release -y
- Install Dependencies and RabbitMQ repository:
dnf -y install centos-release-rabbitmq-38
- Enable RabbitMQ repositry and instll rabbitMQ Server
dnf --enablerepo=centos-rabbitmq-38 -y install rabbitmq-server
- Start and Enable RabbitMQ Server
systemctl start rabbitmq-server
systemctl enable rabbitmq-server
systemctl status rabbitmq-server
- For VProfile-specific configuration, create a file and redirect output:
sh -c 'echo "[{rabbit, [{loopback_users, []}]}]." > /etc/rabbitmq/rabbitmq.config'
- RabbitMQ commands - add user and set "administrator" tag . then restart the service
rabbitmqctl add_user test test
rabbitmqctl set_user_tags test administrator
systemctl restart rabbitmq-server
- Setting up Tomcat Service
- Login to the Tomcat vm
vagrant ssh app01
- Update the OS:
sudo yum update -y
- Set up the repository:
sudo yum install epel-release -y
- Install Dependencies: OpenJDK 11, Git, Wget, and Maven:
dnf -y install java-11-openjdk java-11-openjdk-devel dnf install git maven wget -y
- Download & Install Tomcat Package
cd /tmp/ wget https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.75/bin/apache-tomcat-9.0.75.tar.gz tar xzvf apache-tomcat-9.0.75.tar.gz useradd --home-dir /usr/local/tomcat --shell /sbin/nologin tomcat cp -r /tmp/apache-tomcat-9.0.75/* /usr/local/tomcat/ chown -R tomcat.tomcat /usr/local/tomcat
- Setup systemctl command for Tomcat: Copy and paste the following script to tomcat.service file (path= /etc/systemd/system/tomcat.service):
[Unit] Description=Tomcat After=network.target [Service] User=tomcat WorkingDirectory=/usr/local/tomcat Environment=JRE_HOME=/usr/lib/jvm/jre Environment=JAVA_HOME=/usr/lib/jvm/jre Environment=CATALINA_HOME=/usr/local/tomcat Environment=CATALINE_BASE=/usr/local/tomcat ExecStart=/usr/local/tomcat/bin/catalina.sh run ExecStop=/usr/local/tomcat/bin/shutdown.sh SyslogIdentifier=tomcat-%i [Install] WantedBy=multi-user.target
- Reload systemd files, then start and enable the Tomcat service:
systemctl daemon-reload systemctl start tomcat systemctl enable tomcat
- Building & Deploying the Application on Tomcat:
- Download Source code
git clone -b main https://github.com/myacov/vprofile-local.git
- Build the code:
cd vprofile-local mvn install
- Deploy the artifact:
systemctl stop tomcat rm -rf /usr/local/tomcat/webapps/ROOT* cp target/vprofile-v2.war /usr/local/tomcat/webapps/ROOT.war systemctl start tomcat
- Download Source code
- Login to the Nginx vm
vagrant ssh web01
- Update the OS and install Nginx:
sudo -i
apt update
apt upgrade -y
apt install nginx -y
- Create an Nginx conf file and copy and paste the following script (path= /etc/nginx/sites-available/vproapp)::
upstream vproapp {
server app01:8080;
}
server {
listen 80;
location / {
proxy_pass http://vproapp;
}
}
- Remove the default Nginx configuration link:
rm -rf /etc/nginx/sites-enabled/default
- Create a symbolic link to our configuration:
ln -s /etc/nginx/sites-available/vproapp /etc/nginx/sites-enabled/vproapp
- Restart Nginx:
systemctl restart nginx
The automated branch includes shell scripts for the Vagrantfile to execute during the provisioning stage.
This project is licensed under the MIT License.