I'm uploading my first Django project to a Linux server, where I should put my project in the filesystem?
With a PHP, or ASP project, everything goes into /var/www
, would it be ok to do the same and add my Django project to the /var/www
folder?
Put your code in some directory outside of the document root, such as /home/mycode. Normally all folders in /home/ are users' home folders.
For hosting web applications built on Django, you will need to use a platform that lets you deploy the app. One of these platforms is Heroku. Heroku is a cloud platform on which users can build and deploy applications. Heroku relies on Git, a revision control system that lets you manage the program code of your app.
The best way to deploy is to get an ubuntu server, setup nginx and a WSGI app like gunicorn. Nginx will handle all of your static files for you. Using Let's Encrypt to get a free SSL cert is nice, too.
In the Django tutorial it states:
Where should this code live?
If your background is in PHP, you're probably used to putting code under the Web server's document root (in a place such as /var/www). With Django, you don't do that. It's not a good idea to put any of this Python code within your Web server's document root, because it risks the possibility that people may be able to view your code over the Web. That's not good for security.Put your code in some directory outside of the document root, such as /home/mycode.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With