john | May 16, 2020, 8:46 a.m.
When you make your server in DO you should have had the ability to enter your root password, if you used vultr, they will supply you one and it will be in your admin panel.
The first thing to do is to ssh into the server, Windows (use putty) and Mac users user Finder to search for terminal, and Ubuntu users type ctrl+alt+t
With the ssh client, open and type the following into it.
Of course you should use your own ip Address.
Once you log in to your server, the first thing you want to do is make another user that has `sudo privileges and disable root user login to make your server more secure.
So first we are going to do,
then once that is done, you do
adduser cooluser sudo
Ok now we have our
cooluser made so now we need to disable root login and log out, so next we type
sudo passwd -l root
Now you should be back in your local terminal, from there we now ssh in with our new user
Next we are going to make the directory and virtual environment, you will have to enter your sudo password which you made earlier when making your cool user.
sudo mkdir /home/www && cd /home/www
sudo mkdir django
python3 -m venv env
Once you have this activated you should see something along the lines of
Now that we have the virtualenv activated, we are going to install Django to the virtual environment by typing
pip install Django
This should install Django in your virtual environment. From here we set up Django by typing
django-admin startproject mysite
Awesome! We now are almost there to having a skeleton website up and running!
if you type in ls you should see folders and directories that are something like this, you can use the
cd command to go between them for example
cd mysite will move you to mysite directory and typing ls will show you whats in there. To go back one directory type
This is the layout of your basic website
mysite/ manage.py mysite/ __init__.py settings.py urls.py wsgi.py
This is the layout of your basic Django website. Now if we type
python manage.py runserver
We should see the following output, which lets us know the website is up and running.
Performing system checks... System check identified no issues (0 silenced). You have unapplied migrations; your app may not work properly until they are applied. Run 'python manage.py migrate' to apply them. January 08, 2020 - 15:50:53 Django version 2.0, using settings 'mysite.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
This lets us know that the server is up and running on port :8000. But that it also missing its migrations haven't been applied. We can worry about this later.
At this point we have successfully installed and set up a basic website on a server.
You can access it now, even though it's in development by going to youripaddress:8000
At this point, my job is done here.
From here I hand you off to the very capable hands of Django Project
There is a walkthrough on a little bit of python, to how to fully run and manage and make your Django project do anything you want. They also have Django project forums where you can ask questions, or see what other people have asked. And if not, always remember that you can ask in StackOverflow Django.
P.S. Like what you read? Show it to your friends.
Welcome to the world of Johnathan Nader. Here you will find writings of various things. I will try to stay on topic on some, and digress in others. If you want to know more about meClick here!