When using uwsgi to render python on nginx, you may use the following command: 
uwsgi --socket mysite.sock --wsgi-file mysite/wsgi.py --chmod-socket=664

Well, you may encounter an exception: ImportError: No module named django.core.handlers.wsgi
*** Operational MODE: single process ***
*** no app loaded. going in full dynamic mode ***
*** uWSGI is running in multiple interpreter mode ***
spawned uWSGI master process (pid: 1838)
spawned uWSGI worker 1 (pid: 1839, cores: 1)
Traceback (most recent call last):
  File "./mysite.py", line 7, in <module>
    import django.core.handlers.wsgi
ImportError: No module named django.core.handlers.wsgi
unable to load app SCRIPT_NAME=django.udm.local|

Well, the solution is simple. 

I've changed the mysite.py file and added the paths to django and the python libs
import os, sys

sys.path.append(os.path.dirname(__file__))
sys.path.append('/usr/lib/python2.7/dist-packages')

os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import django.core.handlers.wsgi

application = django.core.handlers.wsgi.WSGIHandler()

Another problem you may also encounter is : 
2014/01/31 23:59:50 [crit] 10016#0: *8 connect() to unix:///home/zheng/Downloads/testdjango/testdjango.sock failed (13: Permission denied) 

Just change user to www-data if your nginx set the user to www-data. The corresponding command is : 
sudo su www-data






Drupal Clean URLs with NGINX

Nginx provides powerful rewrite commands in the servers' configuration, so it is flexible in its support for Clean URLs. The recommended settings from the Nginx Drupal Documentation are:
server {
     listen       80;
     server_name  example.org;
     location / {
         root   /path/to/drupal;
         index  index.php;
         error_page 404 = @drupal;
     }
     location @drupal {
         rewrite ^(.*)$ /index.php?q=$1 last;
     }
}
The key change is with the 404 line under location / and the location @drupalconfiguration section. This works by assuming that anything that isn't a reference to a specific file should be handled by Drupal via the rewrite rule.
Of course, you have to enable PHP by inserting the following codes:
        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                # fastcgi_pass 127.0.0.1:9000;
                # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }

If you are looking for more information about installing Nginx, see Installing Nginx With PHP5 (And PHP-FPM) And MySQL Support (LEMP) On Ubuntu 12.04 LTS.

Posted by Jeffye | 10:10 AM

Clean URLs with NGINX

Nginx provides powerful rewrite commands in the servers' configuration, so it is flexible in its support for Clean URLs. The recommended settings from the Nginx Drupal Documentation are:
server {
     listen       80;
     server_name  example.org;
     location / {
         root   /path/to/drupal;
         index  index.php;
         error_page 404 = @drupal;
     }
     location @drupal {
         rewrite ^(.*)$ /index.php?q=$1 last;
     }
}
The key change is with the 404 line under location / and the location @drupalconfiguration section. This works by assuming that anything that isn't a reference to a specific file should be handled by Drupal via the rewrite rule.
If you are looking for more information about installing Nginx, see Installing Nginx With PHP5 (And PHP-FPM) And MySQL Support (LEMP) On Ubuntu 12.04 LTS.

The following method will get you started fast on Ubuntu 12.04;
sudo apt-get install php5-common php5-cli php5-fpm
sudo apt-get install nginx
sudo service nginx start
Test that it's working (should see "Welcome to nginx!")
sudo service nginx stop
In your nginx site configuration (/etc/nginx/sites-available/default), uncomment the lines in the server {} section starting with
listen for ipv4 / ipv6 both.
scroll down to where it says "location ~ .php {" and uncomment lines so it looks like this:
location ~ \.php$ {
  fastcgi_split_path_info ^(.+\.php)(/.+)$
  fastcgi_pass 127.0.0.1:9000;
  fastcgi_index index.php;
  include fastcgi_params;
}
sudo service php5-fpm restart sudo service nginx restart
Your default web root is located at /usr/share/nginx/www (per the config file). (See root /usr/share/nginx/www;
(Note1: For Ubuntu 12.10 or newer, you will need to replace the fastcgi_pass 127.0.0.1:9000; line with this to make it work: fastcgi_pass unix:/var/run/php5-fpm.sock;)
Note2:  remember to include "index.php" as follows: 
index index.html index.htm index.php;

When my installation of phpMyAdmin was interrupted, I had the problem as shown in the title:

This solved it for me:

sudo rm -rf /var/cache/debconf/*
sudo apt-get install -f


update Git on old Ubuntu version, like ubuntu 9.10

1. The first thing to do is to install all dependencies.

Install required packages:
1.sudo apt-get install libcurl4-gnutls-dev libexpat1-dev libssl-dev gettext libz-dev asciidoc

2. Download git 1.8 and install as follows:

wget git-core.googlecode.com/files/git-1.8.1.1.tar.gz
tar -zxf git-1.8.1.1.tar.gz
cd git-1.8.1.1
make prefix=/usr/local all
sudo make prefix=/usr/local install


That's it.






Popular Posts