Archive for the ‘apache’ tag
Beginning CouchDB is out now
My book “Beginning CouchDB” is now available in the United States, and should be available internationally in the coming days. The final manuscript comes in at exactly 300 pages, and features everything you need to know to get started with the Apache CouchDB database – from installing it on Mac OS X or Linux to creating applications that work with CouchDB data using JavaScript, Python and Ruby. The following are links to Websites where you can purchase the book:
Amazon.com
Barnes & Noble
Borders
Books-A-Million
Amazon.co.uk
Waterstones
WHSmith
Apress (Buy e-Book Version for $27.99)
The following is the Table of Contents for the completed work:
- About the Author
- About the Technical Reviewer
- Acknowledgements
- Introduction
- Part 1: Getting Started
- Chapter 1: Introduction to CouchDB
- What is CouchDB?
- CouchDB: The Story So Far
- Document-Oriented Databases
- CouchDB Documents
- The JavaScript View Engine
- Restful HTTP API
- Futon
- So…Now What?
- Chapter 2: Installing CouchDB on Linux
- Installing CouchDB on Ubuntu Linux 8.10
- Installing CouchDB on Fedora Linux Using yum
- Building CouchDB (and Prerequisites) from Source Code
- Building Erlang
- Building libcurl
- Building ICU
- Building Spidermonkey
- Building Subversion
- Building CouchDB
- Chapter 3: Installing CouchDB on Mac OS X
- Installing the Xcode Developer Tools
- Installing Macports
- Installing CouchDB
- CouchDBX: A One-Click CouchDB Package for Mac OS X
- Chapter 4: Creating Your First CouchDB Database
- Tools of the Trade
- HTTP Requests
- JSON Response
- Using curl
- Creating Your First Database
- Creating Documents in Your Contacts Database
- Getting Started with CouchDB Views
- Summary
- Chapter 1: Introduction to CouchDB
- Part 2: Managing CouchDB Databases
- Chapter 5: Using Futon: The CouchDB Administration Interface
- Creating a Database
- Creating a Document
- Uploading Attachments
- Compacting the Database
- Futon Tools
- Summary
- Chapter 6: Introduction to JSON
- What is JSON?
- Why JSON?
- JSON 101: Syntax and Data Types
- Working with JSON
- Defining JSON Structures
- Looping Through JSON Arrays
- CouchDB and JSON
- Summary
- Chapter 7: Introduction to CouchDB Views
- Creating Views
- Permanent Views
- Design Documents
- Views and the CouchDB API
- Summary
- Chapter 8: Map/Reduce
- What is Map/Reduce?
- Map/Reduce in CouchDB
- Map/Reduce in Futon
- Map/Reduce Views and the CouchDB API
- Map/Reduce vs. SQL Queries
- Word Count Example
- Summary
- Chapter 9: Advanced CouchDB Views
- Advanced Aggregation
- Ordering and Filtering Results
- Working with Related Data
- Summary
- Chapter 5: Using Futon: The CouchDB Administration Interface
- Part 3: Advanced CouchDB Topics
- Chapter 10: Developing CouchDB Applications with CouchApp
- Installing CouchApp
- Your First CouchApp
- Creating CouchTasks: A Simple Task Manager
- Suggested Improvements
- Summary
- Chapter 11: Developing Applications with CouchDB
- Developing in Python with Couchdbkit
- Developing in Ruby with CouchRest
- Creating a Bookmarks Application with CouchDB and Django
- Summary
- Chapter 12: Advanced CouchDB Topics
- Replication
- Compaction
- Fetching Documents in Bulk
- Writing Documents in Bulk
- Show Functions
- Summary
- Chapter 13: Mechanics of CouchDB Deployment
- Measuring Performance
- Configuring CouchDB
- Conflict Resolution
- Security
- Backup
- Fault Tolerance and Load Balancing
- Clustering
- Summary
- Chapter 10: Developing CouchDB Applications with CouchApp
- Appendices
- Appendix A: CouchDB API Reference
- Appendix B: HTTP and curl Reference
- Index
I’m writing a book
I’m delighted to announce that I have signed a book deal with Apress publishing (the black and yellow techie books). The book is on Apache CouchDB, an exciting document-oriented database management system that is in active development. I was approached by Apress about the prospect of writing a book on CouchDB after my article “Exploring CouchDB” was published on IBM developerWorks back in March 2009. The book is coming along quite nicely and I’ll have much more information to share shortly.
For now, check out my “Exploring CouchDB” article on IBM developerWorks.
Also, please check out Apress.com for similar books. Apress have published over 700 books on a wide range of technology areas including Programming, Web Development, iPhone Development, Open Source, Operating Systems and much more. Below are some of the excellent books they have published (my book will have a similar cover):
Exploring CouchDB
In this developerWorks article, I explore the concepts behind Apache CouchDB – an open source, document-oriented database management system. CouchDB uses a RESTful JSON API and JavaScript views to interact with and report on the data stored in the database. Unlike the relational model, the model CouchDB is built on is designed specifically for use in document-oriented web applications such as blogs, wikis and discussion forums. This makes it an exciting prospect as a potential de-facto database for publishing-oriented web applications. The following is the abstract from IBM developerWorks:
Relational databases define a strict structure and provide a rigid way to maintain data for a software application. Apache’s open source CouchDB offers a new method of storing data, in what is referred to as a schema-free document-oriented database model. Instead of the highly structured data storage of a relational model, CouchDB stores data in a semi-structured fashion, using a JavaScript-based view model for generating structured aggregation and report results from these semi-structured documents. CouchDB has been developed from the ground up with Web applications as the primary focus and has its sights on becoming the de-facto database for Web application development.
Read the article in full at http://www.ibm.com/developerworks/opensource/library/os-couchdb/
Install Apache and mod_owa
In order to develop PL/SQL applications on Oracle XE, we are going to need to install a web server (Apache) and a PL/SQL gateway for Apache called mod_owa. On a regular Oracle Application Server you would probably be using Oracle HTTP Server (a modified Apache) and mod_plsql, amd you should also be able to follow my future tutorials if you have this type of setup.
Once again I will be assuming throughout this guide that you have followed my Oracle XE installation tutorial. If you didn’t, you may need to change usernames, passwords and service names to fit your setup. I will be walking through the setup process on a Windows XP machine, but it should be similar on another Windows version. Let’s get started!
IMPORTANT NOTE: If you are looking for the download for mod_owa, please note that the website for it has moved since this blog post was originally written. You can now find mod_owa on the Oracle OSS website at the following URL: http://oss.oracle.com/projects/mod_owa/dist/documentation/modowa.htm. I have updated this blog post to reflect this change.
The first thing you’ll need to do is download the relevant software. The easiest way to install Apache is to download and run the installer binary from the Apache website. At the time of writing, the latest stable version of Apache available is 2.2.9, but again the process should be similar for whatever version you are installing. You can download Apache from http://httpd.apache.org/download.cgi. You will also need to grab the Apache PL/SQL Gateway Module (mod_owa) from http://oss.oracle.com/projects/mod_owa/dist/documentation/modowa.htm. Click on the link for “Zip file for Windows”, which includes the source code and binaries for the Windows version of Apache.
The first stage in setting up our PL/SQL web development environment is the installation of the Apache web server. To start the installation, run the installer package you downloaded earlier (the filename should be something like apache_2.2.9-win32-x86-no_ssl-r2.msi). The screen should look similar to the one in Figure 3a below:
Click “Next >” to continue. On the screen that follows, read the license agreement and if you are happy with the terms, select “I accept the terms in the license agreement” and click “Next >” to move on to the readme screen, from which you can simply press “Next >” again. You should now be presented with the following screen:
Unless you are installing Apache for production use, it doesn’t matter too much what you enter into Network Domain, Server Name or Administrator’s email, but be sure to select the option to Install Apache “for All Users, on Port 80, as a Service”. Installing on Port 8080 would likely cause a conflict between Apache and the Application Express software that comes with Oracle XE, which runs on port 8080. As soon as you are ready, click “Next >” to continue.
On the “Setup Type” screen, you can safely leave the default option of “Typical” selected and click “Next >” to continue with the installation. Advanced users may wish to tweak their installation using the Custom option, but for the sake of this tutorial, there is no need to do so.
The Apache installer will now ask you where to install Apache on your hard disk. By default Apache is installed into a subfolder of the Program Files folder, but I find it easier to install Apache into a folder just beneath the root of the C drive, which I usually name “httpd”. You can safely accept the default destination, but from here on I will refer to all Apache configuration files as if you chose to install to C:\httpd\. To install to this directory, click on the “Change” button as in Figure 3d, which should popup a screen like the one in Figure 3e. In the textbox for Folder Name, enter C:\httpd\ and click “OK”. This will close the popup window and return you to the screen shown in Figure 3d. You can now click on “Next >”.
You can now safely click on the “Install” button, which will start the installation process. This should not take long, especially if you are using a modern PC. During the installation you should see a screen similar to that in Figure 3f below.
When the installation has completed, simply click the “Finish” button to exit the installer. You should now have a new icon in your system tray, like the one highlighted in Figure 3g. It should have a tiny green play symbol in it. If it has a red square stop symbol instead, left-click on the icon, and from the Apache2.2 menu, click “Start” to start the Apache service.
Before we move on to installing mod_owa, we will first check that Apache is up and running and functioning correctly. To do so, open your favourite web browser (I use Firefox), enter http://localhost/ in the address bar and press enter. If Apache is working, you will see a message like in Figure 3h:
Now that we have Apache up and running, it is time to install our PL/SQL gateway, mod_owa. The first thing we need to do is to unzip the archive we downloaded earlier, usually named windows_all.zip. You don’t need to worry about where you extract the files to, as we are only really interested in one of them. When the archive has extracted, open the folder you extracted them, and go into the modowa folder. From here, double click on apache22 and right-click on mod_owa.dll and click Copy.
We will now paste this into the modules folder under the Apache installation directory. Hold down the Windows key and press R to open the Run dialog and enter C:\httpd\modules\ as shown in Figure 3i:
This will open the modules folder. Go to the Edit menu and click on Paste to put a copy of the mod_owa.dll file here. Now that we have stored the module DLL file, we now need to tell Apache to load this module into the web server and set up a new Apache Location, which will act like an Oracle Document Access Descriptor (DAD) from where we can run our PL/SQL web applications. If none of this makes any sense to you at this point, don’t worry about it, just follow the instructions closely and you’ll be fine.
To open the Apache configuration file (httpd.conf) open the Run dialog once again (Windows+R or Start->Run). This time, enter notepad c:\httpd\conf\httpd.conf and click the OK button. Notepad should launch, with the Apache config file opened and ready for editing. Scroll down to the bottom of this file (or hold down the Ctrl button and press the End button) and below all other code, insert the text from listing 3a:
LoadModule owa_module modules/mod_owa.dll
<Location /somando>
AllowOverride None
Options None
SetHandler owa_handler
OwaUserid somando/somando1
OwaNLS WE8ISO8859P1
OwaDiag COMMAND ARGS CGIENV POOL SQL MEMORY
OwaLog "/usr/local/apache/logs/mod_owa.log"
OwaPool 20
OwaStart "doc_pkg.homepage"
OwaDocProc "doc_pkg.readfile"
OwaDocPath docs
OwaUploadMax 10M
OwaCharset "iso-8859-1"
order deny,allow
allow from all
</Location>
/
Listing 3a: mod_owa Options for Apache’s httpd.conf
When you have added the text above to your httpd.conf file, save the file, and on the Apache icon in your system tray, left-click and from the Apache2.2 menu choose the “Restart” option to restart the Apache service. If all has gone well, Apache will restart just fine and you will have a play icon in your system tray icon once again. If you did not follow my guide to install Oracle XE, you will need to change the OwaUserid parameter in the text above to your own database’s connect identifier.
Once Apache has been restarted, mod_owa should now be running from http://localhost/somando. To test this, enter that address into your favourite web browser, and if mod_owa was installed you should see an error message like the one displayed in Figure 3j. If you see a different error message, you may not have installed mod_owa correctly.
The final thing we are going to do to make sure our Apache+PL/SQL setup is working correctly is create a sample application which performs a database SELECT and displays the output in a HTML table. Before we create the PL/SQL procedure to do this, let’s run the query from the SQL*Plus command line to see what data we should expect to appear in our sample app. To open SQL*Plus, go to Start -> Programs -> Oracle Database 10g Express Edition -> Run SQL Command Line. When the command line appears log on by typing CONNECT and pressing Enter. When prompted, enter your database username and password (Username: somando Password: somando1 if you followed our Oracle XE installation guide) and as soon as you are connected, enter the SQL statement from Listing 3b to query the database.
SELECT INITCAP(LOWER(object_type)) type, COUNT(*) count FROM all_objects GROUP BY object_type;
Listing 3b: Query all_objects table by object_type
You should see a result similar to that illustrated in Figure 3j:
Now we are going to create a PL/SQL procedure that will output this data to a HTML table that we can access using our web browser. From the SQL Command Line, enter the command ed test_page. Notepad will open and say that it cannot find the test_page.sql file, asking if you would like to create a new file. Click on the “Yes” button, and paste the text from Listing 3c into the Notepad window:
CREATE OR REPLACE PROCEDURE test_page IS CURSOR get_data IS SELECT INITCAP(LOWER(object_type)) type, COUNT(*) count FROM all_objects GROUP BY object_type; BEGIN htp.p('<table border="1">'); htp.p('<tr><th>Type:</th><th>Count:</th></tr>'); FOR i IN get_data LOOP htp.p('<tr><td>'||i.type||'</td><td>'||i.count||'</td></tr>'); END LOOP; htp.p('</table>'); END test_page; /
Listing 3c: Create test_page PL/SQL Procedure
When you have pasted the above code into Notepad, click on File -> Save and then quit Notepad. Back in the SQL Command Line, you should have an SQL prompt. Here, enter the command @test_page to run the script we just created. If all goes according to plan, you should see a message “Procedure created”. We can now test this procedure from our web browser by navigating to http://localhost/somando/test_page which should display something like what you see in Figure 3k below:
That’s it! You are now ready to start developing PL/SQL web applications. In our next tutorial I will look at installing Oracle SQL Developer and how to set up a development environment for PL/SQL web application programming. Very shortly I will be writing tutorials on creating some neat web applications in PL/SQL.
Click here to view a printer friendly version of this tutorial. To download this tutorial to disk, right click here and choose “Save Target As” or “Save Link As”. You will need Adobe Reader to open this file.














