Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@hanhpv
Created September 15, 2016 07:55
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save hanhpv/3cf5192ef05d10b512e84d76fb905fac to your computer and use it in GitHub Desktop.
Save hanhpv/3cf5192ef05d10b512e84d76fb905fac to your computer and use it in GitHub Desktop.
Magento 1 nginx configuration
server { 
	listen 80; 
	root /Users/admin/htdocs/vax-uk;
	index index.php index.html index.htm;
	 
	server_name vax.local; 
	access_log /usr/local/etc/nginx/logs/vax_access.log;
	access_log /usr/local/etc/nginx/logs/vax_error.log;
	 
	## These locations would be hidden by .htaccess normally 
	location ^~ /app/                { deny all; } 
	location ^~ /includes/           { deny all; } 
	location ^~ /lib/                { deny all; } 
	location ^~ /media/downloadable/ { deny all; } 
	location ^~ /pkginfo/            { deny all; } 
	location ^~ /report/config.xml   { deny all; } 
	location ^~ /var/                { deny all; } 
	location /var/export/            { deny all; } 
	 
	# deny htaccess files 
	location ~ /\. { 
		deny  all; 
		access_log off; 
		log_not_found off; 
	} 
	 
	location ~*  \.(jpg|jpeg|png|gif|ico)$ { 
		expires 365d; 
		log_not_found off; 
		access_log off; 
	} 
	 
	location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler 
		rewrite ^(.*.php)/ $1 last; 
	}

	## rewrite anything else to index.php
	location / { 
		index index.html index.php;
		try_files $uri $uri/ /index.php?$query_string;
		expires 30d;
		rewrite /api/rest /api.php?type=rest;
	}
	 
	# pass the PHP scripts to FPM socket 
	location ~ \.php$ { 
		fastcgi_pass 127.0.0.1:9000;
		fastcgi_param MAGE_RUN_TYPE store;
		fastcgi_param  MAGE_RUN_CODE $MAGE_RUN_CODE;
		fastcgi_index index.php; 
		include fastcgi.conf; 
	}
}

map $http_host $MAGE_RUN_CODE {
    vax.local uk_default;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment