How to install and use a BrowserShots server !
What will this page do for you
- Install browsershots locally (called shotserver)
- Install a screen shot factory (called shotfactory)
- Instructions instructions were tested in linux debian with these versions :
- Python 2.7.3
- Django 1.6.7 (link provided below)
- Browsershots latest version (2008) with my patches (link provided below)
You will create and store custom password for these instances :
- linux machine user.
- postgresql super user.
- django super admin.
= Installation / Setup =
1. Install django
UPDATE: Now use github to checkout django :
git clone -b 1.6.7 https://github.com/foligny/django django-1.6.7 cd django-1.6.7 sudo python setup.py install
2. Download browsershots server (shotserver)
cd .. git clone https://github.com/foligny/browsershots-psycopg2 cd browsershots-psycopg2/shotserver sudo python setup.py install
3. Get PostgreSQL and psycopg2 prerequisites
sudo apt-get install postgresql
sudo apt-get install python-psycopg2
The following post-install documentation is from the Postgre Official Documentation :
<< PostgreSQL is an object-relational database system that has the features of traditional commercial database systems with enhancements to be found in next-generation DBMS systems.
Once the installation is complete, you should configure the PostgreSQL server based on your needs, although the default configuration is viable.
Configuration
By default, connection via TCP/IP is disabled. PostgreSQL supports multiple client authentication methods. By default, IDENT authentication method is used for postgres and local users. Please refer the PostgreSQL Administrator's Guide.
The following discussion assumes that you wish to enable TCP/IP connections and use the MD5 method for client authentication. PostgreSQL configuration files are stored in the /etc/postgresql/{version}/main directory. For example, if you install PostgreSQL 8.3, the configuration files are stored in the /etc/postgresql/8.3/main directory.
[Tip]
To configure ident authentication, add entries to the /etc/postgresql/8.3/main/pg_ident.conf file.
To enable TCP/IP connections, edit the file /etc/postgresql/8.3/main/postgresql.conf
Locate the line #listen_addresses = 'localhost' and change it to:
listen_addresses = 'localhost'
[Note]
To allow other computers to connect to your PostgreSQL server replace 'localhost' with the IP Address of your server.
You may also edit all other parameters, if you know what you are doing! For details, refer to the configuration file or to the PostgreSQL documentation.
Now that we can connect to our PostgreSQL server, the next step is to set a password for the postgres user. Run the following command at a terminal prompt to connect to the default PostgreSQL template database:
sudo -u postgres psql template1
The above command connects to PostgreSQL database template1 as user postgres. Once you connect to the PostgreSQL server, you will be at a SQL prompt. You can run the following SQL command at the psql prompt to configure the password for the user postgres.
ALTER USER postgres with encrypted password 'your_password'; \q
After configuring the password, edit the file /etc/postgresql/8.3/main/pg_hba.conf to use MD5 authentication with the postgres user:
Change this line (this is *not* the first line but the second line of data)
local all all peer
To this :
local all all md5
Finally, you should restart the PostgreSQL service to initialize the new configuration. From a terminal prompt enter the following to restart PostgreSQL:
sudo /etc/init.d/postgresql restart
[Warning]
The above configuration is not complete by any means. Please refer the PostgreSQL Administrator's Guide to configure more parameters.
Resources
As mentioned above the Administrator's Guide is an excellent resource. The guide is also available in the postgresql-doc-8.3 package. Execute the following in a terminal to install the package:
sudo apt-get install postgresql-doc-8.3
To view the guide enter file:///usr/share/doc/postgresql-doc-8.3/html/index.html into the address bar of your browser.
Create a new user for browershot : bshotuser (note in original documentation the user is called www-data)
sudo -u postgres createuser bshotuser
Shall the new role be a superuser? (y/n) n
Shall the new role be allowed to create databases? (y/n) y
Shall the new role be allowed to create more new roles? (y/n) n
ALTER USER postgres with encrypted password 'your_password'; \q
Or on windows or command-line :
psql -U postgres -c "CREATE ROLE \"bshotuser\" LOGIN NOSUPERUSER INHERIT CREATEDB NOCREATEROLE;" shotserver04
psql -U postgres -c "ALTER USER \"bshotuser\" with encrypted password \"your_password\";" shotserver04
Create a new database :
sudo -u postgres createdb shotserver04 NOTE: You might get warning about "could not change directory to xyz" or "sudo: unable to resolve host xyz". The create operation will succeed anyway.
4. Complete the browsershot specific steps
Edit shotserver04/settings.py to put your database credentials
Let Django create the database tables for you:
cd shotserver/shotserver04
./manage.py syncdb
When it asks if you would like to create an admin account, say yes.
Create content folders
If you haven't changed the directories in settings.py, you need the following folders:
sudo mkdir -p /var/www/v04.browsershots.org/png
The png folder must be writable by the user running the server.
sudo chown www-data:www-data /var/www/v04.browsershots.org/png
== Now you have a running server ==
http://localhost:8000/
== Create a superuser ==
cd shotserver/shotserver04
./manage.py createsuperuser
*Note: You must restart the server after you createsuperuser*
{{{
sudo mkdir -p /var/www/v04.browsershots.org/png
}}}
The png folder must be writable by the user running the shotserver.
{{{
sudo chown admin:admin /var/www/v04.browsershots.org/png
}}}
For a production system, you don't want to use the development server that comes with Django. Here's how you set up Apache for Browsershots.
sudo apt-get install apache2 libapache2-mod-python
Create directory for log files:
sudo mkdir -p /var/log/apache2/v04.browsershots.org/
Enable mod_rewrite:
sudo a2enmod rewrite
Then put the following in /etc/apache2/sites-available/v04.browsershots.org:
ExtendedStatus On
NameVirtualHost *:80
ServerName browsershots.example.com # FQDN
ServerAlias browsershots # Local alias
ServerAdmin webmaster@example.com
ServerSignature On
LogLevel warn
ErrorLog /var/log/apache2/v04.browsershots.org/error.log
CustomLog /var/log/apache2/v04.browsershots.org/access.log combined
DocumentRoot /var/www/v04.browsershots.org
Options -Indexes
RewriteEngine On
RewriteBase /
# Force canonical hostname.
RewriteCond %{HTTP_HOST} !^browsershots.example.com(|:80)$
RewriteRule ^(.*)$ http://browsershots.example.com/$1 [R,L]
# Static files at server root
RewriteRule ^(favicon.ico|robots.txt)$ static/$1 [L]
# Force HTTPS for secure pages (uncomment next line to enable)
# RewriteRule ^(admin|accounts)(/.*)$ https://browsershots.example.com/$1$2 [R,L]
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE shotserver04.settings
PythonDebug Off
PythonAutoReload Off
SetHandler None
SetHandler None
SetHandler None
SetHandler server-status
Allow from all
# Local variables:
# mode: apache
# end:
Make sure that file is the first symlink in /etc/apache/sites-enabled and then restart Apache:
sudo a2dissite default
sudo a2ensite v04.browsershots.org
sudo apache2ctl restart
Create some symlinks for static content:
cd /var/www/v04.browsershots.org/
sudo ln -s /usr/lib/python2.5/site-packages/shotserver04/static
sudo ln -s /usr/lib/python2.5/site-packages/django/contrib/admin/media
Recent Comments