Tested on Ubuntu/Debian/CentOS
???? Prerequisites
-
A VPS with root/SSH access
-
Basic Linux command-line knowledge
-
10-15 minutes of time
1️⃣ Update Your System
# For Ubuntu/Debian: sudo apt update && sudo apt upgrade -y # For CentOS/RHEL: sudo yum update -y
2️⃣ Install a Web Server
Option A: Apache (Easy & Universal)
# Ubuntu/Debian: sudo apt install apache2 -y # CentOS: sudo yum install httpd -y
Start & Enable:
sudo systemctl start apache2 # or httpd (CentOS) sudo systemctl enable apache2
✅ Verify: Visit your server’s IP in a browser. You should see the Apache test page.
Option B: Nginx (Fast & Lightweight)
sudo apt install nginx -y # Ubuntu/Debian sudo yum install nginx -y # CentOS
Start & Enable:
sudo systemctl start nginx sudo systemctl enable nginx
✅ Verify: Check http://[your-server-IP]
for the Nginx welcome page.
3️⃣ Install MySQL/MariaDB (Database)
# Ubuntu/Debian: sudo apt install mariadb-server -y # CentOS: sudo yum install mariadb-server -y
Secure Installation:
sudo mysql_secure_installation
(Follow prompts to set a root password and remove insecure defaults)
4️⃣ Install PHP (For Dynamic Content)
# Ubuntu/Debian: sudo apt install php php-mysql -y # CentOS: sudo yum install php php-mysql -y
Test PHP:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
✅ Visit http://[your-server-IP]/info.php
to see PHP details.
5️⃣ Configure Firewall
Allow HTTP/HTTPS traffic:
# Ubuntu/Debian (UFW): sudo ufw allow 80/tcp sudo ufw allow 443/tcp # CentOS (FirewallD): sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo firewall-cmd --reload
6️⃣ Auto-Start Services
Ensure services launch on reboot:
# For Apache: sudo systemctl enable apache2 # or httpd # For Nginx: sudo systemctl enable nginx # For MariaDB: sudo systemctl enable mariadb
???? Next Steps
-
Upload your website via SFTP/FTP
-
Secure with SSL (Use Let’s Encrypt):
sudo apt install certbot -y sudo certbot --apache # or --nginx
-
Optimize performance (Enable caching, use PHP-FPM)
???? Pro Tips
-
Need a control panel? Try:
-
Webmin (Free)
-
CyberPanel (For OpenLiteSpeed)
-
-
Docker option? Run Nginx/PHP in containers for isolation.
Example LAMP Stack in One Command (Ubuntu):
sudo apt update && sudo apt install apache2 mariadb-server php php-mysql -y && sudo mysql_secure_installation
???? Done!
You now have a self-hosted web server! Need help? Contact AuxoDomain Support.