- Tier 1 β Presentation Tier Setup (nginx) π₯οΈ
- Tier 2 β Application Tier Setup (apache2) π
- Tier 3 β Setup Data Tier (MariaDB and Secure phpMyAdmin) π‘οΈ
- Connect Tier 3 (Data Tier) to Tier 2 (Application Tier) π
- Importing Database π₯
- Setup Network File Sharing (NFS) π
- Documentation π
-
Install nginx:
sudo apt-get install nginx -y
-
Check Nginx status:
sudo systemctl status nginx
-
Check if the nginx website is working by typing localhost in your web browser. π
-
Reverse proxy nginx (put hostβs IP):
sudo nvim /etc/nginx/sites-available/default
Add the following configuration:
location /var/www/softdev_project.com { proxy_pass http://192.168.132.139; proxy_buffering off; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Port $server_port; }
-
Add your domain to /etc/hosts:
sudo nvim /etc/hosts
-
Create a configuration file for your domain at /etc/nginx/conf.d/:
sudo nvim /etc/nginx/conf.d/softdev_project.com.conf
Add the following configuration:
upstream softdev-project.com { server 192.168.132.139 fail_timeout=0; server 192.168.132.149 backup; } server { listen 80; server_name StudentResultManagementSystem.edu.ph; location / { proxy_pass http://softdev-project.com$1; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Host $host; proxy_redirect off; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 90; proxy_send_timeout 90; proxy_read_timeout 90; client_max_body_size 10m; client_body_buffer_size 128k; proxy_buffer_size 4k; } }
-
Restart nginx:
sudo systemctl restart nginx
-
Install apache2:
sudo apt install apache2
-
Add 'Apache' and 'Apache Full' to the firewall list:
sudo ufw allow 'Apache' sudo ufw allow 'Apache Full'
-
Check Apache website.
-
Setup Virtual Host (/var/www/softdev_project.com):
sudo mkdir /var/www/softdev_project.com sudo chown -R USER:USER /var/www/softdev_project.com sudo chmod -R 755 /var/www/softdev_project.com
-
Permissions and setup PHP web.
-
Configure .conf file (/etc/apache2/sites-available/):
sudo nvim /etc/apache2/sites-available/softdev_project.com.conf
Add the following configuration:
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName softdev_project.com ServerAlias www.softdev_project.com DocumentRoot /var/www/softdev_project.com ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
-
Enable the new .conf file and disable 000-default.conf:
sudo a2ensite softdev_project.com.conf sudo a2dissite 000-default.conf
-
Test the new PHP website.
-
Install MySQL:
sudo apt-get install mysql-server
-
Install PHP and PHP extensions:
sudo apt-get install php php-cgi libapache2-mod-php php-mbstring php-all-dev
-
Install PHP MySQL extension:
sudo apt-get install php8.1-mysql
-
Install MariaDB:
sudo apt install mariadb-server php-mysql
-
Set up MySQL.
-
Configure MySQL.
-
Alter the user and flush privileges.
-
Access MySQL again.
-
Test localhost/phpMyAdmin.
-
Whitelist the IP address of Tier 2 (Application Tier) to Tier 3 (Data Tier).
-
Create a new user for the remote database.
-
Change "bind-address = 127.0.0.1" to "bind-address = 0.0.0.0".
-
Access and show the database by logging into your remote account.
-
Create, import, and check table database.
-
Change the configuration of the PHP website database (change to Tier 3 database credentials).
-
Add include apache.conf.
-
Test the website.
-
Setup components (host side and client side).
-
Create the shared directories on the host.
-
Configure the NFS Exports on the Host server.
-
Adjust the firewall on the host.
-
Create mount points and mount directories on the client.
-
Check if directories are mounted.
-
Test NFS access.
-
Mount the remote NFS directories at boot.
This documentation provides a step-by-step guide to setting up a multi-tiered application environment using Nginx, Apache2, MariaDB, and NFS file sharing. Follow the instructions in each section to set up your environment successfully. πππ‘οΈππ₯π