Setup VM Production Ready Best Practice
V1 (GENERATED BY DEEPSEEK)
Berikut adalah langkah-langkah best practice untuk setup VM production ready:
1. Update & Upgrade Sistem
sudo apt update && sudo apt upgrade -y
sudo apt dist-upgrade -y
sudo apt autoremove -y
sudo apt clean2. Buat User Baru (Non-Root)
sudo adduser deployer # Ganti dengan username yang diinginkan
sudo usermod -aG sudo deployer # Tambah ke group sudo3. Setup SSH Security
# Ganti port SSH (pilih antara 1024-65535)
sudo nano /etc/ssh/sshd_config
# Ubah konfigurasi:
Port 2222 # Contoh port custom
PermitRootLogin no
PasswordAuthentication no
AllowUsers deployer
# Restart SSH
sudo systemctl restart sshd
# SEBELUM KELUAR: Buka terminal baru untuk test koneksi ke port baru!4. Setup Firewall (UFW)
5. Install Nginx
6. Install Fail2Ban
7. Install Certbot (SSL)
8. Install PHP & Dependencies untuk CI3
9. Install CodeIgniter 3
10. Konfigurasi Nginx
11. Database Setup (Opsional)
12. Hardening Security Tambahan
13. Auto Update Security
14. Final Check
Best Practice Tambahan:
Gunakan SSH Key Authentication
Setup monitoring (seperti Netdata atau Prometheus)
Implementasi backup harian
Setup intrusion detection system (IDS)
Gunakan Cloudflare sebagai additional security layer
Regular security audit
Monitor logs dengan tools seperti Logwatch
Pastikan untuk:
Mengganti semua placeholder (example.com, deployer, dll)
Menyimpan SSH key di tempat aman
Membuat backup sebelum melakukan perubahan besar
Memonitor resource usage secara berkala
V2 (GENERATED BY DEEPSEEK)
Berikut revisi yang lebih lengkap dengan PHP 7.3 dan tambahan hardening security:
1. Initial Setup & System Hardening
2. User Management & SSH Hardening
3. Firewall Configuration
4. Install PHP 7.3 & Ekstensi
5. Install Nginx dengan Optimalisasi
6. Install MariaDB & Hardening
7. Install CodeIgniter 3 dengan Secure Configuration
8. SSL dengan Certbot & Optimalisasi
9. Nginx Server Block Configuration
10. Advanced Security Setup
11. Final Touches
12. Post-Install Checklist
Test PHP info: Buat file
info.phpdan pastikan PHP 7.3 terinstallTest koneksi database dari CI3
Cek semua log (/var/log/nginx/*.log, /var/log/fail2ban.log)
Test SSL: https://www.ssllabs.com/ssltest/
Scan port dari luar:
nmap -sV -p- your_server_ipSetup monitoring (cth: Netdata atau Prometheus)
Implementasi WAF (ModSecurity)
Setup log rotation untuk aplikasi
Yang perlu diperhatikan:
Ganti semua contoh domain (example.com) dengan domain Anda
Simpan SSH key di tempat aman
Backup konfigurasi sebelum melakukan perubahan besar
Update password database dengan yang lebih kuat
Setup monitoring resource (memory, CPU, disk)
Lakukan audit security secara berkala
Revisi ini mencakup:
PHP 7.3 spesifik
Kernel hardening
SSL optimalisasi
Security headers lengkap
File integrity monitoring
Backup otomatis
Tambahan WAF dan monitoring
Konfigurasi database yang lebih aman
Perlindungan terhadap serangan umum di level server
Pastikan untuk menyesuaikan semua placeholder (example.com, deployer, password, dll) sesuai kebutuhan Anda!
MYSQL 5.7
It's important to note that MySQL 5.7 is quite old and is no longer actively supported by the MySQL community. It's highly recommended to install a more recent and secure version of MySQL, such as 8.0. However, if you have a specific reason to install MySQL 5.7 on Ubuntu 24.04.2 LTS, here are the steps:
Warning: Installing older, unsupported software can introduce security vulnerabilities. Proceed with caution and ensure you understand the risks involved.
Step 1: Download the MySQL 5.7 APT Repository Configuration Package
Ubuntu 24.04 repositories do not include MySQL 5.7 by default. You need to download and install the MySQL APT repository configuration package for older Ubuntu versions.
Bash
Step 2: Install the Repository Configuration Package
Install the downloaded package using dpkg.
Bash
During the installation, you will be presented with a configuration menu. Carefully navigate this menu using the arrow keys and select the following:
MySQL Server and Cluster: Choose
mysql-5.7.MySQL Tools & Connectors: You can keep the default selections or choose specific components if needed.
MySQL Workbench: You can keep the default or deselect if you don't need it on the server.
MySQL Shell: You can keep the default or deselect if you don't need it on the server.
Use the arrow keys to move between options and the Enter key to select. Use the Tab key to move between "Ok" and "Cancel" buttons. Select "Ok" when you have made your choices.
Step 3: Update the APT Package Index
After configuring the repository, update the APT package index to reflect the new available packages.
Bash
Step 4: Install the MySQL 5.7 Server
Now you can install the MySQL 5.7 server package.
Bash
During the installation, you will be prompted to set a root password for your MySQL server. Remember this password carefully!
Step 5: Verify MySQL 5.7 is Running
After the installation is complete, check if the MySQL service is running.
Bash
You should see output indicating that the mysql.service is active (running).
Step 6: Secure Your MySQL Installation
It's crucial to secure your MySQL installation. Run the mysql_secure_installation script.
Bash
This script will guide you through several security-related steps:
Validate Password Plugin: You can choose to enable or disable the password validation plugin. It's recommended to enable it for stronger passwords.
Change the root password: If you didn't set a strong password during installation, you'll be prompted to change it now.
Remove anonymous users: It's recommended to remove anonymous users for security.
Disallow root login remotely: Unless you have a specific need, it's generally recommended to disallow root login from remote hosts.
Remove test database and access to it: Removing the test database and related privileges is a good security practice.
Answer the prompts according to your security requirements.
Step 7: (Optional) Configure Firewall
If you have a firewall enabled (like ufw), you might need to allow connections to the MySQL port (default is 3306).
Bash
Step 8: (Optional) Connect to the MySQL Server
You can now try connecting to your MySQL 5.7 server using the mysql client.
Bash
You will be prompted for the root password you set during the installation.
Important Considerations:
Security: As mentioned earlier, MySQL 5.7 is no longer actively supported. This means it won't receive security updates, making your server vulnerable. Consider upgrading to a newer version as soon as feasible.
Compatibility: Some newer applications or libraries might have compatibility issues with older MySQL versions.
Repository Stability: The availability of the MySQL 5.7 repository for Ubuntu 24.04 in the long term is not guaranteed.
By following these steps, you should be able to install MySQL 5.7 on your Ubuntu 24.04.2 LTS server. However, remember the security implications and consider upgrading to a supported version.
Last updated