forked from 0x2620/pandora
update readme, dont use __PREFIX__ in apache/nginx config
This commit is contained in:
parent
134d340790
commit
d658da92c8
4 changed files with 125 additions and 95 deletions
188
README
188
README
|
@ -1,20 +1,28 @@
|
||||||
pan.do/ra - open media archive
|
pan.do/ra - open media archive
|
||||||
|
|
||||||
|
for more information on pan.do/ra visit our website at https://pan.do/ra
|
||||||
|
|
||||||
== SETUP ==
|
== SETUP ==
|
||||||
pan.do/ra is known to work with Ubuntu 12.04, older versions of
|
pan.do/ra is known to work with Ubuntu 12.04,
|
||||||
Ubuntu or other distributions should also work.
|
but other distributions should also work.
|
||||||
|
The instructions below are for Ubuntu 12.04.
|
||||||
|
All commans given expect that you are root.
|
||||||
|
|
||||||
To setup pan.do/ra, you need python, bazaar, pip and virtualenv
|
To run pan.do/ra you need to install and setup:
|
||||||
and several other python modules:
|
python
|
||||||
|
postgres
|
||||||
|
nginx (or apache2)
|
||||||
|
additinal video packages
|
||||||
|
|
||||||
* Packages
|
|
||||||
(add pandora ppa to get all packages in the required version)
|
* Installing required packages
|
||||||
|
1) add pandora ppa to get all packages in the required version
|
||||||
|
|
||||||
apt-get install python-software-properties
|
apt-get install python-software-properties
|
||||||
add-apt-repository ppa:j/pandora
|
add-apt-repository ppa:j/pandora
|
||||||
apt-get update
|
apt-get update
|
||||||
|
|
||||||
(install dependencies)
|
2) install all required packages
|
||||||
apt-get install bzr git subversion mercurial \
|
apt-get install bzr git subversion mercurial \
|
||||||
python-setuptools python-pip python-virtualenv ipython \
|
python-setuptools python-pip python-virtualenv ipython \
|
||||||
python-dev python-imaging python-numpy python-psycopg2 \
|
python-dev python-imaging python-numpy python-psycopg2 \
|
||||||
|
@ -24,8 +32,28 @@ and several other python modules:
|
||||||
ffmpeg2theora ffmpeg \
|
ffmpeg2theora ffmpeg \
|
||||||
python-ox oxframe
|
python-ox oxframe
|
||||||
|
|
||||||
* Pan.do/ra
|
|
||||||
Get code from bazzar
|
* Prepare Environment
|
||||||
|
1) add pandora user and set permissions
|
||||||
|
adduser pandora --disabled-login --disabled-password
|
||||||
|
|
||||||
|
2) Setup Database
|
||||||
|
su postgres
|
||||||
|
createuser pandora
|
||||||
|
createdb -T template0 --locale=C --encoding=UTF8 -O pandora pandora
|
||||||
|
echo "CREATE EXTENSION pg_trgm;" | psql pandora
|
||||||
|
exit
|
||||||
|
|
||||||
|
3) Setup RabbitMQ
|
||||||
|
Important: "use_your_own" is a password and you have to use the same value here and below for BROKER_PASSWORD
|
||||||
|
|
||||||
|
rabbitmqctl add_user pandora use_your_own
|
||||||
|
rabbitmqctl add_vhost /pandora
|
||||||
|
rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*"
|
||||||
|
|
||||||
|
|
||||||
|
* Install Pan.do/ra
|
||||||
|
1) Get code from bazzar
|
||||||
cd /srv/
|
cd /srv/
|
||||||
bzr branch http://code.0x2620.org/pandora pandora
|
bzr branch http://code.0x2620.org/pandora pandora
|
||||||
cd pandora
|
cd pandora
|
||||||
|
@ -35,94 +63,86 @@ Get code from bazzar
|
||||||
cd static
|
cd static
|
||||||
bzr branch http://code.0x2620.org/oxjs
|
bzr branch http://code.0x2620.org/oxjs
|
||||||
|
|
||||||
create local_settings.py and create config.jsonc in /srv/pandora/pandora
|
cd /srv
|
||||||
do noy copy settings.py but only add your changes to local_settings.py
|
chown -R pandora.pandora pandora
|
||||||
(check https://wiki.0x2620.org/wiki/pandora/configuration
|
|
||||||
and use settings.py / config.jsonc / config.*.jsonc as example)
|
|
||||||
|
|
||||||
create and configure database as described below
|
2) create local_settings.py and config.jsonc
|
||||||
after that
|
|
||||||
|
|
||||||
create / update static files
|
1) create file /srv/pandora/pandora/local_settings.py with the following content:
|
||||||
|
|
||||||
./manage.py collectstatic -l --noinput
|
|
||||||
./manage.py update_static
|
|
||||||
./manage.py compile_pyc
|
|
||||||
|
|
||||||
* Database
|
|
||||||
We use postgresql but other databases might also work
|
|
||||||
(make sure you have the python bindings installed).
|
|
||||||
|
|
||||||
create a postgresql database
|
|
||||||
|
|
||||||
sudo -u postgres createdb -T template0 --locale=C --encoding=UTF8 -O pandora pandora
|
|
||||||
|
|
||||||
(setting locale to C is required to fix a bug in sort if set to UTF8)
|
|
||||||
|
|
||||||
now add settings to local_settings.py:
|
|
||||||
DATABASES = {
|
DATABASES = {
|
||||||
'default': {
|
'default': {
|
||||||
'NAME': 'pandora',
|
'NAME': 'pandora',
|
||||||
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
'ENGINE': 'django.db.backends.postgresql_psycopg2',
|
||||||
'USER': 'pandora',
|
'USER': 'pandora',
|
||||||
|
'PASSWORD': '',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DB_GIN_TRGM = True
|
||||||
|
BROKER_PASSWORD = "use_your_own"
|
||||||
|
|
||||||
and run ./manage.py syncdb to populate the database.
|
#with apache x-sendfile or lighttpd set this to True
|
||||||
|
XSENDFILE = False
|
||||||
|
|
||||||
Optionaly use pg_trgm to improve find speed (requires postgres 9.1 and postgresql-contrib)
|
#with nginx X-Accel-Redirect set this to True
|
||||||
|
|
||||||
echo "CREATE EXTENSION pg_trgm;" | sudo -u postgres psql pandora
|
|
||||||
./manage.py sqlfindindex | ./manage.py dbshell
|
|
||||||
echo "DB_GIN_TRGM = True" >> local_settings.py
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* RabbitMQ
|
|
||||||
For background tasks RabbitMQ is required, to install rabbitmq:
|
|
||||||
|
|
||||||
sudo apt-get install rabbitmq-server
|
|
||||||
|
|
||||||
and create permissions according to BROKER_* in local_settings.py i.e.:
|
|
||||||
|
|
||||||
sudo rabbitmqctl add_user pandora box
|
|
||||||
sudo rabbitmqctl add_vhost /pandora
|
|
||||||
sudo rabbitmqctl set_permissions -p /pandora pandora ".*" ".*" ".*"
|
|
||||||
|
|
||||||
|
|
||||||
* H264
|
|
||||||
for h264 videos, you need ffmpeg with x264 and libfaac enabled,
|
|
||||||
you also need to install qt-faststart (from ffmpeg/tools)
|
|
||||||
(you can use medibuntu.org packages or compile ffmpeg yourself)
|
|
||||||
to enable h264 derivatives add "mp4" to video.formats in your config.jsonc
|
|
||||||
|
|
||||||
|
|
||||||
== Deployment ==
|
|
||||||
* Install upstart scripts
|
|
||||||
check etc/init for upstart scripts, adjust path and user and put into /etc/init
|
|
||||||
|
|
||||||
To run pan.do/ra in production, we use nginx, using apache2 is also possible.
|
|
||||||
|
|
||||||
* nginx setup
|
|
||||||
sudo apt-get install nginx
|
|
||||||
|
|
||||||
add this to local_settings.py:
|
|
||||||
XACCELREDIRECT = True
|
XACCELREDIRECT = True
|
||||||
|
|
||||||
setup nginx according to etc/nginx/vhost.in
|
2) create config.jsonc
|
||||||
|
config.jsonc holds the configuration for your site.
|
||||||
|
To start you can copy /srv/pandora/pandora/config.pandora.jsonc
|
||||||
|
to /srv/pandora/pandora/config.jsonc but have a look at
|
||||||
|
https://wiki.0x2620.org/wiki/pandora/configuration and
|
||||||
|
config.0xdb.jsonc config.padma.jsonc for configuration options.
|
||||||
|
|
||||||
* apache2 setup
|
3) initialize database
|
||||||
apt-get install apache2-mpm-prefork libapache2-mod-xsendfile
|
su pandora
|
||||||
|
cd /srv/pandora/pandora
|
||||||
|
./manage.py syncdb --noinput
|
||||||
|
./manage.py sqlfindindex | ./manage.py dbshell
|
||||||
|
./manage.py collectstatic -l --noinput
|
||||||
|
./manage.py update_static
|
||||||
|
./manage.py compile_pyc
|
||||||
|
|
||||||
add this to local_settings.py:
|
4) install init scripts and start daemons
|
||||||
XSENDFILE = True
|
cp /srv/pandora/etc/init/*.conf /etc/init/
|
||||||
|
|
||||||
setup apache according to etc/apache2/vhost.in
|
|
||||||
|
|
||||||
now you can start pandora services:
|
|
||||||
service pandora start
|
service pandora start
|
||||||
service pandora-tasks start
|
|
||||||
service pandora-encoding start
|
service pandora-encoding start
|
||||||
|
service pandora-task start
|
||||||
|
|
||||||
|
5) Setup Webserver
|
||||||
|
a) nginx (recommended)
|
||||||
|
apt-get install nginx
|
||||||
|
cp /srv/pandora/etc/nginx/pandora /etc/nginx/sites-available/pandora
|
||||||
|
cd /etc/nginx/sites-enabled
|
||||||
|
ln -s ../sites-available/pandora
|
||||||
|
|
||||||
|
#read comments in /etc/nginx/sites-available/pandora for setting
|
||||||
|
#your hostname and other required settings
|
||||||
|
#make sure XACCELREDIRECT = True in /srv/pandora/pandora/local_settings.py
|
||||||
|
|
||||||
|
service nginx reload
|
||||||
|
|
||||||
|
b) apache2 (if you need it for other sites on the same server)
|
||||||
|
apt-get install apache2-mpm-prefork libapache2-mod-xsendfile
|
||||||
|
a2enmod xsendfile
|
||||||
|
cp /srv/pandora/etc/apache2/pandora.conf /etc/apache2/sites-available/pandora.conf
|
||||||
|
a2ensite pandora
|
||||||
|
|
||||||
|
#read comments in /etc/apache2/sites-available/pandora.conf for setting
|
||||||
|
#your hostname and other required settings
|
||||||
|
#make sure XSENDFILE = True in /srv/pandora/pandora/local_settings.py
|
||||||
|
|
||||||
|
service apache2 reload
|
||||||
|
|
||||||
|
|
||||||
|
Now you can open pandora in your browser, the first user to sign up will become admin.
|
||||||
|
|
||||||
|
|
||||||
|
* A note about providing H.264 versions
|
||||||
|
For H.264 videos, you need ffmpeg with x264 and libfaac enabled,
|
||||||
|
you also need to install qt-faststart (from ffmpeg/tools)
|
||||||
|
(you can use medibuntu.org packages or compile ffmpeg yourself)
|
||||||
|
to enable H.264 derivatives add "mp4" to video.formats in your config.jsonc
|
||||||
|
|
||||||
|
|
||||||
=== Updating ===
|
=== Updating ===
|
||||||
To update a pandora installation get the latest version from bzr by running
|
To update a pandora installation get the latest version from bzr by running
|
||||||
|
@ -131,11 +151,14 @@ To update a pandora installation get the latest version from bzr by running
|
||||||
this will update pandora/oxjs/python-ox and list possible upgrades to the db
|
this will update pandora/oxjs/python-ox and list possible upgrades to the db
|
||||||
|
|
||||||
to update your database tables, use
|
to update your database tables, use
|
||||||
|
su pandora
|
||||||
|
cd /srv/pandora/pandora
|
||||||
./manage.py sqldiff -a
|
./manage.py sqldiff -a
|
||||||
to check if there are changes and
|
to check if there are changes and
|
||||||
./manage.py sqldiff -a | ./manage.py dbshell
|
./manage.py sqldiff -a | ./manage.py dbshell
|
||||||
to apply them.
|
to apply them.
|
||||||
|
|
||||||
|
|
||||||
=== Development ===
|
=== Development ===
|
||||||
in one terminal:
|
in one terminal:
|
||||||
./manage.py runserver
|
./manage.py runserver
|
||||||
|
@ -143,3 +166,8 @@ to apply them.
|
||||||
and background task in another:
|
and background task in another:
|
||||||
./manage.py celeryd -B -Q celery,default,encoding
|
./manage.py celeryd -B -Q celery,default,encoding
|
||||||
|
|
||||||
|
now you can access your local pandora instace at http://127.0.0.1:8000/
|
||||||
|
|
||||||
|
we use virtual machines for development, you can get a vm from our site
|
||||||
|
or use the script in vm/build.sh to create one.
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
<VirtualHost *:80>
|
<VirtualHost *:80>
|
||||||
|
|
||||||
|
#ServerName pandora.YOURDOMAIN.COM
|
||||||
|
|
||||||
<Location />
|
<Location />
|
||||||
Options -Indexes
|
Options -Indexes
|
||||||
</Location>
|
</Location>
|
||||||
<Directory __PREFIX__>
|
<Directory /srv/pandora>
|
||||||
Order deny,allow
|
Order deny,allow
|
||||||
Allow from all
|
Allow from all
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
<Location />
|
<Location />
|
||||||
XSendFile on
|
XSendFile on
|
||||||
XSendFilePath __PREFIX__
|
XSendFilePath /srv/pandora
|
||||||
</Location>
|
</Location>
|
||||||
|
|
||||||
AddType video/webm webm
|
AddType video/webm webm
|
||||||
|
@ -26,11 +28,10 @@
|
||||||
ProxyPass /data !
|
ProxyPass /data !
|
||||||
ProxyPass /.bzr !
|
ProxyPass /.bzr !
|
||||||
|
|
||||||
|
Alias /.bzr /srv/pandora/.bzr
|
||||||
Alias /.bzr __PREFIX__/.bzr
|
Alias /static /srv/pandora/static
|
||||||
Alias /static __PREFIX__/static
|
Alias /favicon.ico /srv/pandora/static/favicon.ico
|
||||||
Alias /favicon.ico __PREFIX__/static/favicon.ico
|
Alias /data /srv/pandora/data
|
||||||
Alias /data __PREFIX__/data
|
|
||||||
|
|
||||||
ProxyPreserveHost On
|
ProxyPreserveHost On
|
||||||
ProxyPass / http://127.0.0.1:2620/
|
ProxyPass / http://127.0.0.1:2620/
|
|
@ -14,23 +14,24 @@ server {
|
||||||
#gzip_buffers 16 8k;
|
#gzip_buffers 16 8k;
|
||||||
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";
|
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";
|
||||||
|
|
||||||
|
#server_name pandora.YOURDOMAIN.COM;
|
||||||
|
|
||||||
listen 80 default;
|
listen 80 default;
|
||||||
#server_name pandora.example.com;
|
|
||||||
|
|
||||||
access_log /var/log/nginx/pandora.access.log;
|
access_log /var/log/nginx/pandora.access.log;
|
||||||
error_log /var/log/nginx/pandora.error.log;
|
error_log /var/log/nginx/pandora.error.log;
|
||||||
|
|
||||||
location /favicon.ico {
|
location /favicon.ico {
|
||||||
root __PREFIX__/static;
|
root /srv/pandora/static;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /static/ {
|
location /static/ {
|
||||||
root __PREFIX__;
|
root /srv/pandora;
|
||||||
autoindex on;
|
autoindex off;
|
||||||
}
|
}
|
||||||
location /data/ {
|
location /data/ {
|
||||||
internal;
|
internal;
|
||||||
root __PREFIX__;
|
root /srv/pandora;
|
||||||
}
|
}
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
|
@ -40,7 +41,7 @@ server {
|
||||||
proxy_read_timeout 90; #should be in sync with gunicorn timeout
|
proxy_read_timeout 90; #should be in sync with gunicorn timeout
|
||||||
proxy_connect_timeout 90; #should be in sync with gunicorn timeout
|
proxy_connect_timeout 90; #should be in sync with gunicorn timeout
|
||||||
if (!-f $request_filename) {
|
if (!-f $request_filename) {
|
||||||
proxy_pass http://127.0.0.1:2620;
|
proxy_pass http:/127.0.0.1:2620;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
client_max_body_size 32m;
|
client_max_body_size 32m;
|
||||||
|
@ -48,12 +49,12 @@ server {
|
||||||
|
|
||||||
error_page 404 /404.html;
|
error_page 404 /404.html;
|
||||||
location /404.html {
|
location /404.html {
|
||||||
root __PREFIX__/static/html;
|
root /srv/pandora/static/html;
|
||||||
}
|
}
|
||||||
|
|
||||||
# redirect server error pages to the static page /50x.html
|
# redirect server error pages to the static page /50x.html
|
||||||
error_page 500 502 503 504 /50x.html;
|
error_page 500 502 503 504 /50x.html;
|
||||||
location /50x.html {
|
location /50x.html {
|
||||||
root __PREFIX__/static/html;
|
root /srv/pandora/static/html;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -64,7 +64,7 @@ service pandora-tasks start
|
||||||
service pandora start
|
service pandora start
|
||||||
|
|
||||||
#nginx
|
#nginx
|
||||||
sed "s/__PREFIX__/\/srv\/pandora/g" "/srv/pandora/etc/nginx/vhost.in" > "/etc/nginx/sites-available/default"
|
cp "/srv/pandora/etc/nginx/pandora" "/etc/nginx/sites-available/default"
|
||||||
service nginx restart
|
service nginx restart
|
||||||
|
|
||||||
cat > /usr/local/bin/fixtime <<EOF
|
cat > /usr/local/bin/fixtime <<EOF
|
||||||
|
|
Loading…
Reference in a new issue