Installing Elgg on NginxΒΆ

To run Elgg on Nginx, you will need to:

  • configure Nginx to talk to a PHP process in either CGI or FPM mode
  • Port the following rewrite rules
# Elgg Nginx configuration. Customize and put into /etc/nginx/sites-enabled

server {
	listen 80;
	server_name example.org;

	# Server root, replace it with your elgg installation location
	root /srv/example.org;
	index index.php index.html index.htm;

	# Server logs, replace it with your project names
	error_log /var/log/nginx/example_error.log;
	access_log /var/log/nginx/example_access.log;

	location ~ (^\.|/\.) {
		return 403;
	}

	location /cache {
		rewrite ^/cache\/(.*)$ /engine/handlers/cache_handler.php?request=$1&$query_string;
	}

	location /export {
		rewrite ^/export\/([A-Za-z]+)\/([0-9]+)\/?$ /engine/handlers/export_handler.php?view=$1&guid=$2;
		rewrite ^/export\/([A-Za-z]+)\/([0-9]+)\/([A-Za-z]+)\/([A-Za-z0-9\_]+)\/$ /engine/handlers/export_handler.php?view=$1&guid=$2&type=$3&idname=$4;
	}

	location = /rewrite.php {
		rewrite ^(.*)$ /install.php;
	}

	location / {
		try_files $uri $uri/ /index.php?__elgg_uri=$uri&$query_string;
	}

	# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
	#
	location ~ \.php$ {
		fastcgi_split_path_info ^(.+\.php)(/.+)$;
	#	# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
	#
	#	# With php5-cgi alone:
	#	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;
	}
}

Other than that, you should be able to follow the standard installation instructions.