OpenX Ad Server - Basics for Setup and Embedding an Ad on Drupal

Submitted by matthew on Sat, 2009-10-24 20:03

OpenX is an opensource adserver with similar functionality to other ad services. The difference is that you run the service yourself and it is free if you host it yourself.

I am often faced with Drupal clients who are interested in selling ad space on their sites but don't want to use a paid service, need more flexibility than the ad module available for Drupal, and don't want want to use a service like AdBrite or Google Ads.

This little tutorial will show you how to install the ad server on your localhost to play around with it. First off, you need some kind of *amp stack on your computer. I personally work on a Mac, so I use MAMP. This also means that the tutorial is Mac centric.

  1. Download the OpenX package here:
  2. Change the permissions on the openx/var folder, as well as the openx/www/images folder - they need to be writable. The easiest way to this is to right click on the directories in question choose "Get Info". From there, unlock the little lock icon at the bottom of the screen, you will need to enter your admin username and password.
  3. Fire up MAMP and click on "Open Start Page"
  4. Click on phpMyAdmin in the menu bar at the top of the page
  5. Click on the "databases" link in the main body of the page
  6. At the bottom of this page is a text box that reads "create new database", type in a name for your new database and choose a "collation", I used UTF8
  7. Create a user for the database--click on the sql tab up top and use the following command "grant all on database_name.* to user_name@localhost identified by 'password';" with no quotes and replacing database_name with the database, user_name with any name you care to put in, and password with an password you care to use
  8. Navigate to the OpenX directory. In my case, this redirects me to: http://localhost:8888/openx/www/admin/install.php
  9. Click Continue to go to the terms
    OpenX Ad Server
  10. Click on "Agree" at the bottom of the page.
    OpenX Ad Server
  11. OpenX will then check your system to make sure there are no issues. If all goes well there won't be any errors. Scroll to the bottom and click on "Continue"
    OpenX Ad Server
  12. Enter in your username, password, and database for the MySQL database that you just set up. Click Continue. An OpenX database will be created at this point. Click "Continue"
    OpenX Ad Server

    OpenX Ad Server
  13. On the configuration page, touch nothing. Click "Continue"
    OpenX Ad Server
  14. Create an Admin Account and click "Continue"
    OpenX Ad Server
  15. OpenX will then install plugins. Once that is finished, click "Continue"
    OpenX Ad Server
  16. At this point you are done. Click "Continue"
    OpenX Ad Server

Your ad server is up and running. The next steps that I took were to set up one campaign with one ad that would live in a Drupal block.

  1. Click on "Add Advertiser"
    OpenX Add Advertiser 10
  2. Enter your Advertiser Information
    OpenX enter Ad Info 11
  3. Click on "Add Campaign"
  4. For this exercise, choose a "Remnant" campaign. You don't really need to choose any options at this point. Click "Continue"
  5. Click on "Add Banner"
    OpenX add banner 13
  6. Enter the name, add the image, destination, target, alt text, status, text below the image, keywords, weight, and comments. Click "Save Changes"
    OpenX Upload a Banner 14
  7. Click on the "Websites" link.
    OpenX Websites 15
  8. Add a website to advertise on.
    OpenX Add the Website 16
  9. Add a zone.
  10. Enter the name, description, category, zone type, size, and a comment.
    OpenX Zone 17
  11. Add a "Targeting Channel"
    OpenX channel 18
  12. Choose "Direct Selection" and make selections there (don't enter anything in banner selection")- click refresh. It will give you a new banner code. Copy it.
    OpenX Direct select 19
  13. For the purpose of this exercise, go to your Drupal instance and go to the blocks menu admin/build/block/add and add a new block.
  14. Paste the ad code into the block body.
  15. Save the block and activate it. You should be displaying an ad at this point in that block.


Submitted by Per on Sun, 2009-10-25 04:44

OpenX is also available hosted for free on I'm using it with the OpenX module on my clients Idrottens Affärer and Civilekonomen. Easy setup and works like a charm!

Submitted by Anonymous (not verified) on Fri, 2009-11-20 15:28

I have been pulling my hair out trying to download OpenX. Thanks

Submitted by Anonymous (not verified) on Sun, 2010-01-31 22:49

All of these great step by step instructions are amazing. I can totally follow these and apply them to my own site.

Submitted by Anonymous (not verified) on Thu, 2010-02-25 04:00 also help you with various OpenX installation and integrations

Submitted by sureshpeters (not verified) on Thu, 2011-04-21 05:19

thanks dude for the precious post on openx :) it helps a lot

glqxz9283 sfy39587stf02 mnesdcuix8