Compare Apache conf files and Nginx conf files

From www.ReeltoReel.nl Wiki
Jump to navigation Jump to search

APACHE:

Apache Nginx

<VirtualHost *:80> server {
listen 80;

ServerName yoursite.com
ServerAlias www.yoursite.com server_name yoursite.com www.yoursite.com;

DocumentRoot /path/to/root root /path/to/root;

AllowOverride All <span class=“highlight”>(No Available Alternative)</span>

DirectoryIndex index.php index index.php;

ErrorLog /path/to/log error_log /path/to/log error;

CustomLog /path/to/log combined access_log /path/to/log main;

Alias /url/ “/path/to/files” location /url/ {
<Directory “/path/to/files”> alias /path/to/files;

NGINX:

server {
listen 8000; # We’re deliberately leaving this as-is to avoid conflict at the moment

root /var/www;
server_name <span class="highlight">your_site.com</span> www.<span class="highlight">your_site.com</span>;

location / {
    try_files $uri $uri/ /index.html;
}

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

location /doc/ {
    alias /usr/share/doc/;
    autoindex on;
    allow 127.0.0.1;
    deny all;
}

location ~/\.ht {
    deny all;
}
}