11 KiB
11 KiB
WebGIS Poverty Mapping - Deployment Guide
Version: 1.0
Last Updated: May 2026
Table of Contents
- Prerequisites
- Installation Steps
- Database Setup
- Configuration
- Testing
- Deployment Checklist
- Troubleshooting
- Maintenance
Prerequisites
System Requirements
- Server: Apache 2.4 or higher (with mod_rewrite enabled)
- PHP: 7.4 or higher
- Database: MySQL 5.7+ or MariaDB 10.3+
- OS: Linux (Ubuntu 18.04 LTS recommended) or Windows with XAMPP
Required Software
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install -y apache2 php php-mysql php-gd php-json mysql-server
# Verify installations
php -v
mysql --version
apache2ctl -v
Browser Support
- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
Installation Steps
Step 1: Prepare Web Directory
# For Ubuntu/Linux
sudo mkdir -p /var/www/html/webgis
sudo chown -R www-data:www-data /var/www/html/webgis
cd /var/www/html/webgis
# For Windows XAMPP
# Create folder: C:\xampp\htdocs\webgis\
cd C:\xampp\htdocs\webgis\
Step 2: Copy Application Files
# Copy all application files to web directory
cp -r /path/to/application/* /var/www/html/webgis/
# Set proper permissions (Linux only)
sudo chmod -R 755 /var/www/html/webgis/
sudo chmod -R 777 /var/www/html/webgis/logs/
sudo chmod -R 777 /var/www/html/webgis/data/
Step 3: Enable Apache Modules (Linux)
sudo a2enmod rewrite
sudo a2enmod headers
sudo a2enmod php*
sudo systemctl restart apache2
Step 4: Create Virtual Host (Optional - Linux)
Create /etc/apache2/sites-available/webgis.conf:
<VirtualHost *:80>
ServerName webgis.local
ServerAdmin admin@webgis.local
DocumentRoot /var/www/html/webgis
<Directory /var/www/html/webgis>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/webgis-error.log
CustomLog ${APACHE_LOG_DIR}/webgis-access.log combined
</VirtualHost>
Enable the site:
sudo a2ensite webgis.conf
sudo systemctl reload apache2
Database Setup
Step 1: Start MySQL Service
# Linux
sudo systemctl start mysql
# Windows (XAMPP)
# Start MySQL from XAMPP Control Panel
Step 2: Run Setup Script
# Access the setup script via browser
http://localhost/webgis/setup_db.php
# OR run via command line
php /var/www/html/webgis/setup_db.php
Expected Output:
=== WebGIS Poverty Mapping - Database Setup ===
✓ Database 'webgis_unified' ready
✓ Table 'data_unified' created
✓ Table 'audit_log' created
✓ Table 'ref_kondisi_rumah' created
✓ Table 'ref_status_bantuan' created
✓ Table 'ref_sumber_penghasilan' created
✓ Table 'data_statistics' created
✓ Table 'users' created
✓ Trigger 'trg_data_unified_insert' created
✓ Trigger 'trg_data_unified_update' created
✓ Trigger 'trg_data_unified_delete' created
✓ View 'v_data_summary' created
✓ View 'v_poor_house_analysis' created
=== Setup Selesai ===
Database: webgis_unified
Tables: 9 (data_unified, audit_log, ref_kondisi_rumah, ref_status_bantuan, ref_sumber_penghasilan, data_statistics, users, + 2 views)
Triggers: 3 (INSERT, UPDATE, DELETE)
Ready for production use!
Step 3: Verify Database
# Connect to MySQL
mysql -u root -p
# List databases
SHOW DATABASES;
# Select database
USE webgis_unified;
# List tables
SHOW TABLES;
# Check table structure
DESCRIBE data_unified;
Configuration
Step 1: Update db.php (if needed)
File: db.php
<?php
$conn = new mysqli("localhost", "root", "", "webgis_unified");
if ($conn->connect_error) {
die("Koneksi gagal: " . $conn->connect_error);
}
$conn->set_charset("utf8mb4");
?>
Step 2: Configure PHP Settings
Edit php.ini:
; Increase upload file size
upload_max_filesize = 100M
post_max_size = 100M
; Set timezone
date.timezone = "Asia/Jakarta"
; Enable extensions
extension=mysqli
extension=json
; Error reporting (development)
error_reporting = E_ALL
display_errors = On
; Error reporting (production)
error_reporting = E_ALL
display_errors = Off
log_errors = On
error_log = /var/log/php/error.log
Step 3: Create .htaccess (if needed)
File: .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
# CORS headers (if needed for API)
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, POST, OPTIONS"
Header set Access-Control-Allow-Headers "Content-Type"
</IfModule>
Step 4: Create logs Directory
mkdir -p /var/www/html/webgis/logs
chmod 777 /var/www/html/webgis/logs
Testing
Step 1: Run Database Tests
# Access via browser
http://localhost/webgis/TESTS.php
# OR command line
php /var/www/html/webgis/TESTS.php
Expected results: All tests should pass ✓
Step 2: Test API Endpoints
# Test GET endpoint
curl "http://localhost/webgis/get_improved.php?limit=10"
# Test POST endpoint (Create)
curl -X POST http://localhost/webgis/save_improved.php \
-H "Content-Type: application/json" \
-d '{"tipe":"point","nama":"Test","latitude":-0.0554,"longitude":109.3494}'
# Test GET with filter
curl "http://localhost/webgis/get_improved.php?tipe=worship"
Step 3: Test Web Interface
- Open browser:
http://localhost/webgis/ - Verify map loads
- Test adding new feature
- Test editing feature
- Test deleting feature
- Verify data appears on map
Deployment Checklist
- All prerequisite software installed
- Web directory created with proper permissions
- Application files copied to web directory
- Apache modules enabled (Linux)
- Virtual host configured (optional)
- MySQL service running
- Database setup script executed successfully
- All tables created correctly
- Triggers and views created
- Reference data populated
- PHP configuration updated
- .htaccess file created
- logs directory created and writable
- All database tests pass
- API endpoints tested
- Web interface tested
- Backups configured
- Security hardening done
- Production deployment completed
Troubleshooting
Issue: Connection Refused
Error: Could not connect to MySQL
Solution:
# Check MySQL status
sudo systemctl status mysql
# Start MySQL
sudo systemctl start mysql
# Check if MySQL is listening
sudo netstat -tlnp | grep mysql
Issue: Permission Denied
Error: Permission denied on logs or data folder
Solution:
# Fix permissions
sudo chown -R www-data:www-data /var/www/html/webgis/
sudo chmod -R 755 /var/www/html/webgis/
sudo chmod -R 777 /var/www/html/webgis/logs/
sudo chmod -R 777 /var/www/html/webgis/data/
Issue: 404 Error
Error: The requested resource was not found
Solution:
# Check if mod_rewrite is enabled
sudo a2enmod rewrite
# Check virtual host configuration
sudo apache2ctl configtest
# Restart Apache
sudo systemctl restart apache2
Issue: Database Import Error
Error: Unknown collation or charset issues
Solution:
# When running setup script, ensure UTF-8 is used
# In db.php, add:
$conn->set_charset("utf8mb4");
# Or in SQL:
SET NAMES utf8mb4;
Issue: CORS Error in Browser
Error: Access to XMLHttpRequest blocked by CORS policy
Solution:
Add to .htaccess:
<IfModule mod_headers.c>
Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Methods "GET, POST, OPTIONS, DELETE, PUT"
Header set Access-Control-Allow-Headers "Content-Type"
</IfModule>
Maintenance
Daily Tasks
- Check application logs for errors
- Monitor disk space
- Verify database connectivity
Weekly Tasks
- Review access logs
- Check for failed transactions
- Validate data integrity
Monthly Tasks
- Run full database backup
- Test backup restoration
- Review performance metrics
- Update documentation
Quarterly Tasks
- Security audit
- Performance optimization
- Database maintenance (OPTIMIZE, ANALYZE)
- Software updates
Backup Procedure
# Manual backup
mysqldump -u root -p webgis_unified > backup_$(date +%Y%m%d).sql
# Automated daily backup (add to crontab)
0 2 * * * mysqldump -u root -pYOURPASSWORD webgis_unified > /backup/webgis_$(date +\%Y\%m\%d).sql
# List backups
ls -la /backup/
# Restore from backup
mysql -u root -p webgis_unified < backup_20260520.sql
Database Optimization
# Connect to MySQL
mysql -u root -p
# Select database
USE webgis_unified;
# Optimize tables
OPTIMIZE TABLE data_unified;
OPTIMIZE TABLE audit_log;
# Analyze tables
ANALYZE TABLE data_unified;
ANALYZE TABLE audit_log;
# Check table
CHECK TABLE data_unified;
# View table status
SHOW TABLE STATUS;
Security Hardening
1. Change Default Credentials
# MySQL - change root password
mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED BY 'StrongPassword123!';
FLUSH PRIVILEGES;
2. Create Application User
-- Create dedicated user for application
CREATE USER 'webgis_user'@'localhost' IDENTIFIED BY 'AppPassword123!';
-- Grant permissions
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER ON webgis_unified.*
TO 'webgis_user'@'localhost';
FLUSH PRIVILEGES;
3. Update db.php
<?php
$conn = new mysqli("localhost", "webgis_user", "AppPassword123!", "webgis_unified");
?>
4. Disable Directory Listing
Add to .htaccess:
Options -Indexes
5. Set PHP Configuration
; Disable dangerous functions
disable_functions = exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec
; Limit file uploads
upload_max_filesize = 10M
post_max_size = 10M
; Session security
session.secure = On
session.httponly = On
session.samesite = Strict
Performance Optimization
Enable Database Query Caching
; my.cnf
query_cache_type = 1
query_cache_size = 64M
Add Indexes
-- Already included in setup script, verify:
SHOW INDEXES FROM data_unified;
Optimize Queries
// Use LIMIT for large result sets
$limit = 1000;
$offset = 0;
$sql = "SELECT * FROM data_unified LIMIT $limit OFFSET $offset";
Documentation Files
All documentation is included in the application:
SKPL_SRS_WebGIS_PovertyMapping.md- System requirements specificationAPI_DOCUMENTATION.md- API endpoint documentationDEPLOYMENT_GUIDE.md- This fileREADME.md- Quick start guide
Support & Contact
For technical support or issues:
- Check logs:
/var/www/html/webgis/logs/error.log - Review troubleshooting section above
- Contact development team
Last Updated: May 20, 2026
Version: 1.0
Status: Production Ready