Launching a simple HTML website on your own Linux server is easier than you might think. Whether you're sharing a static landing page or integrating HTML into a backend system like Flask, here’s a complete hands-on guide you can follow.
🔥 Method 1 — Deploying Directly to Apache Web Server
Apache by default serves files from the directory:
/var/www/html
Step-1: Create/Verify the HTML Folder
sudo mkdir -p /var/www/html
cd /var/www/html
Step-2: Upload Your HTML File
Use SFTP tools like FileZilla, WinSCP, or sftp command-line to copy cortex.html
(or your HTML file) from your local machine to /var/www/html.
💡 You may need folder permissions from your server admin.
Step-3: (Optional) Create/Edit HTML Directly in Server
sudo vim /var/www/html/cortex.html
Common Vim commands:
:wq Save and exit
:q! Exit without saving
:w Save only (don’t exit)
Step-4: Set Correct Permissions
sudo chmod 644 /var/www/html/cortex.html
sudo chmod 644 /var/www/html/index.html
Step-5: Fix File Naming (optional)
sudo mv /var/www/html/Cortex.html /var/www/html/cortex.html
Step-6: Confirm Apache DocumentRoot
DocumentRoot "/var/www/html"
Step-7: Restart Apache
sudo systemctl restart httpd #
CentOS/RHEL
sudo systemctl restart apache2 #
Ubuntu/Debian
Your page should now load at:
http://<server-ip>/ or http://<server-ip>/cortex.html
Method 2 — Serve HTML Inside a Flask App on Custom Port (81)
Sometimes, we want to deploy HTML via a Flask application running behind Apache
on a different port, e.g. 81.
Folder Structure
/var/www/flaskapp/
└── templates/
├── index.html
└── se.html <- (optional subpage)
Step-1: Copy the HTML into Flask Template
sudo cp /var/www/html/cortex.html /var/www/flaskapp/templates/index.html
Step-2: Add Apache VirtualHost for Port 81
<VirtualHost *:81>
ServerName yourdomain.com
DocumentRoot /var/www/flaskapp
WSGIScriptAlias /
/var/www/flaskapp/flaskapp.wsgi
</VirtualHost>
Step-3: Restart Apache
sudo systemctl restart httpd
Open in browser:
http://<server-ip>:81/
Updating HTML Pages Later
Upload new version using SFTP to /var/www/ and then run:
sudo cp /var/www/cortexV3.html /var/www/flaskapp/templates/index.html
sudo systemctl restart httpd
Adding New Pages
sudo cp /var/www/cortexV4.html /var/www/flaskapp/templates/se.html
sudo chmod 644 /var/www/flaskapp/templates/se.html
sudo systemctl restart httpd
Open page at: http://<server-ip>:81/se
Summary
Task Command (Linux)
Create HTML folder sudo mkdir -p
/var/www/html
Upload via SFTP Use FileZilla/WinSCP or sftp
Edit file vim
/var/www/html/filename.html
Set permission sudo chmod 644
file.html
Restart Apache sudo systemctl
restart httpd
Copy to Flask app sudo cp source
destination
Final Thoughts
With just a handful of commands and SFTP access, you can deploy static HTML
pages directly with Apache or plug them into a Python-based Flask app running
on a custom port. This manual method gives you full control over your
deployment — perfect for learning, testing, or lightweight production websites.
No comments:
Post a Comment