PART 1: Create the Application on cPanel.
-
Request for Jailed SSH access
-
Upload through file manager on your cPanel or FTP into public_html
-
On your cPanel dashboard, click on Setup Python App and click on Create Application
-
Set the python version to the one compatible with the application you want to host.
-
Set the application root to the location of your application NOTE: Your files cannot be directly under public_html, so it should be in a subfolder e.g /home/user/public_html/myappfiles
-
Set the application URL you wish to use. In this example, we will leave the application URL as testingpythons.wghdemo.com.ng
-
Set the application startup file to the location of your wsgi.py file
-
Set the entry point to the name of your application as declared in the wsgi.py file.
-
Finally set the passenger log file to the location where you want error logs to be saved
-
Click on Create.
PART 2: Install requirements, dependencies, and configure your application. (From cPanel) After the application is created, it displays more details about the created application. If it doesn't for you, click on the edit icon
-
Input the full path to your requirement.txt file in the CONFIGURATION FILES option and click on the add button.
-
After the required file or files depending on your application is added, click on the RUN PIP INSTALL button and select the file you added to install requirements and dependencies for the application.
-
After requirements have been installed successfully, you can then go ahead to run any other scripts as directed by the application developer using the EXECUTE PYTHON SCRIPT option. Example of such scripts include manage.py migrate manage.py runscript many_load ….. Etc
NOTE: manage.py runserver will not work on cPanel because cPanel handles that part for you already.
-
Restart the application and access via the application URL
NOTE: Please ensure you add your application URL in allowed host in your application settings, you will not need to do so if you have ALLOWED_HOSTS = [ '*' ] in your settings file. PART 2: Install requirements, dependencies, and configure your application. (From ssh) After the application is created, login to your Cpanel account via SSH
-
From the details of the created application, copy the command to enter into the virtual environment. E.g source /home/pythonswg/virtualenv/public_html/dj4e-samples/3.6/bin/activate && cd /home/pythonswg/public_html/dj4e-samples
-
Run the command below to install requirements from your requirements.txt file pip install -r /path/to/requrement.txt
-
After requirements have been installed successfully, you can then go ahead to run any other scripts as directed by the application developer. Example of such scripts include python manage.py migrate python manage.py runscript many_load ….. Etc
NOTE: manage.py runserver will not work on cPanel because cPanel handles that part for you already.
-
After running all required scripts, go back to cPanel and restart the application.
NOTE: Please ensure you add your application URL in the allowed host in your application settings, you will not need to do so if you have ALLOWED_HOSTS = [ '*' ] in your settings file.