Tutorial

How To Install OpenX On Ubuntu 12.10

Published on March 29, 2013
author

Bulat Khamitov

How To Install OpenX On Ubuntu 12.10

Introduction

OpenX is a popular advertisement server written in PHP. It has a web interface that allows you to easily manage your ad campaigns and track statistics.

Step 1 - Create A Domain Name

Having a domain name is essential. If you would like to get a free domain, you can get one from dot.tk.

For our purposes, we will register a free domain, cloudads.tk and point it to DigitalOcean name servers:

ns1.digitalocean.com (69.55.55.74)
ns2.digitalocean.com (141.0.175.217)

Step 2 - Spin Up A New Droplet and Configure DNS

Spin up a Ubuntu 12.10 x64 droplet with at least 1GB of RAM and 1 CPU Core. As your OpenX server grows, it would be best to separate database from webserver, and scale them up separately.

If you are just starting out, a single server would be sufficient for both.

We should also add some SWAP memory, and for our droplet we'll add 2 GB:

dd if=/dev/zero of=/swap bs=1024 count=2097152
mkswap /swap && chown root. /swap && chmod 0600 /swap && swapon /swap
echo /swap swap swap defaults 0 0 >> /etc/fstab
echo vm.swappiness = 0 >> /etc/sysctl.conf && sysctl -p

Now head over to DigitalOcean's Control Panel and click DNS (under Labs):

Click "Add Domain" and select the droplet you just created:

Step 3 - Install Packages

apt-get install nginx mysql-server php5 php5-mysql php5-fpm php5-gd

When prompted for MySQL root password, enter your own value, we will choose "PassWord":

Edit /root/.my.cnf and add the following lines:

[client]
user=root
pass=PassWord

Step 4 - Setup Database and Create User

Now you can connect to MySQL server, and also run command-line commands. We should create a new database and user. Make sure to change to your own PassWord value:

mysqladmin create openx
mysql -Bse "create user 'openx'@'localhost' identified by 'PassWord'"
mysql -Bse "grant all privileges on \`openx\`.* to 'openx'@'localhost'"
mysqladmin flush-privileges

Step 5 - Configure Nginx and PHP5-FPM

Set date.timezone "America/New_York" for New York datacenter, or "Europe/Amsterdam" for Amsterdam datacenter:

echo "date.timezone=America/New_York" >> /etc/php5/fpm/php.ini

Edit your Nginx config and add the following lines to /etc/nginx/sites-available/default (modify server_name and folders for your own domain):

server {

        root /usr/share/nginx/www/cloudads.tk;
        index index.html index.htm index.php;
        server_name cloudads.tk www.cloudads.tk;

        location / {
                try_files $uri $uri/ /index.html;
        }

        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }
}


Step 6 - Install OpenX

cd /usr/share/nginx/www
mkdir cloudads.tk
wget http://download.openx.org/openx-2.8.10.tar.bz2
tar jxvf openx-2.8.10.tar.bz2
mv openx-2.8.10/* cloudads.tk/
service nginx start && service php5-fpm restart

Make sure to set correct folder permissions:

chmod -R a+w /usr/share/nginx/www/cloudads.tk/var
chmod -R a+w /usr/share/nginx/www/cloudads.tk/var/cache
chmod -R a+w /usr/share/nginx/www/cloudads.tk/var/plugins
chmod -R a+w /usr/share/nginx/www/cloudads.tk/var/templates_compiled
chmod -R a+w /usr/share/nginx/www/cloudads.tk/plugins
chmod -R a+w /usr/share/nginx/www/cloudads.tk/www/admin/plugins
chmod -R a+w /usr/share/nginx/www/cloudads.tk/www/images

Navigate over to your droplet's IP address or domain if it has already propagated. You should see the OpenX Installer:

In this next step you will be prompted to register for OpenX.org account:

It seems to be timing out for us, so we can skip this step by temporarily disabling outgoing SSL connections and trying any username/password

You would have to add the following iptables rules and restart PHP5-FPM:

iptables -I OUTPUT 1 -p tcp --dport 443 -j REJECT
service php5-fpm restart

Now you can start over by navigating to http://cloudads.tk but when you get to Step "2.Registration" simply enter any username/password (test/test for example):

And since outbound SSL connections are blocked, OpenX will be unable to verify your credentials, and offer you to skip this step:

You can register for OpenX Market at http://pc.openx.com/ or your OpenX Admin Panel (My Account -> OpenX Market -> Get Started).

In this next step, you will enter OpenX database credentials that we set in Step 4.

Now you will create an OpenX Admin account, make sure to pick a password with a large character set:

This is the last step in Installation process, where all configuration files are created:

Step 7 - Disable your Dashboard and Allow Outgoing SSL Connections:

sed -i 's/dashboardEnabled.*$/dashboardEnabled=0/' /usr/share/nginx/www/cloudads.tk/var/cloudads.tk.conf.php
iptables -D OUTPUT 1

Now you can login to your OpenX Admin Panel:

And you are all done!

By Bulat Khamitov

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors
Default avatar
Bulat Khamitov

author

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
3 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

It seems like Open X has removed most or all of its documentation about the open source version of its software. Is it not longer available?

Bulat
DigitalOcean Employee
DigitalOcean Employee badge
August 19, 2013

nepto, OpenX dashboard creates a security vulnerability, and it is highly recommended to disable it on all OpenX installations.

Why should I disable dashboard? Does not make a sence for me :)

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more