Eliminare la pagina wiki 'Server Configuration' è una operazione che non può essere annullata. Continuare?
Rophako uses the YamlSettings module for its configuration. There is a default settings file named defaults.yml
; use it for reference to see what options are available.
To configure your site, create a file named settings.yml
and define the keys/values that you want to override from the defaults. For example, if the only thing you want to change is the site’s name and secret key, the settings.yml
can look as simple as this:
rophako:
site:
site_name: new-site.com
security:
secret_key: helloworld123456
The default config is loaded by the app first and then your custom settings are masked on top, so you only need to include the settings you want to change in the settings.yml. The defaults file is thoroughly commented, so check it out.
For the web server side of things, see Apache and nginx configurations.
For simple sites you can configure Rophako to run as a mod_wsgi app.
In your Apache configuration:
<VirtualHost *:80>
ServerName www.example.com
WSGIDaemonProcess rophako user=www-data group=www-data threads=5 home=/home/www-data/git/rophako
WSGIScriptAlias / /home/www-data/git/rophako/app.wsgi
WSGIScriptReloading On
CustomLog /home/www-data/logs/access_log combined
ErrorLog /home/www-data/logs/error_log
<Directory /home/www-data/sites/rophako>
WSGIProcessGroup rophako
WSGIApplicationGroup %{GLOBAL}
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
A file named app.wsgi
is included in the git repo. Here it is for reference. You may need to make changes to it if you use a different virtualenv:
#!/usr/bin/env python
"""WSGI runner script for the Rophako CMS."""
import sys
import os
# Add the CWD to the path.
sys.path.append(".")
# Use the 'rophako' virtualenv.
activate_this = os.environ['HOME']+'/.virtualenv/rophako/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
from rophako import app as application
# vim:ft=python
For Kirsle.net I had a legacy document root full of random static files, so Rophako needed to serve the dynamic pages but let Apache serve all the legacy stuff.
Apache configuration:
# Rophako www.kirsle.net
<VirtualHost *:80>
ServerName www.kirsle.net
DocumentRoot /home/kirsle/www
CustomLog /home/kirsle/logs/access_log combined
ErrorLog /home/kirsle/logs/error_log
SuexecUserGroup kirsle kirsle
<Directory "/home/kirsle/www">
Options Indexes FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
<Directory "/home/kirsle/www/fcgi">
SetHandler fcgid-script
Options +ExecCGI
AllowOverride all
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
And in my .htaccess
file in my document root:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /fcgi/index.fcgi/$1 [QSA,L]
RewriteRule ^$ /fcgi/index.fcgi/ [QSA,L]
</IfModule>
And finally, my FastCGI script. Important things to note:
sys.path
and chdir
to my git checkout folder for Rophako.ScriptNameStripper
allows mod_rewrite
to work best. Without it you’ll sometimes get URL paths like /fcgi/index.fcgi/blog/entry/...
etc. from Flask because that’s what it thinks its path is.#!/home/kirsle/.virtualenv/rophako/bin/python
import os
import sys
sys.path.append("/home/kirsle/git/rophako")
os.chdir("/home/kirsle/git/rophako")
from flup.server.fcgi import WSGIServer
from rophako import app
class ScriptNameStripper(object):
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
environ["SCRIPT_NAME"] = ""
return self.app(environ, start_response)
app = ScriptNameStripper(app)
if __name__ == "__main__":
WSGIServer(app).run()
This is how to get it set up with nginx, supervisor and gunicorn.
Install supervisor and create a config file like /etc/supervisor/conf.d/rophako.conf
with these contents:
[program:rophako]
command = /home/www-data/.virtualenv/rophako/bin/gunicorn -b 127.0.0.1:9000 wsgi_gunicorn:app
environment = ROPHAKO_SETTINGS="/home/www-data/site/settings.ini"
directory = /home/www-data/git/rophako
user = www-data
Reload supervisor and start your app:
$ supervisorctl reread
$ supervisorctl reload
$ supervisorctl start rophako
Add your site to /etc/nginx/sites-available
with a config like this:
server {
server_name www.example.com example.com;
listen 80;
root /home/www-data/git/rophako;
location /static {
alias /home/www-data/www/static;
}
location /favicon.ico {
alias /home/www-data/www/favicon.ico;
}
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_pass http://127.0.0.1:9000;
}
}
Start or restart nginx, service nginx restart
Next Step: Configuration and Plugins
Eliminare la pagina wiki 'Server Configuration' è una operazione che non può essere annullata. Continuare?