This project automates the setup of a multi-server LAMP (Linux, Apache, MySQL, PHP) stack using Vagrant and Ansible. It creates and configures three separate servers: one for the MySQL database, one for authentication, and one for the application.
Group Members:
Vagrantfile
: Defines the virtual machines using Vagrant.playbook.yml
: Ansible playbook for provisioning the servers.inventory.ini
: Inventory file for Ansible (dynamically generated by Vagrant)./scripts
: Directory containing shell scripts used in the project.git clone https://github.com/rukhat/Multi-Server-LAMP-Stack-Automation.git
cd multi-server-lamp-automation
vagrant up
You can SSH into any of the servers using:
vagrant ssh <server-name>
Replace <server-name>
with db
, auth
, or app
.
On the auth server, you can run the script that fetches and executes scripts from the database:
sudo bash /usr/local/bin/fetch_and_execute_scripts.sh
This script connects to the MySQL database on the db server, retrieves script information, and executes the scripts via SSH.
Vagrantfile
to change VM configurations.playbook.yml
to alter server setups or add new features.If you encounter issues:
Contributions to improve the project are welcome. Please follow these steps:
This project is licensed under the MIT License - see the LICENSE.md file for details.
This section of the project will demonstrate the setup and configuration of an LDAP server, as well as PAM (Pluggable Authentication Module). The server is capable of managing users/groups, implementing lockout policies, time-based access restrictions, and logging of authentication attempts.
Install Required Packages:
sudo apt install apache2 php php-cgi libapache2-mod-php php-mbstring php-common php-pear -y
sudo apt install slapd ldap-utils -y
Run "sudo slapcat" to verify OpenLDAP installation.
sudo apt install ldap-account-manager -y
Run "sudo a2enconf php*-cgi" to enable the PHP-CGI PHP extension. Once the service is restarted, run "sudo systemctl enable apache2" to enable the Apache service to autostart at boot time.
Run "sudo systemctl status apache2" to confirm the Apache service is running.
Configure LDAP:
setup-ldap.md
to configure the LDAP server.Configure PAM:
setup-pam.md
to integrate PAM with LDAP.Run Featured Scripts:
check_time.sh
script for time-based access restrictions.This project contains a script to create and run backup scripts for a database server and an authentication server. The backup scripts use rsync
to synchronize data from these servers to a local backup directory.
When initially running the backup scripts, you will need to change the address to your desired location.
In the app.py note lines 19-23
db_backup_content = """#!/bin/bash
rsync -avz --delete [email protected]:/path/to/backup/ /home/vagrant/backups/db/
"""
auth_backup_content = """#!/bin/bash
rsync -avz --delete [email protected]:/path/to/backup/ /home/vagrant/backups/auth/
"""
DO THE FOLLOWING
- To create scripts on your local machine or VM
python3 app.py create_scripts
- To run the database backup script
python3 app.py backup_db
-To run the authentication backup script
python3 app.py backup_auth
-To run the Server Performance script:
python3 app.py monitor <server name>