AdminsForum

Paste the error. Find the fix.

Step-by-step guides and community answers for Linux servers, VPS and hosting control panels.

New threads

The latest guides and questions from every forum.

aaPanel Websites & Web Servers Guides

Manage Python Packages with requirements.txt in aaPanel

requirements.txt records the Python packages an application needs, so you can install them into the correct environment and rebuild the app later. In aaPanel, the key is using the Python executable from the environment selected for that project.

Tested: Our Flask project on aaPanel Free 8.0.7 uses af_python_lab. We also created a separate clean environment, installed the sample's requirements, ran pip check and started the restored app on a different local port. This lesson uses SSH commands for package management; it does not claim a new aaPanel package-management screen exists.

   
Dependency workflow diagram: record, install, check and run the application.

1. Find the project's actual environment
Open Website → Python Project, click the project and inspect Project information → Python Environment. Our selected environment is af_python_lab. Its actual path on this panel version is:
Code:
/www/server/pyporject_evn/af_python_lab
Do not assume the path is identical on every release. Verify the executable before installing packages:
Code:
/www/server/pyporject_evn/af_python_lab/bin/python --version /www/server/pyporject_evn/af_python_lab/bin/python -m pip --version
The pip output should point inside that environment. Using python -m pip ties the installer to the chosen interpreter, avoiding a different pip from the shell's PATH.

2. Create requirements.txt beside the app
For our small sample, the project folder is /www/wwwroot/af-flask-lab and the file contains:
Code:
Flask==3.1.3 gunicorn==26.2.0
Each line names a package; == pins the direct version. These are the versions tested in this lab, not an instruction to upgrade every existing app to them. Use your application's known compatible versions and include its real direct dependencies.

This two-line file does not pin every transitive dependency. Pip will resolve Flask's dependencies when it installs the file. For stronger repeatability, keep a reviewed full version snapshot or the lock file used by your project's dependency workflow.

3. Understand pip freeze before using it
To inspect installed packages in this environment:
Code:
/www/server/pyporject_evn/af_python_lab/bin/python -m pip list /www/server/pyporject_evn/af_python_lab/bin/python -m pip freeze
A freeze snapshot includes installed packages, including packages added by tools or unrelated experiments in that same environment. It does not identify which ones your application directly uses. Review it before using it as your application requirements file, and avoid overwriting an existing reviewed file without keeping a copy.

AaPanel initialized additional support packages in our project environment. For the tiny Flask restore, we used the application's two direct dependencies instead of blindly copying every installed package.

4. Install using the intended environment and user
If the environment belongs to www, run the installer as that user. Give it a writable cache inside the project rather than broadening permissions on system directories:
Code:
runuser -u www -- /www/server/pyporject_evn/af_python_lab/bin/python  -m pip install --cache-dir /www/wwwroot/af-flask-lab/.pip-cache  -r /www/wwwroot/af-flask-lab/requirements.txt
The project and environment must already have appropriate ownership for www. If the command reports Permission denied, inspect that specific path; do not apply chmod 777 to the environment or the whole website tree.

Review the requirements file and package source before installation. Do not paste credentials into package URLs that may appear in shell history or logs. For a running application, rehearse dependency changes in a separate environment and plan rollback before changing its live packages.

5. Check consistency and run the app
Use the same interpreter:
Code:
/www/server/pyporject_evn/af_python_lab/bin/python -m pip check /www/server/pyporject_evn/af_python_lab/bin/python -m pip show Flask gunicorn
A successful pip check reports no incompatible or missing declared package requirements. It does not prove your application behavior is correct, so also test startup and a meaningful application request.

6. Prove the file can rebuild a clean environment
Our recovery exercise created a new environment under /www/af-flask-restore-20261014/venv and installed:
Code:
/www/af-flask-restore-20261014/venv/bin/python -m pip install  -r /www/af-flask-restore-20261014/af-flask-lab/requirements.txt /www/af-flask-restore-20261014/venv/bin/python -m pip check
The installation succeeded with Flask 3.1.3 and Gunicorn 26.2.0. Pip check reported No broken requirements found. The rebuilt app returned HTTP 200 and AdminsForum Flask lab on 127.0.0.1:3202, then the temporary test process was stopped. The live website still returned HTTP 200.

See Back Up and Restore a Flask App for the complete isolated test. A separate environment prevents a failed experiment from replacing the live application's dependencies.

Common errors
  • No module named flask: verify the project uses the same environment in which you installed Flask.
  • No matching distribution: check whether the requested package version supports your Python version and platform.
  • Permission denied: check the installer user, environment ownership and cache directory.
  • Dependency conflict: read the reported package versions; test compatible pins in a clean environment rather than forcing an inconsistent installation.
  • Packages install but app fails: check the startup command, environment variables, OS libraries and application logs. Pip cannot configure those for you.

Completion checklist
  • Correct project environment identified.
  • Application dependency file reviewed and backed up.
  • Install and verification use the same interpreter.
  • Pip check passes.
  • Clean-environment rebuild and application response tested.

Reference: Official pip requirements-file documentation and pip freeze documentation.

Tested and illustrated by AdminsForum. Diagram summarizes our lab workflow; use paths and versions appropriate to your application.
DEV 10-14-2026, 07:13 AM Read thread
aaPanel Backups & Migration Guides

Back Up and Restore a Flask App on an aaPanel Server

A backup is useful only when you can rebuild and run the application from it. This SSH-based guide backs up a small Flask project hosted by aaPanel, restores it outside the live website folder and tests it on a separate localhost port.

Tested lab: Ubuntu 22.04.5, aaPanel Free 8.0.7 and a Flask/Gunicorn sample. This is a source-and-dependency recovery exercise, not a complete VPS image or a walkthrough of an aaPanel backup plugin.

   
Restore workflow diagram. The live app and the recovery test remain separate.

1. Define what must be recovered
Our sample has app.py and requirements.txt and no database, uploads or secret configuration. A real app may also need a consistent database export, uploaded files, environment secrets, Nginx configuration and its startup settings. Inventory those separately before claiming a complete backup.

The live project directory is /www/wwwroot/af-flask-lab. Its Gunicorn command uses app:app and binds 127.0.0.1:3200. Record your environment path, Python version, startup user, domain and mapping port in a protected recovery note.

2. Record the application's packages
Place a reviewed requirements.txt beside app.py. Our small sample contains:
Code:
Flask==3.1.3 gunicorn==26.2.0
These are the versions tested in this lab. This pins direct dependencies; it does not lock every transitive dependency. For stronger repeatability, retain a reviewed full dependency snapshot or a suitable lock file and test it in a clean environment.

3. Create a protected source archive
Choose a new archive name so you do not overwrite an older recovery point. From the VPS terminal, the equivalent command for our two-file sample is:
Code:
tar -czf /www/backup/af-flask-20261014.tar.gz -C /www/wwwroot af-flask-lab/app.py af-flask-lab/requirements.txt chmod 600 /www/backup/af-flask-20261014.tar.gz tar -tzf /www/backup/af-flask-20261014.tar.gz
Check that both expected files are listed. Our archive was 377 bytes because this is a tiny text-only sample, not a full production application.

Do not publish backup archives inside a website document root. Rebuild the virtual environment rather than assuming a copied environment is portable between server paths or operating systems. Save a protected off-site copy through your approved backup destination; a local archive alone does not protect against losing the VPS. Off-site transfer was not performed in this exercise.

4. Restore into a new isolated directory
Use a new directory that does not already contain files:
Code:
mkdir /www/af-flask-restore-20261014 tar -xzf /www/backup/af-flask-20261014.tar.gz -C /www/af-flask-restore-20261014
Only extract your trusted archive after inspecting its file list. Do not extract into the live project for a rehearsal. The restored app is now under /www/af-flask-restore-20261014/af-flask-lab.

Compare app.py and requirements.txt with the source copies. For example:
Code:
sha256sum /www/wwwroot/af-flask-lab/app.py sha256sum /www/af-flask-restore-20261014/af-flask-lab/app.py
Our test compared both files with SHA-256 and both matched. A matching hash proves the file content matches; it does not yet prove the app can run.

5. Build a fresh environment
Use a Python version compatible with the application. Our existing lab uses /usr/bin/python3.10; choose a maintained compatible release for a new deployment. Ubuntu's matching venv package must already be installed.
Code:
python3 -m venv /www/af-flask-restore-20261014/venv /www/af-flask-restore-20261014/venv/bin/python -m pip install -r /www/af-flask-restore-20261014/af-flask-lab/requirements.txt /www/af-flask-restore-20261014/venv/bin/python -m pip check
Our fresh environment installed the recorded direct versions and pip check reported No broken requirements found. Install from trusted package sources. If your project needs OS libraries, document and rebuild those too.

6. Run the restored app on a different local port
Set permissions only on the isolated restore directory for the intended application user. In our lab that user is www. From an administrator terminal:
Code:
chown -R www:www /www/af-flask-restore-20261014 cd /www/af-flask-restore-20261014/af-flask-lab runuser -u www -- /www/af-flask-restore-20261014/venv/bin/gunicorn --workers 1 --bind 127.0.0.1:3202 app:app
This foreground command occupies that terminal. From a second terminal:
Code:
curl -i http://127.0.0.1:3202/
Our restore returned HTTP 200 and AdminsForum Flask lab. Port 3202 stayed local and did not replace the live app on 3200. Stop the foreground recovery process with Ctrl+C when the test is finished. We stopped the temporary test process and rechecked the live HTTPS site, which still returned HTTP 200.

Before using this for a real recovery
Test database connectivity, uploads, background jobs, secrets, logging and the expected user workflow. A two-file Flask test cannot establish those properties. Restore missing resources before changing the live domain or project path. Plan cutover and rollback separately; a rehearsal should not overwrite your running deployment.

Completion checklist
  • Backup contents inspected and protected.
  • Isolated restore directory used.
  • Source file hashes compared.
  • Fresh environment built and dependencies checked.
  • Restored application tested on a separate local port.
  • Temporary process stopped and live website checked.
  • Off-site retention and application-specific data still included in the wider recovery plan.

AdminsForum lab-tested guide. Illustration is a workflow diagram; commands describe the tested SSH recovery method.
DEV 10-14-2026, 07:11 AM Read thread
aaPanel Websites & Web Servers Guides

Fix Python and Flask 502 Bad Gateway in aaPanel

A 502 Bad Gateway response from Nginx usually means it could not get a valid response from the application behind it. For a Flask project, diagnose Gunicorn and the local port before changing DNS or opening firewall ports.

Tested lab: aaPanel Free 8.0.7 on Ubuntu 22.04.5. Project af_flask_lab uses Gunicorn on 127.0.0.1:3200 and Nginx serves flask.adminslab.com. We deliberately stopped this disposable project, reproduced public HTTP 502, then started it and recovered HTTP 200. No production website was stopped.

   
Diagnostic workflow diagram: check the app before changing its proxy configuration.

1. Separate the error from a certificate problem
Open the hostname and record the actual response. A page saying 502 Bad Gateway is different from a TLS certificate warning, DNS failure or application-generated 500. Do not disable certificate validation to make the test appear successful.

2. Test the local application port
From the VPS terminal, replacing 3200 with your actual port:
Code:
curl -i http://127.0.0.1:3200/ ss -lntp | grep ':3200'
  • Connection refused/no listener: the app is stopped, failed at startup or bound to another port.
  • HTTP 200 locally but 502 publicly: inspect Nginx mapping and compare its upstream with the working listener.
  • Application 500 locally: investigate the application traceback, configuration and database dependencies.
Do not expose the Gunicorn port to the Internet as a workaround. Nginx can reach a localhost listener without a public firewall rule for 3200.

3. Check aaPanel project status and logs
Open Website → Python Project, click the project name, then open Project logs. In our lab the log is:
Code:
/www/wwwlogs/python/af_flask_lab/error.log
Read the newest startup messages. Look for ModuleNotFoundError, an incorrect callable, Permission denied, Address already in use or a missing environment executable. These need different fixes.

For our app, Project information uses:
  • Environment: af_python_lab
  • Path: /www/wwwroot/af-flask-lab
  • Startup way: Command Startup
  • User: www
  • Command: gunicorn --workers 1 --bind 127.0.0.1:3200 app:app
The first app in app:app means app.py; the second means the Flask object named app. Match your own module and object instead of copying this blindly.

4. Confirm the right packages are installed
Use the selected environment's Python executable, not an unrelated system pip:
Code:
/www/server/pyporject_evn/af_python_lab/bin/python -m pip show Flask gunicorn /www/server/pyporject_evn/af_python_lab/bin/python -m pip check
The path above is the actual directory name used by this lab's aaPanel version. Use your environment path if different. Install missing application packages from its reviewed requirements file, then retry startup. Do not solve package errors by installing everything globally as root.

5. Compare the Nginx mapping
In the project window, open Mapping. Confirm external network mapping is enabled and its detected port matches the actual Gunicorn listener. Ensure the domain is attached to this project in Domain Manager.

For our HTTP Gunicorn app, Nginx routes to:
Code:
proxy_pass http://127.0.0.1:3200;
A wrong port or using https for a plain-HTTP upstream can prevent Nginx from connecting. If you edit Nginx configuration, back it up, validate it and reload only after validation succeeds. Avoid replacing the entire configuration with an unrelated example.

6. Start the app and verify both paths
Use the project's Start control after fixing the cause. Wait for the process to initialize, then test localhost and the public hostname again. In our controlled lab test:
  • Before stopping: public HTTPS returned HTTP 200 and AdminsForum Flask lab.
  • After the native stop command: public HTTPS returned HTTP 502.
  • After the native start command: public HTTPS returned HTTP 200 with the expected Flask response.
This proves a stopped upstream can produce this symptom. It does not prove every 502 has that cause.

If the problem occurs after reboot
Check the native Startup option and allow for its advertised 120-second daemon interval. See Python startup and reboot recovery. That guide also documents a lab-version issue where saving project settings removed the SSL listener; verify HTTPS separately after settings changes.

When asking for support
Share the aaPanel version, startup method, sanitized command, local HTTP result, mapping port and relevant recent log lines. Remove passwords, tokens, cookies, private keys and database connection secrets before posting.

AdminsForum lab-tested troubleshooting guide. Illustration is a workflow diagram, not a screenshot of an error page.
DEV 10-14-2026, 07:10 AM Read thread
aaPanel Websites & Web Servers Guides

Auto-Start Python and Flask Apps After Reboot in aaPanel

A Python project that works today can remain offline after a VPS reboot unless its startup setting is enabled. This guide enables aaPanel's native recovery option and verifies that a Flask app actually returns after a real reboot.

Tested: Ubuntu 22.04.5 and aaPanel Free 8.0.7, with Flask served by Gunicorn through Nginx. Our project is af_flask_lab and listens on 127.0.0.1:3200. Replace these values with your own project. A reboot temporarily interrupts every service on that VPS; use a lab or a planned maintenance window.

1. Confirm the app is healthy first
Complete Run Flask with Gunicorn and, if you need a public hostname, Connect Flask to a Domain and HTTPS.

Open Website → Python Project and confirm the application is running. From the VPS terminal:
Code:
curl -i http://127.0.0.1:3200/
You should receive HTTP 200 and your expected application response. Resolve startup errors before testing reboot recovery.

2. Enable aaPanel's Startup option
Click the project name, then open Project information. Locate Startup and tick the checkbox labelled default built-in daemon checks every 120 seconds. Click Save.

   
Enable the native Startup checkbox for the correct Python project, then save its settings.

This setting tells aaPanel to recover the project when its daemon finds it stopped. It is not an immediate availability guarantee: the panel advertises a 120-second check interval. Keep the same working startup command, environment, project path and non-root user.

Our command remained:
Code:
gunicorn --workers 1 --bind 127.0.0.1:3200 app:app
The selected environment was af_python_lab and the startup user was www. Do not create a second systemd or cron launcher for the same process while using the native panel daemon; two launchers can compete for the same port.

3. Recheck HTTP and HTTPS after saving
Before rebooting, check localhost and the public hostname again. In our aaPanel 8.0.7 lab, saving the Python project settings regenerated its Nginx configuration and removed the 443 SSL listener. The app still worked on localhost, but public HTTPS selected another site's certificate and failed hostname validation.

This is a separate configuration problem, not proof that Gunicorn failed. Check SSL and the project's Nginx Config after saving. Back up the configuration before editing it. For this lab we restored the HTTPS listener and the existing certificate references, validated Nginx configuration and reloaded Nginx. We did not issue another certificate.

The existing certificate paths in this lab were:
Code:
/www/server/panel/vhost/cert/af_flask_lab/fullchain.pem /www/server/panel/vhost/cert/af_flask_lab/privkey.pem
Your project may have different paths. Do not copy another site's certificate or publish private-key contents. Normal HTTPS validation must pass; do not hide the error with curl -k.

4. Record the current boot before rebooting
From the VPS terminal:
Code:
cat /proc/sys/kernel/random/boot_id
Keep this value locally. After the reboot it must differ, proving you tested a new server boot rather than a simple browser refresh.

Reboot only after your work is saved and you have a working way to reconnect. In a disposable test VPS, a normal reboot command is:
Code:
sudo reboot
An SSH disconnection is expected while the server restarts. A browser tab can also lose its aaPanel session; signing back into the panel is separate from restarting the application.

5. Verify recovery without manually starting the app
Reconnect through SSH after the VPS is reachable. Check:
Code:
cat /proc/sys/kernel/random/boot_id ss -lntp | grep ':3200' curl -i http://127.0.0.1:3200/ curl -i https://your-hostname/
Wait for the native daemon's recovery interval if the application has not returned yet. Do not click Start during the automatic recovery test, because that would invalidate the test.

Our new boot ID differed from the original. Gunicorn returned automatically with a master and worker listening on 127.0.0.1:3200. After restoring the SSL listener described above, the public Flask hostname returned HTTP 200 with AdminsForum Flask lab and passed certificate validation. Nginx, Postfix and Dovecot were also active.

6. Inspect logs if recovery fails
In the project window, open Project logs. Check the latest startup attempt rather than old messages. For this project, the error log was:
Code:
/www/wwwlogs/python/af_flask_lab/error.log
Typical problems include a missing virtual environment, incorrect working directory, missing packages, a port already in use or a startup user unable to read the app files. Confirm that the same command still starts the app in its intended environment before changing the daemon.

Know the limits of this test
  • A successful reboot test confirms recovery for the tested app and configuration. It does not test database recovery, queues, upload persistence or every application dependency.
  • Startup recovery can cause a short period of 502 responses while Nginx is running but Gunicorn has not started yet.
  • Because the native daemon recovers stopped projects, temporarily disable Startup when deliberately keeping an app stopped for maintenance; restore it when the maintenance is finished.
  • Repeat HTTP and HTTPS checks after later project edits. The SSL configuration issue above was observed on this lab version, not assumed for every aaPanel release.

Completion checklist
  • Startup checkbox enabled and saved.
  • Correct environment, project path and non-root user retained.
  • A real reboot confirmed by a changed boot ID.
  • App returned without a manual Start action.
  • Local response, public mapping and HTTPS checked separately.
  • Any recovery errors explained using current logs.

Tested on the AdminsForum lab VPS. Screenshot and test results are from our own deployment.
DEV 10-14-2026, 07:06 AM Read thread
aaPanel Websites & Web Servers Guides

Connect a Flask App to a Domain and HTTPS in aaPanel

A Flask app can work on localhost while still being unavailable through its domain. This guide connects a running Gunicorn project to Nginx, points a hostname at the VPS and enables HTTPS with a trusted certificate.

Tested lab: Ubuntu 22.04.5, aaPanel Free 8.0.7, Nginx 1.30.5, Flask 3.1.3 and Gunicorn 26.2.0. The public test hostname is flask.adminslab.com. Replace the hostname and VPS address with your own values. Menu wording can vary by panel version.

Before you start
  • Complete Run a Flask App with Gunicorn in aaPanel. This lesson assumes the Python project is already running.
  • Have control of the domain's DNS. Nginx must be installed and the VPS must accept incoming TCP 80 and 443 through both its server firewall and any provider firewall.
  • The application should listen on localhost, not a public interface. Our Gunicorn command is:
Code:
gunicorn --workers 1 --bind 127.0.0.1:3200 app:app
Port 3200 is the private application port. Visitors use 80 or 443 through Nginx; you do not need to open 3200 to the Internet.

1. Check the application before changing DNS
In aaPanel, open Website → Python Project. Check that your project is running. Our project is af_flask_lab. If it does not start, open Project logs and fix the startup error first.

From the VPS terminal, test:
Code:
curl -i http://127.0.0.1:3200/
Our test returned HTTP 200 and the body AdminsForum Flask lab. If this fails, a certificate or DNS change will not repair the application itself.

2. Add the domain to the Python project
Click the project name to open its management window. Select Domain Manager, enter your full hostname (for example, flask.example.com) without https:// or a path, and add it on port 80. Confirm that the domain appears in the project's domain list.

Do not create a separate PHP website with the same hostname. The Python project should own the hostname so Nginx sends requests to the correct application.

3. Point the DNS record at the VPS
If the domain uses Cloudflare nameservers, open the domain in Cloudflare and choose DNS → Records → Add record. For our subdomain we used:
  • Type: A
  • Name: flask
  • IPv4 address: the lab VPS public IPv4 address
  • Proxy status: DNS only for this direct-origin certificate test
  • TTL: Auto
Save the record. Check for conflicting records for the same hostname. An AAAA record must point to a working IPv6 origin; do not leave an incorrect IPv6 record in place.

DNS only makes the hostname resolve directly to the VPS. This guide tests Nginx and its certificate at the origin; Cloudflare proxy configuration is a separate step. Allow DNS propagation before requesting the certificate.

4. Enable external network mapping
Return to the project's Mapping section. Turn on External network mapping and confirm the panel's prompt. The panel should detect the running application port. In our lab it detected 3200 and showed Proxy routing is enabled: /.

   
The Python project's mapping routes website traffic through Nginx to the local application port.

The Firewall Status: Not configured entry for 3200 does not mean you must expose that port. The browser reaches Nginx on 80/443, and Nginx reaches Gunicorn on 127.0.0.1:3200.

Open http://your-hostname/ and check that it displays your Flask response. Our public HTTP check returned HTTP 200. If you see another website, check domain ownership and DNS. If you see 502, check the running process, its bind address and the mapping port.

5. Apply a Let's Encrypt certificate
In the project's management window, open SSL → Let's Encrypt. Choose File Verification, select the exact hostname and click Apply. File verification requires the certificate authority to reach the hostname on port 80.

   
Select only the hostname that resolves to this project before applying for its certificate.

Some panel versions display Not connected to the Domain Management Center and a Connect action. Review that integration before connecting your domain, then return to the certificate request. Wait for issuance to finish; a pending request is not an installed certificate.

In this lab, the SSL section changed to Current Certs — Deployed, listed flask.adminslab.com and showed an expiry date of 12 January 2027. We also validated the live certificate independently. Do not copy or share the private-key field from the certificate screen.

6. Verify HTTPS from outside the VPS
Open https://your-hostname/ in a browser. The page must display the expected application without a certificate warning. From a terminal, you can also test:
Code:
curl -i https://your-hostname/
Do not use curl -k for this check: it skips certificate validation and can hide a broken certificate.

   
The public HTTPS hostname serves the expected Flask lab response.

Our result: https://flask.adminslab.com/ returned HTTP 200 with AdminsForum Flask lab, and certificate validation passed. This confirms DNS, Nginx mapping, the running application and HTTPS worked together at the time of testing.

Troubleshooting
  • DNS points to the wrong server: correct the A record and any conflicting AAAA record, then allow caches to expire.
  • HTTP works but certificate verification fails: check port 80, redirects, proxy rules and whether the selected hostname is the one attached to this project. Read the issuance error rather than repeatedly submitting requests.
  • HTTPS shows another site's certificate: confirm this hostname has its own deployed certificate and is served by the expected Nginx project.
  • 502 Bad Gateway: verify localhost responds, then compare the Gunicorn port with the mapping port and inspect Project logs.
  • App stops after reboot: this guide does not verify Python reboot recovery. Test and document autostart separately before treating the deployment as production-ready.

Completion checklist
  • Domain is listed under the correct Python project.
  • DNS resolves to the intended VPS.
  • Local Gunicorn and public HTTP both return the expected content.
  • Mapping uses the application's local port.
  • SSL is deployed for the exact hostname.
  • Public HTTPS passes normal certificate validation and returns the expected app.

Related: Create a Python Virtual Environment · Run Flask with Gunicorn

Tested and illustrated by AdminsForum. Screenshots show our own lab; use your own domain and application values.
DEV 10-14-2026, 06:34 AM Read thread
aaPanel Websites & Web Servers Guides

Run a Flask App with Gunicorn in aaPanel

This guide creates a small Flask application and runs it under aaPanel using Gunicorn and a separate Python virtual environment. The test stops at a verified localhost response; domain mapping and HTTPS are separate steps.

Tested lab: Ubuntu 22.04.5 LTS, aaPanel Free 8.0.7, Python 3.10.12 in af_python_lab, Flask 3.1.3 and Gunicorn 26.2.0. Tested on 14 October 2026. For a new production project choose a currently maintained Python release compatible with the application; the version here records the existing lab system interpreter.

1. Prepare the environment
Follow Create a Python virtual environment in aaPanel. Our application interpreter is:
Code:
/www/server/pyporject_evn/af_python_lab/bin/python
Keep application dependencies separate from aaPanel's own pyenv. Verify the interpreter and pip before installing packages.

2. Create the application folder
Create a fresh folder /www/wwwroot/af-flask-lab and put app.py inside it:
Code:
from flask import Flask app = Flask(__name__) @app.get('/') def home():     return 'AdminsForum Flask lab'
This defines a Flask application object named app in a module named app. There are no credentials, database operations or file uploads in this demonstration.

Use www ownership for this new app folder so the selected run user can read it. The app environment also needs suitable ownership for package installation by the intended user. Apply permission changes only to the newly created application environment and folder, not aaPanel's own Python environment.

3. Install Flask and Gunicorn
As www, use the application's exact interpreter:
Code:
/www/server/pyporject_evn/af_python_lab/bin/python -m pip install --index-url https://pypi.org/simple flask gunicorn /www/server/pyporject_evn/af_python_lab/bin/python -m pip check
We installed from official PyPI and the dependency check returned No broken requirements found. For repeatable real deployments, preserve a reviewed dependency specification instead of always installing whatever version is newest.

Gunicorn is the WSGI server for this example. Do not publish a production Flask site using its development server or enable debug mode on a public deployment.

4. Add the Python project
Open Website → Python Project → Add Project. Set:
  • Project Name: af_flask_lab
  • Python Environment: af_python_lab
  • Startup Way: Command Startup
  • Project Path: /www/wwwroot/af-flask-lab
  • Startup Command: gunicorn --workers 1 --bind 127.0.0.1:3200 app:app
  • Startup User: www
  • Environment Variables: None for this non-secret sample
The folder field can update the project name automatically in this version; check the final identifier before confirming. We left the dependency-path field empty because the packages were already installed in the selected environment.

   
Create the Flask project with the isolated interpreter and localhost Gunicorn command.

The app:app argument means load the app object from app.py. The port must be available. One worker is enough for this tiny lab check, not a universal production sizing recommendation.

5. Wait for project initialization
Click Confirm and let initialization finish. Our panel performed additional environment setup before launching the process. A creation dialog completing does not guarantee that the app is already ready for requests.

Click the project name and inspect Project information. Confirm the interpreter, source folder, run user and startup command.

   
Final project settings retain af_python_lab, the www user and port 3200.

6. Read the startup log
Open Project logs. Our log showed Gunicorn starting, listening at http://127.0.0.1:3200 and booting its worker.

   
Actual Gunicorn startup output for the sample project.

If the log reports module not found, check the selected environment and working directory. If it reports address already in use, identify the existing listener before trying another launch. Read the complete error before reinstalling packages.

7. Verify the local response
Over SSH on the VPS:
Code:
curl -i http://127.0.0.1:3200/ ss -ltnp | grep ':3200' ps -eo user,pid,args | grep '[g]unicorn.*3200'
Our response was HTTP 200 with AdminsForum Flask lab. The Gunicorn master and worker ran as www using the selected environment. pip check passed after the panel setup, and the existing Node.js HTTPS website remained healthy.

8. Understand the boundary of this test
The app is listening only on localhost. It is not yet a public HTTPS website. Next, add the intended domain, configure web-server mapping to this port and deploy a certificate. Do not open port 3200 publicly just to bypass the mapping.

Startup-after-reboot is also a separate recovery test. The Startup checkbox for this Python sample remained off during the current test. A successful current response does not prove automatic reboot recovery.

Reference: Flask's Gunicorn deployment documentation.
DEV 10-14-2026, 06:23 AM Read thread
aaPanel Websites & Web Servers Guides

Fix Python venv and ensurepip Errors in aaPanel on Ubuntu

If aaPanel reports that Python virtual-environment creation returned non-zero exit status 1, the popup alone does not identify the cause. In our Ubuntu lab, the selected system Python lacked ensurepip support because its venv package was not installed. Installing the matching Ubuntu package fixed the creation failure.

   
The actual aaPanel virtual-environment creation failure in the lab.

Tested: Ubuntu 22.04.5 LTS, aaPanel Free 8.0.7, selected interpreter /usr/bin/python3.10. Tested on 14 October 2026. The package and paths below apply to this specific combination; do not assume every exit-status-1 error has the same cause.

1. Record the failed command
The popup showed that aaPanel attempted:
Code:
/usr/bin/python3.10 -m venv /www/server/pyporject_evn/af_python_lab
Record the interpreter and target directory. Do not delete a working environment to investigate an unrelated creation error.

2. Read the underlying error
Over SSH, repeat the creation command only for the newly failed lab target, or choose a fresh unused diagnostic directory. In our test, the error explained that ensurepip was not available and recommended python3.10-venv.

Use the exact selected interpreter. Running a different python command could test another Python installation and hide the problem.

3. Check the matching package
On our Ubuntu server:
Code:
apt-cache policy python3.10-venv
It showed Installed: (none), with a candidate available from Ubuntu's repository. Confirm the selected Python version and repository source before installing a package. Other distributions and vendor-managed interpreters have different prerequisite workflows.

4. Install venv support
As an administrator:
Code:
sudo apt-get install python3.10-venv
Our package manager installed python3.10-venv and its pip/setuptools wheel prerequisites. No unrelated packages were removed. Keep package-manager errors if installation fails; do not continue as if the prerequisite is ready.

5. Retry the aaPanel form
Return to Website → Python Project → Python Environment. Dismiss the error popup, then retry the new environment's creation form. We used the same selected system interpreter and environment name. It succeeded and appeared in the environment list.

A failed attempt may leave a partial directory. In our lab the retry completed it successfully. Do not recursively delete a directory unless you have verified that it belongs only to the failed disposable attempt and no project uses it.

6. Verify the result
Code:
/www/server/pyporject_evn/af_python_lab/bin/python --version /www/server/pyporject_evn/af_python_lab/bin/python -m pip --version /www/server/pyporject_evn/af_python_lab/bin/python -c 'import sys; print(sys.prefix != sys.base_prefix)'
The lab returned Python 3.10.12, pip 22.0.2 inside the new environment and True for the isolation check. Substitute the actual interpreter path from your environment.

If the error continues
Check available disk space, parent-directory permissions, the selected interpreter and the complete command error. Missing ensurepip was our verified cause, not a universal diagnosis. Avoid changing aaPanel's own environment or reinstalling the whole panel before identifying the failure.

Related guide: Create a Python virtual environment in aaPanel.
DEV 10-14-2026, 06:17 AM Read thread
aaPanel Websites & Web Servers Guides

Create a Python Virtual Environment in aaPanel

Create a separate virtual environment for a Python application so its packages do not get mixed into aaPanel's own environment. This walkthrough uses aaPanel's Python Environment controls and verifies the resulting interpreter and pip over SSH.

Tested lab: Ubuntu 22.04.5 LTS, aaPanel Free 8.0.7, system Python 3.10.12, environment af_python_lab. Tested on 14 October 2026. This records the system interpreter already present in our lab; for a new production application choose a currently maintained Python release compatible with the app and your operating-system support policy.

1. Open Python Environment
Go to Website → Python Project → Python Environment. The environment list can include the operating system's interpreter and aaPanel's own environment. Identify which is which before installing packages or changing anything.

We used the system interpreter as the source and created a new environment. We did not install application packages into aaPanel's own pyenv.

2. Create the environment
Click Create virtual environment. Enter a unique name such as af_python_lab, select the intended source interpreter and add a useful remark. In this version, clicking the source's table row selects its radio control.

   
Create virtual environment: name, source interpreter and tutorial remark.

Click Confirm and wait for completion. Do not assume an environment is ready merely because a directory was created.

3. Handle missing venv support if necessary
Our first attempt failed. A direct check showed that the system interpreter lacked ensurepip support because Ubuntu's python3.10-venv package was absent. We installed the package from Ubuntu's repository and retried the same creation form. It then succeeded.

For this specific Ubuntu/Python combination, the prerequisite command was:
Code:
sudo apt-get install python3.10-venv
Other interpreter versions require their corresponding package or installation method. Do not use this package name blindly on another distribution. The separate troubleshooting guide covers diagnosis of this error in more detail.

4. Confirm the new list entry
The list should show your new environment as virtual env, with the expected Python version and remark. In our test af_python_lab appeared alongside the original system and panel environments.

   
The new environment is listed separately from the panel and system environments.

It was not assigned to a project yet, so Using project showed a dash. Creating an environment alone does not deploy a website, map a domain or enable HTTPS.

5. Verify Python and pip
Find the environment's actual interpreter path. Our panel used the directory below, including its spelling:
Code:
/www/server/pyporject_evn/af_python_lab/bin/python
Use the path shown on your own server rather than assuming every aaPanel version uses this location.

Run:
Code:
/www/server/pyporject_evn/af_python_lab/bin/python --version /www/server/pyporject_evn/af_python_lab/bin/python -m pip --version
Our outputs identified Python 3.10.12 and pip 22.0.2 inside this environment. Using python -m pip ties the package installer to that interpreter rather than whichever pip command happens to be on PATH.

6. Verify isolation
Code:
/www/server/pyporject_evn/af_python_lab/bin/python -c 'import sys; print(sys.prefix); print(sys.base_prefix); print(sys.prefix != sys.base_prefix)'
The lab returned the environment directory, /usr as the base prefix and True. The differing prefixes confirm this interpreter is running in a virtual environment.

You can invoke the interpreter by its absolute path without activating an interactive shell. Activation is a convenience for that shell, not proof that a separately started aaPanel project uses the same interpreter.

7. Prepare for application deployment
Keep the app's source directory separate from the interpreter environment. Install its required packages into the intended application environment, then choose that environment when adding the Python project. Check the run user, start command and listening port before mapping a domain.

Do not remove an environment while a project uses it. When migrating, retain the source and dependency specification and recreate the environment deliberately instead of assuming that moving the environment folder is sufficient.

Result: aaPanel created the isolated environment after the missing Ubuntu prerequisite was installed. The environment's Python, pip and prefix-isolation checks passed. No Python website has been published by these steps alone.

Reference: Python virtual environment documentation.
DEV 10-14-2026, 06:15 AM Read thread
aaPanel Websites & Web Servers Guides

Use .env Files for Node.js Apps on an aaPanel Server

A .env file holds application configuration, but merely creating the file does not guarantee Node.js will read it. This guide explicitly loads a .env file with Node.js 24 and verifies the result using a small localhost-only app on an aaPanel server.

   
Environment-file workflow based on the isolated lab test.

Tested: Ubuntu 22.04.5 LTS, aaPanel Free 8.0.7 and Node.js 24.21.0 on 14 October 2026. The sample ran as www in /www/af-node-env-lab and listened on 127.0.0.1:3104. We tested the SSH startup command below; we did not change the live aaPanel project's start command.

1. Separate configuration from application code
Configuration can include a port, a display label or connection settings. This example uses only non-secret values. Do not place real credentials into tutorial screenshots, public repositories or responses returned to visitors.

Create a new practice directory as an administrator:
Code:
sudo mkdir /www/af-node-env-lab sudo chown www:www /www/af-node-env-lab
Choose a directory that does not already contain an application. This sample is outside the live website's document root.

2. Create the environment file
Create /www/af-node-env-lab/.env with:
Code:
APP_LABEL=AdminsForum environment lab PORT=3104
A leading dot can make the file less obvious in file listings; it does not make it encrypted or safe to expose over HTTP. If using a file manager, enable its hidden-file view when needed.

Restrict access to the intended owner:
Code:
sudo chown www:www /www/af-node-env-lab/.env sudo chmod 600 /www/af-node-env-lab/.env
Mode 600 allows the owner to read and write. It is not isolation between applications that all run as www. Use suitable account isolation and secret management for real deployments.

3. Create a sample application
Create /www/af-node-env-lab/server.js with:
Code:
const http = require('node:http'); const port = Number(process.env.PORT); const label = process.env.APP_LABEL; if (!port || !label) {   throw new Error('Missing configuration'); } http.createServer((req, res) => {   res.writeHead(200, { 'Content-Type': 'text/plain' });   res.end(label); }).listen(port, '127.0.0.1');
Set its owner to www and allow that user to read it. The app reads configuration from process.env. It exposes only the harmless sample label, not the whole environment. This demonstration validates presence of the two sample values; a real application should validate its complete configuration, including allowed port ranges.

4. Load the file explicitly
Use the installed Node.js binary and an absolute path:
Code:
sudo runuser -u www -- /www/server/nodejs/v24.21.0/bin/node --env-file=/www/af-node-env-lab/.env /www/af-node-env-lab/server.js
Keep this foreground process running while testing from a second SSH session. Replace the runtime path with your installed version. This command uses Node's built-in environment-file support; no dotenv package is required for this tested Node.js 24 example.

The --env-file option must be passed to Node before the application filename. Using an absolute file path avoids confusion about the working directory. Check your runtime's documentation before using this option with an older release.

5. Verify the result without displaying secrets
From another SSH session:
Code:
curl -i http://127.0.0.1:3104/
Expect HTTP 200 and:
Code:
AdminsForum environment lab
Our test returned exactly that label. We also checked the file's permissions were 600 and confirmed that the existing HTTPS website still returned 200. Stop the foreground test with Ctrl+C when finished. Our temporary process was stopped after verification.

Do not verify real credentials by printing process.env or returning secret values from a web endpoint. For a required secret, check its presence or test the intended service connection without exposing its value.

6. Connect this to your aaPanel deployment
For a managed application, the configured start command must load the intended environment file every time the process starts. An export in your interactive SSH shell is not proof that a separately started panel process receives the same environment.

Review the app's package.json start script or custom startup command and its expected working directory. Preserve the selected runtime, run user and port. Test in a separate project before changing a live start command, then verify application restart and reboot recovery. This guide proves the environment-loading command; panel-managed persistence for this practice app was not configured here.

7. Troubleshoot missing values
  • Missing configuration: Check that the startup command includes --env-file and that variable names match the code.
  • File not found: Check the absolute path and hidden filename.
  • Permission denied: Check the file owner, mode and parent-directory access for the run user.
  • Unsupported option: Confirm which Node binary is running and whether it supports --env-file.
  • Port conflict: Check for an existing listener before launching another copy.
