Build a Django environment with Vagrant in 5 minutes

One way to develop a web application is to use a framework. There are various frameworks, but this time I will use Django which can be developed with Python. Also, I want to create a local environment for testing as a method of building a development environment, so I will create it using Vagrant.

Vagrant setup

Initialize and start Vagrant

This time we will use Ubuntu as the guest OS. Please install Vagrant in advance. I'm also using VirtualBox as the VM.

Also, "hashicorp / precision64" is used as the vagrant box. If it is not in the Vagrant box, add it to the Vagrant box with the following command.

$ vagrant box add hashicorp/precise64

When running Vagrant, it's a good idea to create a suitable folder and run it in it. Here, we create a folder called ~ / Vagrant / Django and run it there.

$ mkdir -p ~/Vagrant/Django
$ cd ~/Vagrant/Django
$ vagrant init hasjicorp/precise64

Change the settings of the created Vagrant file. Here we want to access Django on port 12345 on localhost (127.0.0.1). Open the Vagrantfile in a suitable editor.

$ vim Vagrantfile

Add the following content in the file.

config.vm.network "forwarded_port", guest: 8000, host: 12345

Start Vagrant under the set conditions.

$ vagrant up

Enter the booted VM.

$ vagrant ssh

Install and launch Django

Install Django on the booted VM.

First install pip. pip is a package management system for installing and managing packaged software written in Python. It makes it easy to install Django.

vagrant@precise64:~$ sudo apt-get install python-pip

Install Django with pip. Then use django-admin.py to create your project.

vagrant@precise64:~$ sudo pip install Django
vagrant@precise64:~$ sudo django-admin.py startproject spam

My grade of DB is done and the server is operated. Django is running on port 8000, but from the host side it will be accessed from 127.0.0.1:12345 set in Vagrant.

vagrant@precise64:~$ cd spam/
vagrant@precise64:~/spam$ sudo python manage.py migrate
vagrant@precise64:~/spam$ sudo python manage.py runserver 0.0.0.0:8000

You can see that Django is running by accessing the localhost (127.0.0.1:12345) preset in the Vagrant file after booting.

Welcome_to_Django_と_Welcome_to_Django.png

Recommended Posts

Build a Django environment with Vagrant in 5 minutes
Start Django in a virtual environment with Pipenv
[Python] Build a Django development environment with Docker
Build a Django development environment with Doker Toolbox
Quickly build a Python Django environment with IntelliJ
(Note) Django in Vagrant environment
Build a development environment with Poetry Django Docker Pycharm
Build a Django environment for Win10 (with virtual space)
Build a web application with Django
Try running python in a Django environment created with pipenv
Build a Django development environment with Docker! (Docker-compose / Django / postgreSQL / nginx)
Build Azure Pipelies with Azure DevOps in a Linux self-hosted environment
[Memo] Build a development environment for Django + Nuxt.js with Docker
[Django] Build a Django container (Docker) development environment quickly with PyCharm
How to build a python2.7 series development environment with Vagrant
Create a Todo app with Django ① Build an environment with Docker
Build a LAMP environment with Vagrant (Linux + Apache + MySQL + PHP)
Easily build a development environment with Laragon
Build a Tensorflow environment with Raspberry Pi [2020]
CSS environment created in 10 minutes using Django
Build a Fast API environment with docker-compose
[Linux] Build a jenkins environment with Docker
Build a python virtual environment with pyenv
Build a modern Python environment with Neovim
[Linux] Build a Docker environment with Amazon Linux 2
[DynamoDB] [Docker] Build a development environment for DynamoDB and Django with docker-compose
Build a LAMP environment in a very short time
Build a C language development environment with a container
Build a WardPress environment on AWS with pulumi
Build Django + NGINX + PostgreSQL development environment with Docker
Build the fastest Django development environment with docker-compose
Build a Django environment on Raspberry Pi (MySQL)
Build a python environment with ansible on centos6
Create a python3 build environment with Sublime Text3
[Can be done in 10 minutes] Create a local website quickly with Django
[Memo] Build a virtual environment with Pyenv + anaconda
Build a virtual environment with pyenv and venv
Work in a virtual environment with Python virtualenv.
Build a Python environment with OSX El capitan
Configure a module with multiple files in Django
Build a Minecraft plugin development environment in Eclipse
[Docker] Create a jupyterLab (python) environment in 3 minutes!
Build a Python machine learning environment with a container
Build a python execution environment with VS Code
Steps to build a Django environment with Win10 WSL Ubuntu18.04 + Anaconda + Apache2
Build a data analysis environment that links GitHub authentication and Django with JupyterHub
Build a Django development environment using pyenv-virtualenv on Mac
Build a python virtual environment with virtualenv and virtualenvwrapper
Build a python environment for each directory with pyenv-virtualenv
Create a python development environment with vagrant + ansible + fabric
How to build a Django (python) environment on docker
Build a Python virtual environment using venv (Django + MySQL ①)
Build a machine learning application development environment with Python
Build a python virtual environment with virtualenv and virtualenvwrapper
Create a django environment with docker-compose (MariaDB + Nginx + uWSGI)
Build a numerical calculation environment with pyenv and miniconda3
Minimal website environment with django
Collaborate in a remote environment
Create a homepage with django
Build a LAMP environment [CentOS 7]
Build python3 environment with ubuntu 16.04