- sudo apt update
- sudo apt install vim
- sudo apt install build-essential
This command will install G++, GCC, make, and other core development libraries.
- gcc/g++ 15.2.0
g++-15 -std=c++20 hello.cpp -o hello
- perl 5, version 40, subversion 1 (v5.40.1)
- sudo apt install default-jdk
This installs Java.
- javac --version : javac 21.0.10
- java --version : openjdk version "21.0.10" 2026-01-20
- sudo apt install php
This installs PHP.
- PHP 8.4.11 (cli) (built: Jan 7 2026 08:44:00) (NTS)
- sudo apt install apache2
apache2 is already the newest version (2.4.64-1ubuntu3.2)
- sudo systemctl status apache2
- server is running
- conf: /etc/apache2/
- /var/www/html/
- Python is pre-installed on all modern Ubuntu:
- Python 3.13.7
- sudo apt install python3-pip
This installs pip (Python package manager)
- pip 25.1.1 from /usr/lib/python3/dist-packages/pip (python 3.13)
- sudo apt install python3-venv
sudo apt install python3.14-venv
Install venv (virtual environment module): This is crucial for creating isolated environments
for your projects to manage dependencies without affecting the system Python.
- You also need to install for each python version
- sudo apt install software-properties-common
This installs the add-apt-repository command in Ubuntu.
- type add-apt-repository
add-apt-repository is /usr/bin/add-apt-repository
- You can now use the command to add a new repository, for example, a Personal Package Archive (PPA):
sudo add-apt-repository ppa:some/ppa-name
- sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
- This adds the deadsnakes PPA.
- sudo apt install python3.14
- Installs Python 3.14
- python3.14 --version
3.14.0
- python3 --version
3.13.7
- make Python an alias of python3.14:
- vi ~/.bash_aliases
- add: alias python=python3.14
- source ~/.bash_aliases
- mkdir wschat
cd wschat
python -m venv .myenv
source .myenv/bin/activate
- pip install autobahn[twisted]
deactivate
Monday, February 16, 2026
Ubuntu installation log
Daemonize a process in python virtual environment
The most robust way to daemonize a Python process in a virtual environment on Ubuntu is by
using a systemd service unit file that explicitly points to the virtual environment's Python interpreter. This approach ensures proper isolation and reliable service management by the operating system. Prerequisites
- A Python script you want to run as a daemon (e.g.,
main.py). - A created virtual environment (e.g., in a
.venvdirectory).
Steps
- For security, create a dedicated system user:
sudo useradd --system --no-create-home --shell /usr/sbin/nologin appuser. Then, set ownership for your application directory:sudo chown -R appuser:appuser /path/to/your/app. - Create a systemd service file (e.g.,
mydaemon.service) in/etc/systemd/system/:sudo nano /etc/systemd/system/mydaemon.service. - Configure the service, ensuring the
ExecStartline points to the Python interpreter within your virtual environment and the script:Replaceini[Unit] Description=My Python Daemon Service After=network.target [Service] Type=simple User=appuser Group=appuser WorkingDirectory=/path/to/your/app ExecStart=/path/to/your/app/.venv/bin/python /path/to/your/app/main.py Restart=always RestartSec=10 Environment=PYTHONUNBUFFERED=1/path/to/your/appwith your project's absolute path.Type=simplemeans systemd handles daemonization for your foreground script, andEnvironment=PYTHONUNBUFFERED=1ensures immediate log writing. - Reload systemd:
sudo systemctl daemon-reload. - Enable and start the service:
sudo systemctl enable mydaemon.serviceandsudo systemctl start mydaemon.service. - Check the status and logs:
sudo systemctl status mydaemon.serviceandjournalctl -xeu mydaemon.service.
Alternative Python Package
The
python-daemon package offers a Python-only approach for creating daemons, though systemd is generally preferred on modern Linux systems. You can install it in your virtual environment and use its DaemonContext in your script. You can find more details in the referenced documents. Install Python on Ubuntu
Python 3 is
pre-installed on all modern Ubuntu versions. You should not remove or change the system's default Python version as it can break core system tools. For most use cases, you just need to install additional modules like pip and venv or a specific Python version alongside the system's default. Using the Pre-installed Python 3
Open your terminal (Ctrl + Alt + T) and follow these steps:
- Update package lists:bash
sudo apt update - Verify Python 3 is installed:This command will display the installed version (e.g.,bash
python3 --versionPython 3.12.xon Ubuntu 24.04). - Install
pip(Python package manager): This allows you to install other Python packages from the Python Package Index (PyPI).bashsudo apt install python3-pip - Install
venv(virtual environment module): This is crucial for creating isolated environments for your projects to manage dependencies without affecting the system Python.bashsudo apt install python3-venv - Create and activate a virtual environment:
- Create an environment in your project directory:bash
python3 -m venv my_project_env - Activate the environment:bash
source my_project_env/bin/activate
pythonandpipcommands within this environment (instead ofpython3andpip3). - Create an environment in your project directory:
Installing a Specific or Newer Python Version
If you need a different version not available in the default repositories, the recommended way is to use the
deadsnakes PPA (Personal Package Archive). - Add the
deadsnakesPPA:bashsudo add-apt-repository ppa:deadsnakes/ppa sudo apt update - Install the desired version (e.g., Python 3.14):bash
sudo apt install python3.14 - Verify the installation:bash
python3.14 --version
This version is installed alongside the system Python and can be accessed with its specific command (
python3.14). Always use virtual environments when working with these separate installations. Alma Linux, debian, centos or ubuntu
Choosing
between AlmaLinux, Debian, CentOS, and Ubuntu depends on whether you
prioritize enterprise stability (AlmaLinux/CentOS), extreme reliability
(Debian), or modern, beginner-friendly, and well-supported ecosystems
(Ubuntu). AlmaLinux is the preferred, free successor to CentOS for
cPanel/RHEL compatibility
. Ubuntu is best for cloud, developers, and ease of use, while Debian is ideal for rock-solid, low-resource server stability. Here is a breakdown of the four options:
Ubuntu:
Best for beginners, cloud, and DevOps. It has the largest repository of
software, frequent updates, and excellent documentation.
AlmaLinux:
The top choice for replacing CentOS. It is an enterprise-grade,
RHEL-compatible OS, perfect for long-term stability and web hosting
(e.g., cPanel).
Debian:
Known for extreme stability, making it ideal for production servers
that require minimal changes. It is highly reliable but has a steeper
learning curve and older software packages.
CentOS:
Historically, the standard for servers; however, with CentOS Linux 7/8
reaching end-of-life, most users are transitioning to AlmaLinux or Rocky
Linux.
Key Decision Factors
- For Ease of Use/Cloud: Ubuntu.
- For Enterprise/RHEL/cPanel: AlmaLinux.
- For Maximum Stability: Debian.
- For Older Hardware: Debian.
Note:
CentOS Stream is the only active official CentOS version, which acts as
an upstream for RHEL and is generally less suitable for stable
production environments than AlmaLinux.
Sunday, December 7, 2025
Display CJK fonts in matplotlib
Error: Glyph 21518 (\N{CJK UNIFIED IDEOGRAPH-540E}) missing from font(s) DejaVu Sans
使用matplotlib绘图中文字符显示问题:UserWarning: missing from current font
Code added:
from pylab import mpl
mpl.rcParams["font.sans-serif"] = ["SimSong"]
# all_rcParams_keys = mpl.rcParams.keys()
# You can then iterate through them or convert to a list
# for key in all_rcParams_keys:
# print(key)
Thursday, April 25, 2019
Android development on Mac
SDK for Mac: https://developer.android.com/studio
Installation guide: https://www.talkandroid.com/guides/developer/android-sdk-install-guide/
See more discussion at:
https://stackoverflow.com/questions/2672100/can-i-develop-android-applications-on-macos
Build the first App:
https://www.iosinsight.com/develop-android-apps-on-mac/
Installation guide: https://www.talkandroid.com/guides/developer/android-sdk-install-guide/
See more discussion at:
https://stackoverflow.com/questions/2672100/can-i-develop-android-applications-on-macos
Build the first App:
https://www.iosinsight.com/develop-android-apps-on-mac/
Wednesday, May 2, 2018
Subscribe to:
Posts (Atom)
Blog Archive
-
▼
2026
(36)
-
▼
June
(19)
- C10K to C10M: from thread-per-connection model to ...
- Benchmark server performance
- Application server for php, python, java, node.js,...
- Application server for C++, Go and Rust
- Nginx as reverse proxy and load balancer
- Infrastructure running: nginx, apache, php, python...
- Flow chart of nginx+apache+uvcorn infrastructure
- Flow chart of apache+uvcorn infrastructure
- Uvicorn and Gunicorn
- What's deadsnakes PPA
- What's the optional lsb-core package
- Codex known logging bug
- Daemonsize a service
- Train text to image model, to generate images of c...
- Train a model based on OpenAI API
- Open port 8080 for WebSocket
- Add websocket support on Bluehost Ubuntu VPS for D...
- Install Claude Code on ubuntu VPS of Bluehost
- Install PostgreSQL on Mac
-
▼
June
(19)