Skip to content

Instantly share code, notes, and snippets.

@rianorie
Created November 3, 2014 23:13
Show Gist options
  • Save rianorie/f87a6864acc3d85721d6 to your computer and use it in GitHub Desktop.
Save rianorie/f87a6864acc3d85721d6 to your computer and use it in GitHub Desktop.
Magento nginx vhost
/etc/nginx/sites-available/example.com.conf
------------------------
server {
listen 80;
server_name example.com;
return 301 http://www.example.com$request_uri;
}
server {
listen 80;
server_name example2.com;
return 301 http://www.example2.com$request_uri;
}
server {
listen 80;
listen [::]:80;
root /var/www/example.com/web;
server_name www.example.com www.example2.com;
error_log /var/www/example.com/log/error.log;
include fastcgi_params;
## 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 / {
try_files $uri $uri/ /index.php$is_args$args;
}
# enable php
location ~ \.php$ {
fastcgi_pass php;
}
}
/etc/nginx/nginx.conf
----------------------------------
http {
upstream php {
server unix:/var/run/php5-fpm.sock;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment