Table of contents
- 1. Basic usage
- 2. Django Specific Usage
- 1. Basic usage
- 2. Django Specific Usage
BitNami Django Stack for the Mac Application Store greatly simplifies setting up a full Django development environment in a single click.
The first time the application is launched, it will prepare its environment:
The process will take a few seconds.
When the BitNami Stack for Django is opened, you are prompted with the Welcome page. This page allows you to do basic operations with your server such as visiting the main page ("Visit Application" button), managing your databases ("Open phpMyAdmin" button), opening the application folder in Finder ("Open Application Folder") as well as links to support and BitNami web site. It also includes buttons to follow us so you can get information about our new releases and other products.
You can also notice how two of the buttons appear greyed out. That is because the application is not yet started. The next section will explain you how to start it.
Managing the Services
To start using the MAMP server, you must first start the services. You can easily do that in "Manage Servers" tab. That page will list all the installed services and their states:
You can manually start, stop or restart them individually using the left side buttons or start them all at once using the bottom buttons. In this case, to get a fully started MAMP server you should click "Start All". The states of all the servers will indicate the status of the process while launching them:
If you go back to the Welcome tab, the "Visit Application" and "Open phpMyAdmin" buttons will be now available. Clicking "Visit Application" will open the main index page in your preferred browser:
Changing The Application Ports
By default, your MAMP server will configure the ports while initializing the first time using 8080 for Apache Web server port and 3306 for MySQL database server. However, if one of them is taken, it will automatically pick the first available one. You can view that information using the "Configure" button in the "Manage Servers" section.
Apart from allowing you to review the currently configured ports, you can also change their values.
If the selected ports are not available, you will be prompted with a warning, and your changes won't be applied:
It the selected values are however valid, it will require to restart the services so the changes are taken into account. Denying it will discard the changes:
Viewing your services logs
You can get some basic information about the overall state of the server checking the "Application Log" tab:
However, you can get a more detailed information by checking the servers log individually. To do that, you just have to select one of them from "Manage Servers" tag and select "Configure". You will find buttons pointing to the logs.
The logs will be opened using the "Console" application.
Manually Editing the Configuration Files
If your require further customizations of the servers beyond changing the ports, you can use the "Open Conf File" button in the "Configure" dialog:
Please note an incorrect configuration file could make your services unable to start so you should not make changes if you are not entirely sure of the modifications or have made a backup of the original file. The application will warn you when accessing the configuration file:
Opening the Application Folder
You can easily navigate to the application folder clicking the "Open Application Folder" button in the "Welcome" tab:
That makes it easy to, for example, add files to your apache2/htdocs folder and make them automatically accessible from other computers in your network.
Launching the Django Console
To create new projects you will need to load the development environment. To do that, simply open the application folder as explained in the previous section and doubleclick on the 'use_djangostack' icon. A new Terminal window will be opened, from which you will get access to all the bundled tools such as Python and 'django-admin.py':
Closing the application
When closing the application, all the running services will be closed. You will be first prompted for confirmation. Answering "No" will abort closing, while "Yes" will properly shut them down and exit. This will make sure you do not end will unnoticed background services consuming resources.
If you liked our application and want to help others know about it, please rate us in the store. You can manually search for us or use our link button. To do that, clink in "About MampStack" in the top menu, and then "Rate i!". The "App Store" application will be automatically opened and you will be redirected to the application page:
Django Specific Usage
Create a new project
The best way of learning how to use your Django web framework is by following the Django first application tutorial
To do that, first open the Django console by doubleclicking the "use_djangostack" script under the application folder:
Then navigate to the django projects directory, which already contains the sample project:
And you can start following the Django tutorial. You can check the simplest application posible simply executing:
And check 127.0.0.1:8000 in your browser.
This application is however running in a development HTTP server, just mean for quick tests. If you want something a little more robust, you can serve it through the included Apache server, the same way the bundle sample project works. To do that, you can use it as a reference:
- Copy the django.wsgi script to mysite.wsgi
bash-3.2$ cp ~/shared/django/scripts/django.wsgi ~/shared/django/scripts/mysite.wsgi
- Edit ~/shared/django/scripts/mysite.wsgi and replace all the references to "Project" (the sample project name) with "mysite" (our new project). The result should be similar to the below, where the changes have been highlighted:
- Copy the django.conf file to mysite.conf:
bash-3.2$ cp ~/shared/django/conf/django.conf ~/shared/django/conf/mysite.conf
- Edit ~/shared/django/conf/mysite.conf and adjust the "WSGIScriptAlias" directive to point to the mysite.wsgi script and match it to the "/mysite" url (you could select any other location for the url). You should obtain something similar to the below, where the changes have been highlighted:
- Edit ~/app/apache2/conf/httpd.conf and add include the it:
- Restart the Apache server and check the new url (typically, it will be 127.0.0.1:8080/mysite, where the port number could be different):
You can see that the application is the same one as before, but is now being served through Apache!
Because of the security restrictions when running under the sandbox, created files are not allowed to have executable permissions. This interferes with how virtualenv works, as it creates wrapper binaries to call the appropriate version of python and because of that is not supported.