The Python Selector in CloudLinux simplifies hosting Python applications by allowing users to manage multiple Python versions within isolated environments. In this walkthrough you will learn installing, configuring, and optimizing the Python Selector on a CloudLinux server integrated with cPanel.
Why Should We Use Python Selector?
Key Benefits
- Version Flexibility: Switch between Python versions easily for different applications.
- Environment Isolation: CageFS to secure applications without conflicts and unauthorized access.
- Ease of Management: A nice and intuitive interface for deploying and managing Python applications.
- Increased Security: It protects applications by isolating environments and robust server security features.
How to Prepare Your Server
Step 1: Verify Requirements
Obviously, before starting the installation process of your server, check if the server meets such requirements. The first is that we need root access to do administrative actions. There is already preinstalled software(CPanel and Cloudlinux) that has to be working, and CageFS enabled. Lastly, make sure that there are no compatibility issues and be sure that your system packages are up to date.
Step 2: Update the Server
Run the following commands to update the system packages:
sudo dnf update -y
sudo dnf upgrade -y
This command ensures your server has the latest updates and is ready for installation.
How to Install Python Selector
Install CloudLinux Components
Install the necessary Python tools provided by CloudLinux:
yum groupinstall alt-python -y
This command installs multiple Python versions and prepares the system for integration with CageFS.
How to Verify the Installation?
Log in to cPanel as a user to confirm Python Selector’s availability. Navigate to the Software section and check for the “Setup Python App” option.
If visible, Python Selector is correctly installed, allowing users to manage Python applications directly from their cPanel interface.
Once the “Setup Python App” option appears under the Software section in cPanel, it confirms the successful installation of Python Selector. Users can now choose from many Python versions to deploy their applications seamlessly.
cPanel provides this interface that simplifies application management: specify environment variables, application directories, and more via cPanel.
How to Use the Python Selector
Step 1: Create a Python Application
- Log in to cPanel.
- For this, you can log in to your cPanel account and go to the Software section, where you will find a list of the tools available there and also will be able to manage Python Applications. Click on Setup Python App within this section. It provides a way to create, configure, and manage your Python applications. It also gives the tools to set versions of Python and environment variables.
- After navigating to the Setup Python App, click on (Create Application) to create a new one. This action allows you to configure your app by setting its environment, directory, and version. It initiates the application setup and provides customized options based on your requirements.
- Choose the Python version best suited for your application from the available options. This process ensures compatibility and optimal performance for your application. The selected version will give your app a given runtime environment; it’ll be flexible to meet your app’s development or deployment needs.
- Define the directory where the application will reside, such as /home/user/app. The root directory of your Python application consists of one critical file and some configurations. Permission to run an application or easy-to-set-up virtual environment for this directory path must be correct.
Step 2: Manage Existing Applications
Once created, manage your application by:
- Starting or Stopping the Application:
You can control the application by clicking Start, Stop, or Restart in the cPanel interface. These actions ensure that the application runs efficiently or is paused as needed for updates or maintenance.
- Modifying Environment Variables:
Adjust critical framework variables like DJANGO_SETTINGS_MODULE or FLASK_APP directly in cPanel. Add or update these variables to configure the application’s environment for optimized performance or feature updates.
- Updating the Python Version:
If you want to update your application’s Python version, find the Python version dropdown menu within the cPanel interface. Choose the version of your choice, for example, the latest recommended (for example, 3.10.15). It is updated so that your application keeps getting the latest features, performance, and security updates.
How to Optimize and Maintain Python Selector
- Regular Updates
- Update server packages:
sudo dnf update -y
- Update Python Selector components:
yum groupupdate alt-python -y
- Secure Environments
Use CageFS to prevent unauthorized access to application files and isolate resources between users.
Conclusion
Built on Cloud Linux and integrated with cPanel, Python Selector provides a powerful, flexible solution to control your Python applications. You can install and configure the Python Selector for a smooth as possible deployment and management. It will provide a secure and optimized hosting environment for Python development where we will similarly keep giving regular updates and proactive monitoring.
About the writer
Vinayak Baranwal wrote this article. Use the provided link to connect with Vinayak on LinkedIn for more insightful content or collaboration opportunities.