Giter Club home page Giter Club logo

vagrant-simple-apache-djangocms's Introduction

Boilerplate Apache + Django CMS Virtual Machines with optional project boilerplate and support for isolated project frontend/backend, for Red Hat and Debian based environments.

This repo provides an easy way to get started on a new Django CMS project. By simply bringing up a new virtual machine via vagrant up, it is possible to have a Red Hat or Debian based environment set up with an Apache + Django CMS configuration, along with the default Django CMS starter project already up and running, served at localhost:8080. The created project will already have STATIC_ROOT and STATIC_URL configured, and a requirements.txt present at its root. With all this out of the way, you can get to business. All configuration is stateful thanks to Ansible, so the next time you vagrant provision, your project will be exactly how you left it, the provisioner will just update the database, static files, and installed requirements on the machine to match your project.

You can also import an existing Django CMS project into this environment! Simply make sure you put the root of the project (with manage.py) directly in the server/app folder of whatever environment you choose to go with. A requirements.txt will be created automatically if it didn't already exist in the root of your project. For now, only SQLite will work for importing.

Requirements:

  • Vagrant 1.8.7+
  • VirtualBox 5.1.x

Get Started:

  • Install Vagrant 1.8+.
  • Clone this repository: git clone https://github.com/gscoppino/vagrant-simple-apache-djangoCMS --depth=1
  • Copy either the Ubuntu or CentOS directory to the location you want to keep your project in, and rename the directory to whatever you like. This is now your project folder.
  • (optional) Place an existing Django CMS project in the server/app directory of your project folder. The manage.py script for the project should be in the root, eg. server/app/manage.py.
  • Run vagrant up from your project folder.

Basic Usage:

  • vagrant up : When you are ready to spin up the server. If a project doesn't exist one will be created in the backend directory.
  • vagrant provision : can be used to bring the virtual machine to a new desired state without starting from scratch. If changing a configuration file (such as the Apache config, or your requirements.txt), just run vagrant provision to get the machine to the state it needs to be in.

Initial Environment

  • A new project called project will automatically be created for you in server/app if the provisioner didn't find an existing project. Otherwise, the only difference to note will be that a requirements.txt was created for your project, if it didn't already have one.
  • The project will have been set up and running on localhost:8080 (note that for now, if your existing project is using a database other than SQLite, the migration task will have failed since the database engine will not exist on the VM. Planning to set up dynamic installing of the database engine in the very near future).

Making Changes to the Apache Configuration

The Apache VirtualHost configuration can be found in server/provision/roles/apache/files. If you customize it (for example, to change the path to wsgi.py if you imported your own project or changed the project name), make sure to run vagrant provision, which will copy it into the virtual machine.

Working with the virtual machine from outside the VM

Helper scripts for common tasks live in server/utils directory.

Django 101

Project Configuration

Stored in server/app/PROJECT_NAME/settings.py.

Project Admin Configuration

Create a superuser using server/utils/django-admin createsuperuser. Alternatively, if you wish to do this from within the VM:

  • SSH into the VM: vagrant ssh.
  • Activate the virtualenv: source /home/vagrant/project_env/bin/activate.
  • Change directory to /vagrant/server/app.
  • run python manage.py createsuperuser.

Project Database Configuration

DATABASES['default']: Provide information for your database management system here.

Project Static Files Configuration

STATIC_URL: The directory Django will look in for static files within INSTALLED_APPS when using ./manage.py runserver or ./manage.py collectstatic.

STATIC_ROOT: Where Django will dump static files it finds via ./manage.py collectstatic.

vagrant-simple-apache-djangocms's People

Contributors

gscoppino avatar

Watchers

 avatar

vagrant-simple-apache-djangocms's Issues

Database error

When I create a new instance of the VM and try to access the sample project at localhost:8080 I get an error:

OperationalError at /
attempt to write a readonly database
Request Method: GET
Request URL: http://localhost:8080/
Django Version: 1.8.17
Exception Type: OperationalError
Exception Value:
attempt to write a readonly database
Exception Location: /home/vagrant/project_env/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py in execute, line 318
Python Executable: /usr/bin/python
Python Version: 2.7.6
Python Path:
['/vagrant/server/app',
'/home/vagrant/project_env/lib/python2.7/site-packages',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages']

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.