
How to Turn Your VPS into a Proxy Server for Web Browsing
June 25, 2025
How to Secure Apache with Let’s Encrypt SSL on a VPS (Step-by-Step Guide)
June 30, 2025Set Up a Secure LAMP Stack with phpMyAdmin on Kali Linux
This guide explains how to set up a LAMP stack (Linux, Apache, MariaDB, PHP) with phpMyAdmin on Kali Linux, using your own domain (e.g., yourdomain.com
). It’s perfect for ethical bug bounty hunters, hosting tools, or running a lightweight web server.
Prerequisites
Before you begin, ensure you have:
- A Kali Linux system (physical or virtual machine).
- A registered domain (e.g.,
yourdomain.com
). - Root or sudo access.
- Basic familiarity with terminal commands.
Step 1: Install Apache, PHP, and MariaDB
The LAMP stack consists of Apache (web server), MariaDB (database), and PHP (server-side scripting). Install them all in one go:
What This Does:
sudo apt update
: Refreshes the package list.apt install
: Installs Apache, PHP, MariaDB, and utilities likeunzip
andcurl
.&&
: Ensures the install command runs only if the update succeeds.-y
: Automatically confirms installation prompts.
Note: Kali Linux uses MariaDB instead of MySQL by default. MariaDB is a drop-in replacement for MySQL, fully compatible with phpMyAdmin and most MySQL-based applications.
After installation, Apache and MariaDB should start automatically. Verify Apache is running:
If it’s not active, start it:
Verify MariaDB is running:
If it’s not active, start it:
Troubleshooting: If you see an error like Package 'mysql-server' has no installation candidate
, it’s because Kali uses MariaDB. Ensure you’re installing mariadb-server
as shown above. If the installation fails, try fixing broken packages with:
🛡️ Step 2: Secure MariaDB
MariaDB needs to be hardened to prevent security risks. Run the built-in security script:
Follow These Prompts:
- Set a root password: Choose a strong password.
- Remove anonymous users: Say Yes to disable unauthenticated access.
- Disallow remote root login: Say Yes for better security.
- Remove test database: Say Yes to delete the default test database.
- Reload privilege tables: Say Yes to apply changes.
Manual Setup (if Script is Unavailable): If the script doesn’t work, secure MariaDB manually:
Replace YourStrongPassword
with a secure password. This ensures your MariaDB database is locked down.
Step 3: Install and Configure phpMyAdmin
phpMyAdmin provides a web interface to manage your MariaDB database. Install it with:
During Installation:
- Select Apache2 when prompted (use the spacebar to select, then Enter).
- The installer automatically configures Apache to work with phpMyAdmin.
Restart Apache to apply changes:
Test phpMyAdmin: Open a browser and visit http://your-server-ip/phpmyadmin
. Log in with your MariaDB root credentials. If you see the phpMyAdmin dashboard, it’s working!
Step 4: Point Your Domain to Your Server
To use your domain (e.g., yourdomain.com
), link it to your server’s IP address via your domain registrar (e.g., GoDaddy, Namecheap).
Steps:
- Log in to your registrar’s DNS management panel.
- Add two A records:
@
→ Your server’s public IPwww
→ Your server’s public IP
- Save changes and wait for DNS propagation (can take up to 48 hours, but usually less).
Verify DNS: Check if your domain points to your server:
If it returns your server’s IP, DNS is set up correctly.
Step 5: Add HTTPS with Let’s Encrypt (Optional)
To secure your site with a free SSL certificate, follow our companion guide: How to Set Up Let’s Encrypt SSL on Apache. This enables https://
for your domain, ensuring encrypted traffic.
Step 6: Test PHP
Confirm PHP is working by creating a test file:
Visit http://yourdomain.com/info.php
(or http://your-server-ip/info.php
if DNS isn’t propagated yet). If you see a PHP info page, your LAMP stack is fully functional.
Note: Delete info.php
after testing for security:
Summary
You’ve set up a secure LAMP stack on Kali Linux with:
- Apache: Serving your website.
- MariaDB: Managing your database.
- PHP: Running server-side scripts.
- phpMyAdmin: Simplifying database management.
- Optional HTTPS: Securing your site with Let’s Encrypt.
- Custom domain: e.g.,
yourdomain.com
.
This setup is ideal for hosting WordPress, bug bounty tools, or custom web apps. Want to add virtual hosts, subdomains (e.g., xss.yourdomain.com
), or further harden your server? Let us know!
🛠️ Troubleshooting Tips
If you encounter issues while setting up your LAMP stack or phpMyAdmin, try these steps to diagnose and resolve common problems.
1. “Command Not Found” Error
If you see the error sudo: mysql_secure_installation: command not found
, the mysql_secure_installation
script may be missing. Follow these steps:
- Reinstall MariaDB Components:
sudo apt install –reinstall mariadb-server mariadb-client -y
- Fix Broken Packages:
sudo apt –fix-broken install
- Locate the Script:
Search for the
mysql_secure_installation
script:find / -name mysql_secure_installation 2>/dev/nullIf found (e.g.,
/usr/bin/mysql_secure_installation
), run it:sudo /usr/bin/mysql_secure_installation
2. “Can’t Connect to Server” Error
If you encounter ERROR 2002 (HY000): Can't connect to local server through socket '/run/mysqld/mysqld.sock' (2)
, MariaDB may not be running. Try these steps:
- Check MariaDB Status:
sudo systemctl status mariadb
- Start MariaDB:
If the service is not running, start it:
sudo systemctl start mariadb - Restart MariaDB:
If starting fails, try restarting:
sudo systemctl restart mariadb - Reinstall MariaDB:
If the issue persists, purge and reinstall MariaDB:
sudo apt purge mariadb-server mariadb-client && sudo apt install mariadb-server mariadb-client -y - Check Logs:
Review the logs for more details:
sudo journalctl -u mariadb
Additional Tips:
- Apache not running? Check status with sudo systemctl status apache2or start it withsudo systemctl start apache2.
- phpMyAdmin login fails? Ensure you’re using the MariaDB root password set in Step 2.
- Domain not resolving? Wait for DNS propagation or verify A records with dig +short yourdomain.com.

sudo systemctl start apache2
and recheck the status.
sudo systemctl start mariadb
.⭐ Ready for a reliable, high-performance VPS at an unbeatable price? We host our own Kali labs on Hostinger: 4 vCPU, NVMe storage, 16 GB RAM and 16 TB bandwidth, backed by 24/7 support and a 30-day money-back guarantee. You’ll save up to 20% when you lock in a 24-month plan. Grab a Hostinger VPS using this referral link and support our content.
👉 Claim your Hostinger VPS (from only US$ 7.99/mo)