-
Notifications
You must be signed in to change notification settings - Fork 22
Home
== Warmshowers.org Development and Maintenance (19 July 2009) ==
=== Update 19 July 2009: Lots and lots of changes not reflected here. The site has been updated to Drupal6. Don't use these instructions until they're updated ===
- Here are some of the things that have to be updated:
-
- How to delete language_negotiation variable and clear the cache
- Drupal6
- Misc changes, some thing better.
Author: Randy Fay, [mailto:[email protected]].
=== How it works – Overview ===
Warmshowers.org is an Apache/Mysql/Php application also making use of Google Maps API.
The production site and playground site are hosted on a dedicated Virtual Private Server through Randy’s company.
Roger was the originator and sustainer of the list as a text file for years before going forward with the idea of doing a website, which Randy put together.
=== Site Administration ===
Site administration on the production site is done via the fairly standard cpanel control panel, __http://warmshowers.org/cpanel__. It provides administration for mail, web, mysql, and a thousand other things. You will not need this unless you're actually administering the back-end of the live site. Both Roger and Randy have the username and password.
=== Technology Basics ===
==== Apache ====
The Apache web server, from __[http://httpd.apache.org/ http://httpd.apache.org]__, is the webserver. Complete documentation is available from the website, as well as many other places, including some excellent books. However, we configure very little about the webserver itself, since that’s handled by the folks at hostgator.com. We indirectly configure things through cpanel, and the .htaccess file is an Apache file. WS seems to work fine with any version of Apache.
==== PHP (Currently 5.2.x) ====
PHP is a web-embedded programming language from __[http://php.net/ http://php.net]__. The site is at version 5. The webserver on the site includes both 4 and 5 (with 4 as the default), so a directive at the top of the .htaccess file tells the webserver to use php5.
==== Mysql (Currently 4.1.21) ====
Mysql is the famous open source database, from __[http://mysql.com/ http://mysql.com]__. Full documentation is on their site, as well as a number of other places. WS seems to work fine with versions 4.1 and up of mysql.
==== Drupal 5.x ====
The framework for the site is Drupal, from __[http://drupal.org/ http://drupal.org]__. It was updated from 4.6 in October, 2007. There are a few custom modules that require hand-updating with each major Drupal version, and this can be a bit problematic. The most important modules are user_location, wsmap, and wsuser. There are custom adminsupport and locationservices and manage_blocked modules as well.
==== Javascript ====
The map stuff is primarily done with Javascript, most of which is basically modified stock code from various Google Maps API sites. It uses the excellent Clusterer2 javascript library for the large blue icons with multiple hosts, and uses the built-in (to Drupal) jquery library.
==== Web services for geocoding (Google Maps API, Geonames.org, geocoder.us, geocoder.ca) ====
Geocoding (taking an address and turning it into latitude and longitude) is done with a number of techniques, including the Google Maps API geocoder, the [http://geonames.org] geocoder, and a massive table (the geonames table) that that can be manually updated from the geonames.org site.
==== Google Maps API (Currently version 2) ====
The Google Maps API is used to display all maps. Full information is at __http://www.google.com/apis/maps/documentation/__. This service seems to get better all the time, with more areas of the world covered by more imagery.
=== Common Playground for testing and learning ===
There is a "playground" for testing and learning drupal administration on the warmshowers.org site. It's a snapshot copy of the site. You can fool around with this and experiment with different things without fear of breaking anything. If you destroy it, it's easy to just upload a new database. If it needs to be updated to try something out with the current database, we can just make a new copy. You can access the playground at http://playground.warmshowers.org . If you need administrative privileges, Randy or Roger can enable them.BRBR
=== How to set up a personal development/test/play area ===
It’s really important to develop, test, and play on a test system or sandbox. All development should be done there and fully tested before being uploaded to the server. Playing is terribly important, especially at first. And when you have it set up as described here, you can play away and then just reload the database and start from scratch.
Note that the database is not typically ever uploaded back to the server. The code occasionally is changed, but the database lives on the server. Perhaps someday we’ll have to do a reload, but that’s not the normal way.
Note that although these instructions are given for a Windows machine all the steps are the same for a Linux/Unix/Macintosh machine, except that many Linux machines would already have the apache/Mysql/Php requirements on them, so installing XAMPP would not be useful, although sometimes it's easier than working with the "native" versions.
Also, you could set up each component separately instead of using XAMPP to get you most of them.
The tutorial at __http://www-128.ibm.com/developerworks/edu/i-dw-i-osource3.html?S_TACT=105AGX46&S_CMP=overview__ has a nice overview of the various techniques (using the each-component-separately technique).
==== Apache/PHP/Mysql with !ApacheFriends XAMPP. Any version should do. ====
1. Download XAMPP from http://xampp.org. 1. Install XAMPP by running the installer. 1. Change to PHP4 by going to the XAMPP directory (usually Program Filesxampp or C:xampp) and running php-switch.bat 1. I recommend adding the xamppmysqlbin directory to your system path. This allows running the mysql commands easily. 1. I recommend installing the free Mysql GUI Query browser and Administration tools from __http://dev.mysql.com/downloads/gui-tools/5.0.html__
==== Create the mysql database and import the website database from it ====
- Download the database either from the site or get a canned version from me. (as of 12/24/2008 I have a prepared version of the database on __http://warmshowers_devel.s3.amazonaws.com/tmp/ws_devel.sql.gz__. This is the best way to get a quick start on development, if you're not trying to debug some specific issue on the existing site.) To download the live site (requires cpanel access)
1. Log into __http://warmshowers.org/cpanel__ 1. Navigate to Mysql, then to phpMyAdmin (at the bottom of the page) 1. Select the wsdrupal database on the left side 1. Choose the “export” tab 1. Select all the tables. ''Note that after the first download you can exclude the huge zipcodes table''; it’s static and perhaps unuseful. So once you have it loaded once in your mysql database, that should be enough. It saves a lot of time in the download. 1. Under SQL options on the upper right, choose “Disable foreign key checks” 1. Under structure, click “add drop table” 1. Click “save as file” at the bottom of the page, and choose “gzipped” or “zipped”, depending on what tools you have available. Gzip will be a faster download. 1. Download the file and then unzip it with whatever tools you have available. Gzip will unzip a .gz file, 7-zip or the like will unzip a .zip file. You may want to get the wonderful Cygwin toolkit from __[http://cygwin.com/ http://cygwin.com]__ while you’re waiting. It has gzip and gunzip and many other wonderful tools in it.1. Create the wsdrupal database. The XAMPP mysql comes with a blank password for root, so you can run “mysql –u root” and get in. UseBRcreate database wsdrupal;BRto create a database. 1. Import the database withBRmysql –uroot –-default-character-set=utf8 wsdrupal <roger_wdrupal.sql
==== Install Subversion (for source control), download the Drupal5 base code, and check out the WS-specific code. ====
1. Download the Subversion client from __http://subversion.tigris.org/project_packages.html#binary-packages__ You probably want svn-1.4.2-setup.exe, which is the Windows installer package. 1. Choose a place you want to do your development. For this example, we’ll use “My Documentswarmshowers”. I’ll just refer to it as “warmshowers” 1. Download the Drupal5 base code from __http://www.drupal.org__ and extract it as necessary 1. Check out the WS code (into the /sites directory in the drupal distribution). cd into the sites directory, and withBR
svn co --username <yourSubversionUser> --password <yourSubversionPassword> !http://opensvn.csie.org/warmshowers/website/trunk/sites/all
- (Only the sites/*/dev directories are under source control. Stuff that is warmshowers-specific is in sites/modules/dev and sites/themes/dev. Contributed modules are in sites/modules/contrib and were under source control but not really maintained there. Everything else (outside of sites) comes with the Drupal5 distribution.)
-
- Get the contrib modules used on the site and put them in sites/all/modules/contrib. There is a tarball of modules at __http://warmshowers_devel.s3.amazonaws.com/tmp/contrib_modules_20081224.tgz__. You can go into sites/all/modules and tar -zxf <the_tarball> and you should have it.
- When it's set up right you'll have /sites/all/modules/dev/wsmap, for example, and sites/all/modules/contrib/ip2cc, for example.
-
- Create a files directory in the root: /files. It needs to have write permissions by the webserver. This is no problem if you're running on windows and using xampp, but in many other environments you may have to give it 777 permissions or do some more sophisticated things.
==== Configure Apache to recognize the location of the test website ====
- Make a number of changes to the Apache httpd.conf file (in xampp/apache/conf
- Uncomment the line !LoadModule rewrite_module modules/mod_rewrite.so.
- Add after the !NameVirtualHost lineBR Include "conf/extra/vhosts.d/*.conf"
- In the hosts file (c:Windowssystem32driversetchosts) add an extra identification: 127.0.0.1 localhost warmshowers.local
- In the directory C:Program Filesxamppapacheconfvhosts.d create a file named “warmshowers.local.conf” with these contents (change to the actual installed location, of course):
{{{ <VirtualHost *:80> ServerName warmshowers.local DocumentRoot "/xampp/warmshowers" <Directory "/xampp/warmshowers"> AllowOverride All Order Deny,Allow Deny from All Allow from 127.0.0.1 </Directory> </VirtualHost> }}}
- Restart the Apache server and debug any problems using the log files in xampp/apache/logs
==== Update php.ini === php.ini is in xamppapachebinphp.ini (or wherever you put xampp). Edit it and set {{{ memory_limit = 96M; }}}
==== Configure Drupal for the database ====
You need to tell drupal how to connect to the database. In the Warmshowers.org/sites/. If you have done the instructions above, the sites/warmshowers.local/settings.php file may already work for you.
==== Final configuration for Drupal ====
Log into your __[http://warmshowers.local/ http://warmshowers.local]__ site with your browser. It might work.
If you're using the sample dump of the database as provided above, you should be able to use username=admin password=12345 to get into the drupal admin account.
If you're loading a copy of the real WS database, you need to do the items at [DatabaseBackup] to avoid making big mistakes.
The Google Maps API key needs to be set to something that works. For “warmshowers.local” you can use the key
ABQIAAAAtv7-Af2l6i3PAO3NeWmqAhSQ4rokvyWm46qkPrI6buxYoROcexTGjhOpduRopPvaoaXR7cKEbJySSQ
BR which can also be found in the Warmshowers.org/sites/warmshowers.local/settings.php file. Go to Management->User Location Settings and paste this key in there.
If you want the user pictures to show (if you’re working on that) then you’ll have to get them from files/pictures on the site and put them in warmshowers/Warmshowers.org/files/pictures. You don’t have to do this unless you need to see the pictures. These must not be checked in to subversion!
When you're working with your dummy copy: PLEASE do not enable the SMTP server on your system, and please do not do anything that might send mail. Don't run <yoursite>/cron.php... The site sends out mail via an SMTP library, not the local mail function, so please also make sure that your smtp module (Home >> Management >> Site configuration >> SMTP Support) is not configured to point at an external SMTP server. You just don't want to accidentally send out mail to a bunch of members.
==== Setting up a debugging environment ====
Real work on Drupal or the WarmShowers modules requires debugging. The time-honored tradition of adding print statements to the code works, but it’s not very efficient. I’ve used the commercial program Zend Studio for some time, but it costs money. The free program Eclipse (from __[http://eclipse.org/ http://eclipse.org]__) with phpEclipse can be set up for debugging as well. I tried it out and found that I could make it work, but that it executed quite slowly.…
A writeup on how to get Eclipse going with PHP is at __http://www-128.ibm.com/developerworks/library/os-debug/index.html__.
=== Resources ===
Of course, this area is infinite, but some listing is in order.
- Drupal: __[http://drupal.org/ http://drupal.org]__
- Apache: __[http://httpd.apache.org/ http://httpd.apache.org]__
- Php: __[http://php.net/ http://php.net]__
- Subversion: __[http://subversion.tigris.org/ http://subversion.tigris.org]__. The manual is at __http://svnbook.red-bean.com/__ and there are lots of other resources on the site.
- An outstanding tutorial on the basics of Drupal and all the associated tools is at __http://www-128.ibm.com/developerworks/ibm/osource/implement.html__. They installed all the tools separately, but all the concepts are the same.