apt-get -y dist-upgrade
mee too, didn't notice in the cut-paste madness.
--
if [ "$UID" != "0" ]; then...
--
--
--
ok, wait a second, I'll try with my VM. the previous traceback is due to the changes done to the certificate generation: I took them for granted but there must be an error somewhere.
edit: seen the "forget about the certificates" message right now. Investigating in your "job failed to start".
PS: can you post the output of /var/log/upstart/uwsgi-emperor.log ?
On Wednesday, December 12, 2012 7:48:54 PM UTC+1, Richard wrote:
--
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile \
/var/run/$NAME.pid --exec $DAEMON || true
sleep 1
test_nginx_config
# Check if the ULIMIT is set in /etc/default/nginx
if [ -n "$ULIMIT" ]; then
# Set the ulimits
ulimit $ULIMIT
fi
start-stop-daemon --start --quiet --pidfile \
/var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS || true
echo "$NAME."
;;
The following is an example configuration, to reduce the CPU load it is recommended to run one worker process only and to enable keep-alive connections:
worker_processes 1; http { server { listen 443; ssl on; ssl_certificate /usr/local/nginx/conf/cert.pem; ssl_certificate_key /usr/local/nginx/conf/cert.key; keepalive_timeout 70; } }
When using a chain of certificates, just append the extra certificates to your .crt file (cert.pem in the example). The server certificate needs to be the first on the file, otherwise you'll get a mismatch between private and public keys.
Since Nginx version 0.7.14 the preferred way of enabling SSL is by using the `ssl` parameter of the `listen` directive:
server { listen 443 default_server ssl; ssl_certificate /usr/local/nginx/conf/cert.pem; ssl_certificate_key /usr/local/nginx/conf/cert.key; ... }
--
*** uWSGI linking ***
gcc -pthread -o /usr/local/bin/uwsgi core/utils.o core/protocol.o core/socket.o core/logging.o core/master.o core/master_utils.o core/emperor.o core/notify.o core/mule.o core/subscription.o core/stats.o core/sendfile.o core/offload.o core/setup_utils.o core/clock.o core/init.o core/buffer.o core/plugins.o core/lock.o core/cache.o core/daemons.o core/queue.o core/event.o core/signal.o core/cluster.o core/rpc.o core/gateway.o core/loop.o lib/rbtree.o core/rb_timers.o core/uwsgi.o proto/base.o proto/uwsgi.o proto/http.o proto/fastcgi.o lib/linux_ns.o core/async.o core/ini.o core/yaml.o core/snmp.o core/xmlconf.o core/spooler.o plugins/python/python_plugin.o plugins/python/pyutils.o plugins/python/pyloader.o plugins/python/wsgi_handlers.o plugins/python/wsgi_headers.o plugins/python/wsgi_subhandler.o plugins/python/web3_subhandler.o plugins/python/pump_subhandler.o plugins/python/gil.o plugins/python/uwsgi_pymodule.o plugins/python/profiler.o plugins/python/symimporter.o plugins/python/tracebacker.o plugins/gevent/gevent.o plugins/ping/ping_plugin.o plugins/cache/cache.o plugins/nagios/nagios.o plugins/rrdtool/rrdtool.o plugins/carbon/carbon.o plugins/rpc/rpc_plugin.o plugins/corerouter/cr_common.o plugins/corerouter/cr_map.o plugins/corerouter/corerouter.o plugins/fastrouter/fastrouter.o plugins/http/http.o plugins/ugreen/ugreen.o plugins/signal/signal_plugin.o plugins/syslog/syslog_plugin.o plugins/rsyslog/rsyslog_plugin.o plugins/logsocket/logsocket_plugin.o plugins/router_uwsgi/router_uwsgi.o plugins/router_redirect/router_redirect.o plugins/router_basicauth/router_basicauth.o plugins/zergpool/zergpool.o plugins/redislog/redislog_plugin.o plugins/mongodblog/mongodblog_plugin.o plugins/router_rewrite/router_rewrite.o plugins/router_http/router_http.o plugins/logfile/logfile.o plugins/router_cache/router_cache.o plugins/rawrouter/rawrouter.o -lpthread -lm -rdynamic -ldl -lssl -lcrypto -L/usr/lib/x86_64-linux-gnu -lxml2 -lpthread -ldl -lutil -lm -L/usr/lib/python2.7/config -lpython2.7 -lcrypt
*** error linking uWSGI ***
----------------------------------------Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build/uwsgi/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lRnXgl-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build/uwsgi
Exception information:Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 107, in main status = self.run(options, args) File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 261, in run requirement_set.install(install_options, global_options) File "/usr/local/lib/python2.7/dist-packages/pip/req.py", line 1166, in install requirement.install(install_options, global_options) File "/usr/local/lib/python2.7/dist-packages/pip/req.py", line 589, in install cwd=self.source_dir, filter_stdout=self._filter_install, show_stdout=False) File "/usr/local/lib/python2.7/dist-packages/pip/util.py", line 612, in call_subprocess % (command_desc, proc.returncode, cwd))InstallationError: Command /usr/bin/python -c "import setuptools;__file__='/tmp/pip-build/uwsgi/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-lRnXgl-record/install-record.txt --single-version-externally-managed failed with error code 1 in /tmp/pip-build/uwsgi
--
@Simone, an other improvement to the script could be to combine into a single server the 80, and 443 to avoid duplicating configuration, as stated here :I don't had test this.Also, here the code for permanent redirectionserver {server_name $hostname;listen 80;return 301 https://$hostname$request_uri; # NOTE: I am not sure for $hostname here, because I didn't set hostname for my VM until now, as in the example (URL below) we can use domainName.com instead if properly configure in nginx
...}
--
--
--
--
If you remove those lines web2py will take charge for static files serving, so the issue will be temporarily fixed.location ~* /(\w+)/static/ {root /home/www-data/web2py/applications/;#remove next comment on production#expires max;}
is catching it as the app name and not the language "trick" . so, for a request going to /it/app/static/whatever.css is looking into
/home/www-data/web2py/applications/it/appname/static/whatever.css instead of ..... (remove the bold part, "it/").
--
myapp = dict(languages=['en', 'it', 'jp'], default_language='en')
location ~* /(\w+)/(en|it|jp)/static/(.*)$ {
alias /home/www-data/web2py/applications/$1/;
try_files static/$2/$3 static/$3 =404;
}
--
--
--
--
--
--
--
--
if not request.is_local:
from gluon.contrib.memcache import MemcacheClient
memcache_servers = ['127.0.0.1:11211']
cache.memcache = MemcacheClient(request, memcache_servers)
cache.ram = cache.disk = cache.memcache
--
I run uwsgi using the emperor mode for some time now.... based on my config I tried to upgrade the existing one. Result is available at https://www.dropbox.com/s/n7chteos9sh6p2h/setup-web2py-nginx-uwsgi-ubuntu.sh
I'm looking forward to improve things both on uwsgi niceties and general bash customization (the moment I saw fabric I almost stopped writing bash :-P)
Improvements:
- no uwsgi from debian packages (overcomplicated configurations). uwsgi is installed from pip (so you can upgrade with a simple pip install --upgrade uwsgi)
- optional response.static_version friendly static directories configuration (added also cache headers as an option)
- improved syntax for web2py.xml (no app, no plugin)
- example of uwsgi cron facility (clean sessions script included)
- uwsgi emperor mode, managed with Upstart
- optional upstart pre-script command to fix permissions and compress static files
If interested, I can make a fabfile for that.
<offtopic on> I use Redis as cache but for the "I love embedded" guys uwsgi has a cache framework. I'm accepting votes to make a uwsgi's cache compatible module for web2py, but you will have to test it (no time for that, sorry)
<offtopic off>