๐ Table of Contents
๐ Section 1: phpMyAdmin Installation & Security Configuration
1Generate Secure Random Passwords
Before installing phpMyAdmin, generate three secure random passwords for database authentication and access control:
cat /dev/urandom- Reads random data from the systemtr -dc 'a-za-z0-9'- Filters only alphanumeric charactersfold -w 12- Creates 12-character segmentshead -n 3- Outputs the first 3 passwords
2Create Database Administrator User
Access MySQL and create a privileged database administrator account:
Execute the following SQL commands inside MySQL:
3Verify NGINX Configuration
Test and reload NGINX to ensure configuration integrity:
4Generate HTTP Basic Authentication Credentials
Navigate to the NGINX includes directory and create password hash:
When prompted, enter your chosen password (example: w9sv5hu98q0i). The system will generate a hash like:
5Create Password File
Store the username and hashed password in a dedicated authentication file:
Add the following content (replace with your credentials):
6Install phpMyAdmin
Update package repository and install phpMyAdmin:
7Create Obscured Symbolic Link
Create a symbolic link with a random directory name to obscure phpMyAdmin location:
8Configure NGINX Access Control
Create a dedicated phpMyAdmin configuration file:
Add the following comprehensive security configuration:
your_IP_ADDRESS with your actual public IP
address. To find your current IP when SSH'd into the server, use: last -n3
Security Layer Architecture
9Include Configuration in Default Server Block
Navigate to NGINX sites configuration directory:
Add the following include directive inside your server block:
10Validate and Apply Configuration
Test the NGINX configuration and reload the service:
11Access phpMyAdmin
Open your web browser and navigate to:
๐ Section 2: Log Rotation Configuration
1Configure Global Log Rotation Defaults
Navigate to the logrotate configuration directory and edit the main configuration file:
Make the following changes to optimize log management:
| Setting | Original Value | New Value | Purpose |
|---|---|---|---|
| Rotation Frequency | weekly | daily | More frequent log rotation for better monitoring |
| Retention Period | rotate 4 | rotate 7 | Keep 7 days of backup logs |
| Create New Files | create | create | Create empty log files after rotation |
| Compression | #compress | compress | Compress old logs to save disk space |
2Configure Service-Specific Log Rotation
Navigate to the service-specific logrotate directory:
You will need to modify the following four configuration files:
- fail2ban - Intrusion prevention system logs
- nginx - Web server access and error logs
- rsyslog - System logging daemon
- ufw - Uncomplicated Firewall logs
Edit each file and change weekly to daily and rotate value to
3:
- Change:
weeklyโdaily - Change:
rotate 4โrotate 3
3Verify Log Rotation Configuration
Test the logrotate configuration in debug mode to ensure all settings are correct:
Log Rotation Workflow
๐งน Section 3: NGINX Default Configuration Cleanup
Optimize and secure the default NGINX server block by removing unnecessary configurations and adding security measures:
1Cleanup Objectives
- Remove all comments for cleaner configuration
- Remove the PHP location context (if not needed in default block)
- Add
return 444;to deny direct IP address access
2Optimized Default Server Block
Replace your default server block with this streamlined configuration:
listen 80 default_server;- Listens on port 80 as the default catch-all serverroot /var/www/html;- Sets the document root directoryindex index.php;- Defines default index fileserver_name _;- Wildcard server name (catches all unmatched domains)return 444;- Returns no response and closes connection (security measure)
return 444; directive is a non-standard NGINX
status code that closes the connection without sending a response header. This prevents unauthorized
access via direct IP address and makes your server less visible to automated scanners.
Request Handling Flow
๐ Section 4: FileZilla SFTP Client Setup & Usage
What is FileZilla?
FileZilla is a free, cross-platform SFTP (SSH File Transfer Protocol) client that enables secure file upload and download operations between your local machine and remote server. It is available for Windows, Mac, and Linux operating systems.
1Download FileZilla Safely
- Only download FileZilla from the official website: filezilla-project.org
- Do NOT download from any other source
- Some installers contain bundled offers - follow instructions below to avoid them
2Correct Download Procedure
- Navigate to filezilla-project.org in your web browser
- Select "Download FileZilla Client all platforms"
- DO NOT click the green "Download FileZilla Client" button (contains bundled offers)
- Instead, click "Show additional download options"
- Select the appropriate version for your operating system:
- Windows 64-bit
- Windows 32-bit
- Mac OS Intel
- Mac OS Apple Silicon
- Linux (via package manager)
3Mac Users: Special Setup Requirements
Mac users need to perform additional steps due to hidden directory restrictions:
~/.ssh
directory. Directories starting with a dot (.) are hidden in macOS, and FileZilla cannot directly
access files in hidden directories.
Mac Setup Procedure:
- Create a new directory in your home folder:
- Copy your private key to this new directory using Terminal:
Alternatively, use Finder to copy the file (you'll need to show hidden files first).
4Configure FileZilla Site Manager
After installing FileZilla, configure a new SFTP connection:
Step-by-Step Configuration:
- Launch FileZilla
- Select File โ Site Manager or click the Site Manager icon
- Click "New Site" to create a new connection profile
- Configure the following settings:
| Setting | Value | Notes |
|---|---|---|
| Protocol | SFTP - SSH File Transfer Protocol | Never use FTP - it's insecure |
| Host | Your server IP address | Example: 192.168.1.100 |
| Port | Leave blank (defaults to 22) | Unless you changed SSH port |
| Logon Type | Key file | Use SSH key authentication |
| User | Your non-root username | Example: andrew |
| Key file | Path to your private key | Browse to select the file |
5Select Private Key File
Windows Users:
- Click "Browse" next to Key file
- Navigate to:
C:\Users\YourUsername\.ssh\ - Change file filter from "PPK files" to "All files"
- Select your private key file
Mac Users:
- Click "Browse" next to Key file
- Navigate to the
fzcdirectory you created - Select your private key file
6Key Conversion Process
When you select your private key, FileZilla will prompt you:
Click Yes to convert the key.
- Enter your passphrase to unlock the private key
- FileZilla will convert the key to PuTTY Private Key (PPK) format
- Save the converted key with a meaningful name (e.g., "filezilla_private_key")
- When prompted to remember passwords, choose based on your security preference
7Rename and Connect
- Before connecting, rename "New site" to something meaningful (e.g., "Production Server")
- Click Connect
- If prompted about server fingerprint, verify and click OK to trust and remember
- Enter your passphrase when prompted
8Understanding the FileZilla Interface
FileZilla Window Layout
| Pane | Location | Purpose |
|---|---|---|
| Local Site | Left Side | Your computer's files and folders |
| Remote Site | Right Side | Server's files and folders |
| Local Directory Tree | Top Left (optional) | Can be hidden to save space |
| Remote Directory Tree | Top Right (optional) | Can be hidden to save space |
| Transfer Queue | Bottom | Shows active and queued file transfers |
9Initial Connection Notes
Upon successful connection, you'll be placed in your user's home directory:
You may see directories such as:
- nginx_bash_scripts
- server_bash_scripts
- wp_bash_scripts
10File Upload Best Practices
Recommended Upload Workflow:
- Create a temporary directory in your home folder:
- Upload files from your local machine to this temporary directory
- Use terminal to move files to their final destination with proper permissions
11Transferring Files
Upload Files (Local to Server):
- Navigate to desired folder in left pane (local)
- Navigate to destination in right pane (server)
- Select files in left pane
- Drag and drop to right pane
- Files will upload automatically
Download Files (Server to Local):
- Navigate to source folder in right pane (server)
- Navigate to destination in left pane (local)
- Select files in right pane
- Drag and drop to left pane
- Files will download automatically
- Go to Settings โ Transfers
- Increase "Maximum simultaneous transfers" (recommended: 10)
12Navigating the Server Filesystem
You can navigate outside your home directory, but be aware of permission restrictions:
| Directory | Access Level | Notes |
|---|---|---|
| /home/andrew/ | Full Access | Your home directory - upload here |
| /var/www/ | Read Only | Web server root - view only |
| /var/www/html/yoursite/ | Read Only | WordPress files - view only |
| /var/log/ | Limited | System logs - permission dependent |
| /lost+found/ | No Access | System recovery directory |
13Post-Upload File Management
After uploading files to your temporary directory, use terminal to move them to their final destination:
Example: Moving uploaded files
Example: Copying uploaded files
Cleanup temporary directory:
Secure File Upload Workflow
14WordPress Integration
If you've completed WP-CLI training, you can import uploaded media files properly:
- WordPress tracks media in its database
- Direct file uploads bypass WordPress's media management
- Using WP-CLI ensures proper database entries and thumbnail generation
- Maintains correct file permissions and ownership
15Troubleshooting Common Issues
| Issue | Cause | Solution |
|---|---|---|
| Connection Refused | Firewall blocking connection | Allow FileZilla in firewall settings |
| Permission Denied | Insufficient file permissions | Upload to home directory, then move with sudo |
| Key Format Error | Incorrect key format | Allow FileZilla to convert key to PPK format |
| Timeout Errors | Network or server issues | Check server status, verify SSH is running |
| Cannot See Hidden Files | FileZilla settings | Server โ Force showing hidden files |
16Security Best Practices
- Always use SFTP, never FTP
- Keep FileZilla updated to latest version
- Use strong passphrases for SSH keys
- Only save passwords on trusted devices
- Verify server fingerprint on first connection
- Upload to home directory first, never directly to system directories
- Regularly review and clean up temporary upload directories
- Use key-based authentication instead of passwords
Summary
FileZilla provides a user-friendly graphical interface for secure file transfers via SFTP. By following the proper upload workflow (home directory โ terminal move/copy), you maintain server security and file system integrity while efficiently managing files between your local machine and server.
๐ Conclusion
This comprehensive guide covered four essential aspects of backend server administration:
- phpMyAdmin Security: Multi-layer protection using obscured URLs, HTTP authentication, and IP whitelisting
- Log Rotation: Automated daily log management to maintain system health and save disk space
- NGINX Hardening: Streamlined default configuration that denies unauthorized access attempts
- FileZilla SFTP: Secure file transfer with proper workflows and permission management
- Security is achieved through multiple layers of protection
- Regular log rotation prevents disk space issues and maintains performance
- Proper file upload workflows prevent permission and security issues
- Always use secure protocols (SFTP) instead of insecure alternatives (FTP)
By implementing these configurations, you've significantly improved your server's security posture, maintainability, and operational efficiency. Regular monitoring and maintenance of these systems will ensure continued optimal performance.