Skip to content

simplworld/python-vagrant-centos7

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A CentOS 7.2 Vagrant Box with Python 3.5 via Ansible

  • Apache 2.4, with mod_wsgi (Django)
  • FreeTDS drivers for MS SQL Server
  • PostgreSQL Drivers & Server
  • Node + npm

This repository contains a CentOS 7.2 box for Vagrant. Python 3.5.3 is installed alongside the system Python (2.7.5). The Vagrant config uses a bootstrap.sh script, meant to illustrate steps for getting a development environment, with modules in a self-contained directory thanks to virtualenvwrapper.

MS SQL is also supported as a Django database backend with the FreeTDS ODBC Driver to SQL Server. PostgreSQL 9.5, including the server, can be install optionally for those using PostgreSQL.

Django versions 1.8 and greater are supported. Python 3.5 was first supported in Django 1.8. Django 1.8 is an LTS (Long Term Support) release, meaning it will be actively supported with bug fixes and security patches until at least April, 2018 (and probably longer): https://www.djangoproject.com/download/#supported-versions

Compatibility

Get Started

Clone the repository and bring up the virtual development environment. The first time you install the box, "vagrant up" will take a little while. Grab a cup of coffee or something!

git clone https://github.com/wharton/python-vagrant-centos7.git
cd python-vagrant-centos7
vagrant up
vagrant ssh

Specifying a Host Name

By default, the host name will be set to vagrant.example.com. You can specify a host name like this:

$ VAGRANT_HOSTNAME="vagrant.my.domain.com" vagrant up

You can also add the host name to your computer's hosts file. Your hosts file should be located at:

  • Mac / Linux: /etc/hosts
  • Windows: %SystemRoot%\system32\drivers\etc\hosts

Add this line (with the appropriate host name, if you changed it):

192.168.99.100  vagrant.example.com

Setting Up PostgreSQL & Getting Started

On your Vagrant box, a script has been provided to install PostgreSQL Server 9.6 and set up the vagrant user as superuser alongside the system postgres user.

$ sudo /vagrant/assets/install_postgres.sh
$ psql
psql (9.6.2)
Type "help" for help.

vagrant=# \?
...
vagrant=# \q

Creating ERDs of Django Models

The django-extensions app can build handy Entity Relationship Diagrams for Django apps, even your entire project. The pre-requisites for the Python packages are included with this Vagrant box.

An example ERD with three Django apps.

First, install django-extensions and pygraphviz:

pip install django-extensions pygraphviz

Next, add django_extensions to your INSTALLED_APPS. Then you can create the diagrams; to create a PNG of all models in your Django project.

./manage.py graph_models -a -g -o project-erd.png

Or, to just do a few Django apps:

./manage.py graph_models users faculty courses -g -o users-faculty-courses.png

Windows 10: Forwarding Port 80 for Testing Apache

In Windows 10, the "World Wide Web Publishing Service" automatically starts on port 80. You can disable it so Vagrant can forward port 80.

  • Click Start, type "Services" and open Services.
  • Scroll down to World Wide Web Publishing Service. Right click and go into Properties.
  • Change "Startup type" to be Manual.
  • Click the "Stop" button.
  • Click "OK".

Authors:

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Shell 100.0%