Just completing some upgrades to my service to incorporate subversion. I don't know how I got by without it for so long. My first exposure to version control software was Visual SourceSafe back in the dark ages, and since then I've either used that or similar routines involving backups and multiple versions in similarly-named folders. Subversion is a lean, command-line, open-source version of the same. Here's what I did.
In the case of MediaTemple, Subversion is already installed. All you have to do to get started is invoke a new instance on the command line.
svnadmin create /name/of/project/folder
Then build a project to import into svn, such as
tmp/project/trunk
tmp/project/branches
tmp/project/tags
Jump into the trunk and add some files to it
file1
file2
file3
When you import the project, subversion vacuums it all up.
svn import /tmp/project file:///name/of/project/folder -m "initial import"
Note the -m, ensures you won't get an error for not setting the default text editor for subversion. In case you would like to set it, just use the command:
export SVN_EDITOR=vi
Now you can checkout files using the checkout command
svn checkout file:///name/of/project/folder/trunk project
And you can post your revisions using commit
svn commit
Notice the difference in directory structure between creating, importing and checking out. Creating and importing require only the folder, but checking out requires the additional trunk folder and project name specified.
Here are some additional resources of note for subversion installations, with an emphasis on MediaTemple (dv) installations.
Ayman Hourieh Subversion Tutorial - quick and to the point.
Tony Spencer's Tutorial - includes basic WebDAV integration, also quick and to the point.
Showing posts with label web development. Show all posts
Showing posts with label web development. Show all posts
Wednesday, June 24, 2009
Monday, June 22, 2009
Python and Django in MediaTemple (dv) server
Getting Django to run on a dv server is not as easy as their preconfigured - and cheaper - grid containers. While the shared grid containers are ready to go out of the box, the dv has some server admin changes to get through before you see that welcome
"Hello World".
Specifically, the httpd.conf needs additional lines of code to connect the web root to the Django application. To add a little spin to it, there's also the config file generated by Plesk. That needs some edits as well.
The order of statements in the zz010_psa_httpd.conf file can be a particular obstacle. Seems you have to have the WSGIScriptAlias declarations high up in the page or they aren't acted on properly as the procedure continues. Changing LogLevels to info gives the most detailed view from your logfiles but may not ultimately identify the problems.
In any case, here are the steps in a nutshell:
(added to zz010_psa_httpd.conf - plesk)
Include /var/www/vhosts/urlone.com/conf/httpd.include
Include /var/www/vhosts/urltwo.com/conf/httpd.include
WSGIScriptAlias /myapp /var/www/vhosts/urlone.com/wsgi-scripts/myapp.wsgi
WSGIScriptAlias /django/test01 /var/www/vhosts/urltwo.com/wsgi-scripts/myapp.wsgi
(added both httpd.includes to file structure)
Seems simple enough once it works. I hope this gets you out of a pinch.
"Hello World".
Specifically, the httpd.conf needs additional lines of code to connect the web root to the Django application. To add a little spin to it, there's also the config file generated by Plesk. That needs some edits as well.
The order of statements in the zz010_psa_httpd.conf file can be a particular obstacle. Seems you have to have the WSGIScriptAlias declarations high up in the page or they aren't acted on properly as the procedure continues. Changing LogLevels to info gives the most detailed view from your logfiles but may not ultimately identify the problems.
In any case, here are the steps in a nutshell:
(added to zz010_psa_httpd.conf - plesk)
Include /var/www/vhosts/urlone.com/conf/httpd.include
Include /var/www/vhosts/urltwo.com/conf/httpd.include
WSGIScriptAlias /myapp /var/www/vhosts/urlone.com/wsgi-scripts/myapp.wsgi
WSGIScriptAlias /django/test01 /var/www/vhosts/urltwo.com/wsgi-scripts/myapp.wsgi
(added both httpd.includes to file structure)
Seems simple enough once it works. I hope this gets you out of a pinch.
Labels:
django,
python,
server admin,
web development
Monday, June 15, 2009
Serving Django on Apache
As an update on the previous post, looking into current Django docs, the Apache production server method of using mod_python to serve Django has been superseded by mod_wsgi. I had partially implemented the former method, so now I'm bringing it up to the latest spec.
According to google.code on Python WSGI, Apache 1.3, 2.0 or 2.2 are compatible. Apache on a MediaTemple dv account shows
httpd -v
Server version: Apache/2.2.3
Server built: Nov 12 2008 10:41:27
Python needs to be 2.3 through 2.5 and the vers on (mt) shows
Python 2.4.3 (#1, May 24 2008, 13:47:28)
So far, so what. Now to install wsgi...
wget http://modwsgi.googlecode.com/files/mod_wsgi-2.5.tar.gz
tar xvfz mod_wsgi-2.5.tar.gz
configure
make
make install
finally edit
httpd.conf
located in
/etc/httpd/conf.
Adding the lines:
LoadModule wsgi_module modules/mod_wsgi.so
and
<virtualhost *>
ServerAdmin jasonthewolf@gmail.com
ServerName www.unplugtheinternet.com
DocumentRoot /var/www/vhosts/unplugtheinternet.com
WSGIScriptAlias / /django/test01/apache/django.wsgi
</virtualhost>
In the above, WSGIScriptAlias deserves some explanation:
Description : WSGI maps a URL to a filesystem location and designates the target as a WSGI script.
Syntax : WSGIScriptAlias URL-path file-path|directory-path
Context : server config, virtual host
Module : mod_wsgi.c
A request for http://www.example.com/wsgi-scripts/name in this case would cause the server to run the WSGI application defined in /web/wsgi-scripts/name. This configuration is essentially equivalent to:
and restart apache with
apachectl restart
All reports are good from Apache so far. Now that the installation of wsgi is complete, back to Django implementation.
I once again edited httpd.conf, this time adding
WSGIScriptAlias / /path/to/mysite/apache/django.wsgi
which for my site and requirements was effectively:
WSGIScriptAlias /django/test01 /var/www/vhosts/unplugtheinternet.com/apache/django.wsgi
This is the folder I have chosen for my python tests. If they work out, I'll move them to the root of some url or another. Following the convention established in the example, I created directory apache and the used vi to create the textfile django.wsgi as:
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
According to google.code on Python WSGI, Apache 1.3, 2.0 or 2.2 are compatible. Apache on a MediaTemple dv account shows
httpd -v
Server version: Apache/2.2.3
Server built: Nov 12 2008 10:41:27
Python needs to be 2.3 through 2.5 and the vers on (mt) shows
Python 2.4.3 (#1, May 24 2008, 13:47:28)
So far, so what. Now to install wsgi...
wget http://modwsgi.googlecode.com/files/mod_wsgi-2.5.tar.gz
tar xvfz mod_wsgi-2.5.tar.gz
configure
make
make install
finally edit
httpd.conf
located in
/etc/httpd/conf.
Adding the lines:
LoadModule wsgi_module modules/mod_wsgi.so
and
<virtualhost *>
ServerAdmin jasonthewolf@gmail.com
ServerName www.unplugtheinternet.com
DocumentRoot /var/www/vhosts/unplugtheinternet.com
WSGIScriptAlias / /django/test01/apache/django.wsgi
</virtualhost>
In the above, WSGIScriptAlias deserves some explanation:
Description : WSGI maps a URL to a filesystem location and designates the target as a WSGI script.
Syntax : WSGIScriptAlias URL-path file-path|directory-path
Context : server config, virtual host
Module : mod_wsgi.c
A request for http://www.example.com/wsgi-scripts/name in this case would cause the server to run the WSGI application defined in /web/wsgi-scripts/name. This configuration is essentially equivalent to:
and restart apache with
apachectl restart
All reports are good from Apache so far. Now that the installation of wsgi is complete, back to Django implementation.
I once again edited httpd.conf, this time adding
WSGIScriptAlias / /path/to/mysite/apache/django.wsgi
which for my site and requirements was effectively:
WSGIScriptAlias /django/test01 /var/www/vhosts/unplugtheinternet.com/apache/django.wsgi
This is the folder I have chosen for my python tests. If they work out, I'll move them to the root of some url or another. Following the convention established in the example, I created directory apache and the used vi to create the textfile django.wsgi as:
import os
import sys
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
Friday, June 12, 2009
Python and Django wrapup
Almost a wrapup.
Got django installed in /usr/lib/python2.4/site-packages/
Got django deployed in /var/www/vhosts/unplugtheinternet.com/django/test01/ with subfolder cms autogenerated
Got MySQLdb module added to python so django can use a MySQL database, and django has been successfully configured to build the schemas for the modules it deploys.
Created a vhost.conf to take care of webserver requests that python should handle (courtesy of Nick Sergeant's blog entry).
Still it isn't working properly. But since I'm leaving for a camping trip in ~1 hour, it's time to switch it off and go join my friends at Assateague Island.
Arrividerci pals.
Got django installed in /usr/lib/python2.4/site-packages/
Got django deployed in /var/www/vhosts/unplugtheinternet.com/django/test01/ with subfolder cms autogenerated
Got MySQLdb module added to python so django can use a MySQL database, and django has been successfully configured to build the schemas for the modules it deploys.
Created a vhost.conf to take care of webserver requests that python should handle (courtesy of Nick Sergeant's blog entry).
Still it isn't working properly. But since I'm leaving for a camping trip in ~1 hour, it's time to switch it off and go join my friends at Assateague Island.
Arrividerci pals.
Labels:
cms,
django,
python,
web development,
web projects
MediaTemple, Python and Django
Just installing Django on my Mediatemple dv account.
First, log in to SSH as root user. Then use subversion, provided by mediatemple in
WebControl > Root Access & Developer Tools > Install Developer Tools,
which must at some point be enabled to be accessible. Following this,
Subversion grabs the latest version to /var/trunk/django.
In the case of dv accounts, python packages are located in /usr/lib/python2.4/site-packages
Create a symbolic link between these two locations using
ln -s /var/trunk/django /usr/lib/python2.4/site-packages
then add another symbolic link to bring the underlying python script to the root of the django trunk:
ln -s /var/trunk/django/bin/django-admin.py /usr/local/bin
Basically, what is happening here is:
Django Source /var/trunk : Subversion project root
\ --> accessible to /usr/lib : Libraries for programming and packages
\ --> accessible to /usr/local : Local hierarchy
More on this. Now:
import django
and
django.version
voila!
Next, you must add the MySQLdb interface for python if you are planning to use mySQL as your cms database. Here's a good reference for once you have the tarball in your directory. However, I'd rather wget it directly from the sourceforge site. Here is the command to use from root SSH:
wget http://downloads.sourceforge.net/mysql-python/MySQL-python-1.2.2.tar.gz
Works fine. Now install the module and it should run without an error.
First, log in to SSH as root user. Then use subversion, provided by mediatemple in
WebControl > Root Access & Developer Tools > Install Developer Tools,
which must at some point be enabled to be accessible. Following this,
Subversion grabs the latest version to /var/trunk/django.
In the case of dv accounts, python packages are located in /usr/lib/python2.4/site-packages
Create a symbolic link between these two locations using
ln -s /var/trunk/django /usr/lib/python2.4/site-packages
then add another symbolic link to bring the underlying python script to the root of the django trunk:
ln -s /var/trunk/django/bin/django-admin.py /usr/local/bin
Basically, what is happening here is:
Django Source /var/trunk : Subversion project root
\ --> accessible to /usr/lib : Libraries for programming and packages
\ --> accessible to /usr/local : Local hierarchy
import django
and
django.version
voila!
Next, you must add the MySQLdb interface for python if you are planning to use mySQL as your cms database. Here's a good reference for once you have the tarball in your directory. However, I'd rather wget it directly from the sourceforge site. Here is the command to use from root SSH:
wget http://downloads.sourceforge.net/mysql-python/MySQL-python-1.2.2.tar.gz
Works fine. Now install the module and it should run without an error.
Labels:
cms,
django,
python,
web development,
web projects
Saturday, May 9, 2009
Poster REST App for Firefox
Pretty useful plug in here to allow what otherwise requires modules, DLLs or IDEs. Don't know how I got by without it for so long.
Get Poster
On the PS side, why do low-level service applications typically lack quick client integration options? My web services visualization tool is the browser, not a command line or SDK. So let's put that app into the browser.
Poster does that. Thanks to creator Alex Milowski. Read his blog.
Get Poster
On the PS side, why do low-level service applications typically lack quick client integration options? My web services visualization tool is the browser, not a command line or SDK. So let's put that app into the browser.
Poster does that. Thanks to creator Alex Milowski. Read his blog.
Labels:
firefox,
http requests,
rest,
web development
Tuesday, March 10, 2009
Starting the new MS Website
Site Setup Process
Microsoft Management Console
MasterPage
Microsoft Management Console
- Start local IIS
- Start local SQL Server
- Create new ASP.NET site of type .NET Web Application
- Install Forms Authentication Framework to establish user accounts
MasterPage
- Sitemap
- Add provision for Web.sitemap
- Create Web.sitemap
- Add siteMap entry to web.config
- User Authentication
- Install Forms Authentication schema to application
- Customize FormsAuthentication class for user accounts
Subscribe to:
Posts (Atom)