{"id":541,"date":"2026-01-22T19:04:05","date_gmt":"2026-01-22T19:04:05","guid":{"rendered":"https:\/\/ecodebook.wordpress.com\/?p=541"},"modified":"2026-02-15T10:14:30","modified_gmt":"2026-02-15T10:14:30","slug":"how-to-setup-django-app-on-cloud-panel","status":"publish","type":"post","link":"https:\/\/blog.mycarts.shop\/?p=541","title":{"rendered":"How to setup Django app on Cloud Panel"},"content":{"rendered":"\n<p>Run the following commands<\/p>\n\n\n\n<pre class=\"wp-block-code is-style-solarized-dark\"><code>\nmypyapp@CloudPanel$ cd htdocs\nmypyapp@CloudPanel:~\/htdocs$ python3 -m venv venv\nmypyapp@CloudPanel:~\/htdocs$ source venv\/bin\/activate\nmypyapp@CloudPanel:~\/htdocs$ pip install django\nmypyapp@CloudPanel:~\/htdosc$ django-admin --version\nmypyapp@CloudPanel:~\/htdocs$ pip install pymysql\nmypyapp@CloudPanel:~\/htdocs$ cd mypyapp.cc\nmypyapp@CloudPanel:~\/htdocs\/mypyapp.cc$ django-admin startproject myapp\nmypyapp@CloudPanel:~\/htdocs\/mypyapp.cc$ cd myapp\nmypyapp@CloudPanel:~\/htdocs\/mypyapp.cc$ python3 manage.py migrate\nmypyapp@CloudPanel:~\/htdocs\/mypyapp.cc$ python3 manage.py runserver\n\n#mypyapp@CloudPanel$ sudo apt-get install python3-dev default-libmysqlclient-dev build-essential pkg-config\n#mypyapp@CloudPanel$ pip install mysqlclient\n<\/code><\/pre>\n\n\n\n<p>Directory Structure<\/p>\n\n\n\n<pre class=\"wp-block-code is-style-solarized-dark\"><code>  htdocs\n\tmypyapp.cc\n\t  myapp\n\t    myapp\n\t  venv\n\t  static<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/blog.mycarts.shop\/wp-content\/uploads\/2026\/01\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"214\" height=\"177\" src=\"https:\/\/blog.mycarts.shop\/wp-content\/uploads\/2026\/01\/image-3.png?w=214\" alt=\"\" class=\"wp-image-571\" style=\"width:164px;height:auto\"\/><\/a><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>Create a new file as a root: \/etc\/uwsgi\/apps-enabled\/mypyapp.cc.uwsgi.ini<\/p>\n\n\n\n<p>Then add the below content to the file mypyapp.cc.uwsgi.ini<\/p>\n\n\n\n<pre class=\"wp-block-code is-style-solarized-dark\"><code>&#91;uwsgi]\n\nplugins       = python3\nmaster        = true\nprotocol      = uwsgi\n# Django-related settings\n# the base directory (full path)\nchdir           = \/home\/mypyapp\/htdocs\/mypyapp.cc\/myapp\/\n# Django's wsgi file\nmodule          = myapp.wsgi\n# the virtualenv (full path)\nhome            = \/home\/mypyapp\/htdocs\/mypyapp.cc\/venv\n\n# process-related settings\n# master\nmaster          = true\n# maximum number of worker processes\nprocesses       = 10\n# the socket (use the full path to be safe\nsocket          = 127.0.0.1:8090\n# ... with appropriate permissions - may be needed\n# chmod-socket    = 664\n# clear environment on exit\nvacuum          = true\nuid = mypyapp\ngid = mypyapp\n<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Run uWsgi to debug:<\/p>\n\n\n\n<pre class=\"wp-block-code is-style-solarized-dark\"><code>mypyapp@CloudPanel$ cd \/etc\/uwsgi\/apps-enabled\/\nmypyapp@CloudPanel$ uwsgi --ini mysite_uwsgi.ini<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Start the uWsgi service<\/p>\n\n\n\n<pre class=\"wp-block-code is-style-solarized-dark\"><code>mypyapp@CloudPanel$ systemctl start uwsgi<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Update the vhost file as below<\/p>\n\n\n\n<pre class=\"wp-block-code is-style-solarized-dark\"><code>location \/ {\n    include proxy_params;\n    proxy_pass http:\/\/127.0.0.1:8090;\n}<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>Add static files location in the Nginx config file<\/p>\n\n\n\n<pre class=\"wp-block-code is-style-solarized-dark\"><code>location \/static {\n    alias \/home\/mypyapp\/htdocs\/mypyapp.cc\/myapp\/myapp\/static; # your Django project's static files - amend as required\n}\n  <\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><a href=\"https:\/\/webdevsite.github.io\/ratetrack\/mysqlclient-2.2.7.dist-info.zip\" target=\"_blank\" rel=\"noreferrer noopener\">mysqlclient-2.2.7.dist-info<\/a><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Run the following commands Directory Structure Create a new file as a root: \/etc\/uwsgi\/apps-enabled\/mypyapp.cc.uwsgi.ini Then add the below content to the file mypyapp.cc.uwsgi.ini Run uWsgi to debug: Start the uWsgi service Update the vhost file as below Add static files location in the Nginx config file mysqlclient-2.2.7.dist-info<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[],"class_list":["post-541","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/blog.mycarts.shop\/index.php?rest_route=\/wp\/v2\/posts\/541","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.mycarts.shop\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mycarts.shop\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mycarts.shop\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mycarts.shop\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=541"}],"version-history":[{"count":2,"href":"https:\/\/blog.mycarts.shop\/index.php?rest_route=\/wp\/v2\/posts\/541\/revisions"}],"predecessor-version":[{"id":642,"href":"https:\/\/blog.mycarts.shop\/index.php?rest_route=\/wp\/v2\/posts\/541\/revisions\/642"}],"wp:attachment":[{"href":"https:\/\/blog.mycarts.shop\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=541"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mycarts.shop\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=541"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mycarts.shop\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=541"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}