After changing a .env file, restart the relevant process and verify its behaviour; a running app should not be assumed to reload the file automatically.

Related guides: Node.js deployment with domain and HTTPS and startup after reboot.
Reference: Node.js command-line environment-file documentation.
DEV 10-14-2026, 03:23 AM Read thread
aaPanel Websites & Web Servers Guides

Install npm Packages for a Node.js App on aaPanel

Installing a Node.js runtime is only the first step. An application may also need packages from npm. This guide installs Express in a separate lab folder on an aaPanel server, fixes a writable-cache problem and verifies a clean lockfile-based installation.

   
npm dependency workflow based on the isolated lab test.

Tested: Ubuntu 22.04.5 LTS, aaPanel Free 8.0.7, Node.js 24.21.0, npm 11.19.0 and Express 5.3.0 on 14 October 2026. Commands ran as www in /www/af-npm-lab. This is an SSH workflow, not a demonstration of aaPanel's Module button. The live website was not modified.

1. Confirm the intended Node.js runtime
Install Node.js first using the aaPanel runtime guide. Check the Node version supported by your application and dependencies. Use the same intended runtime for package installation and app execution.

Our runtime is under /www/server/nodejs/v24.21.0/bin. Replace that path if your installed version differs. A shell's node command can point to a different runtime from the one selected for an aaPanel project.

2. Create a separate practice directory
As an administrator over SSH, choose a directory that does not already contain an application:
Code:
sudo mkdir /www/af-npm-lab sudo chown www:www /www/af-npm-lab sudo runuser -u www -- bash
The final command opens a shell as www. The remaining npm commands below belong in that shell. Do not initialise a new package.json over a real application's existing manifest. For an existing project, use its supplied manifest, lockfile and installation instructions.

3. Set the runtime and a writable npm cache
Code:
export PATH=/www/server/nodejs/v24.21.0/bin:$PATH export npm_config_cache=/www/af-npm-lab/.npm-cache cd /www/af-npm-lab node --version npm --version
We verified v24.21.0 and 11.19.0. These exports affect the current shell; they are not a permanent change to aaPanel's project configuration.

Our first attempt encountered a shared npm cache at /www/server/nodejs/cache that www could not write to. A separate writable cache fixed the problem without running npm as root or making shared directories writable to everyone. For real deployments, choose a protected cache location outside publicly served files and ensure the intended run user owns it.

4. Initialise only the new sample project
Code:
npm init -y
This creates package.json for the practice folder. Review the result. Its default test script is a placeholder, not a passing application test.

5. Install the example dependency
Code:
npm install express --ignore-scripts --registry=https://registry.npmjs.org npm ls express
The test used the official npm registry. Express installed as version 5.3.0, and npm ls showed it as a dependency of af-npm-lab. The command also produced package-lock.json and populated node_modules.

We used --ignore-scripts for this controlled example. Some real packages require installation scripts or build steps; disabling those can leave them unusable. Follow the application's documented requirements rather than applying this flag indiscriminately.

6. Understand the files
  • package.json: Declares the project and its dependency requirements.
  • package-lock.json: Records npm's resolved dependency tree for this project.
  • node_modules: Contains installed packages; its presence alone does not prove a working app.
  • .npm-cache: Our chosen local download cache, not application source.
Preserve the manifest and lockfile in your source and recovery process. Do not mix package managers casually: a project built around a Yarn or pnpm lockfile needs its corresponding workflow.

7. Verify a clean installation from the lockfile
Only run the following in the isolated practice folder:
Code:
sha256sum package-lock.json npm ci --ignore-scripts --registry=https://registry.npmjs.org sha256sum package-lock.json npm ls express
The two lockfile checksums matched in our test, and Express remained installed. npm ci requires an existing matching lockfile, installs the whole project and replaces an existing node_modules directory. It is therefore not a harmless diagnostic command to run inside a serving production release.

If the manifest and lockfile disagree, npm ci reports an error rather than silently updating the lockfile. Resolve that mismatch in a controlled development or build workflow; do not delete the lockfile merely to hide the problem.

8. Check that Node can load the package
From the practice directory:
Code:
node -e 'const express=require("express"); const app=express(); console.log(typeof app.get === "function" ? "EXPRESS_LOAD_PASS" : "FAIL")'
Our output was EXPRESS_LOAD_PASS. This confirms that Node can import Express and create an application object. It does not start a web service or prove an entire application, database or domain works.

npm's audit output reported zero known vulnerabilities during this test. That result is time-dependent and is not a guarantee that a package or application is secure. The lab also displayed a warning about an unknown global --init.module configuration; it did not prevent these checks from passing.

9. Common installation errors
  • EACCES or cache write failure: Check directory ownership and use a writable cache for the intended user. Avoid permissions 777 or a root install as shortcuts.
  • npm ci needs a lockfile: Check you are in the right directory and have the project's npm lockfile.
  • Module not found: Check the working directory, installed dependency and runtime used to start the app.
  • Unsupported engine: Compare package requirements with the selected Node version.
  • Registry or certificate error: Check connectivity and registry settings; do not bypass TLS validation to force a download.

10. Return to aaPanel deployment
Type exit to leave the www practice shell. For a real application, prepare dependencies and any required build in a separate release directory, then configure the correct runtime and start command in aaPanel. Restart the intended project and verify its expected response. See Deploy a Node.js app with a domain and HTTPS.

Lab result: Express loaded successfully; npm ci passed; the lockfile checksum stayed unchanged. The isolated practice directory is retained. No public application or production dependency update was performed.

References: npm ci documentation and Express installation documentation.
DEV 10-14-2026, 03:13 AM Read thread