I recently rebuilt my FreeBSD instance and tried to switch from Apache to NGINX.
Now I followed the following great tutorial:
http://forums.freebsd.org/showthread.php?t=30268
But as mentioned there the servers are being configured from the nginx.conf file.
Now I entered the following in the nginx.conf file:
Created two folders (sites-available and sites-enabled), created two .conf files for both of my websites (Wordpress and OpenCart) and created the symbolic links in sites-enabled.
But it doesn't work like it should (can't get the configuration working).
Is there / are there any examples for this:
1. What a default nginx.conf should look like
2. How websitename.conf should look (in sites-available) for OpenCart (http://stackoverflow.com/questions/15625928/opencart-on-nginx)
3. How websitename.conf should look (in sites-available) for Wordpress
Any help would be great
My current configuration ->
nginx.conf
website 1
website 2
What am I doing wrong?
Now I followed the following great tutorial:
http://forums.freebsd.org/showthread.php?t=30268
But as mentioned there the servers are being configured from the nginx.conf file.
Now I entered the following in the nginx.conf file:
Code:
include /etc/nginx/conf.d/*.conf;
Created two folders (sites-available and sites-enabled), created two .conf files for both of my websites (Wordpress and OpenCart) and created the symbolic links in sites-enabled.
But it doesn't work like it should (can't get the configuration working).
Is there / are there any examples for this:
1. What a default nginx.conf should look like
2. How websitename.conf should look (in sites-available) for OpenCart (http://stackoverflow.com/questions/15625928/opencart-on-nginx)
3. How websitename.conf should look (in sites-available) for Wordpress
Any help would be great
My current configuration ->
nginx.conf
Code:
user www www;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use kqueue;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request "'
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#access_log /var/log/nginx/access.log main;
sendfile on;
autoindex off;
map $scheme $fastcgi_https { ## Detect when HTTPS is used
default off;
https on;
}
keepalive_timeout 10;
#gzip on;
#gzip_comp_level 2;
#gzip_proxied any;
#gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
# Load config files from the /etc/nginx/conf.d directory
include /etc/nginx/conf.d/*.conf;
}
website 1
Code:
server {
listen 80;
server_name URL.com;
root /var/www/opencart;
index index.php index.html;
location /image/data {
autoindex on;
}
location /admin {
index index.php;
}
location / {
try_files $uri @opencart;
}
location @opencart {
rewrite ^/(.+)$ /index.php?_route_=$1 last;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Make sure files with the following extensions do not get loaded by nginx because nginx would display the source code, and these files can contain PASSWORDS!
location ~* \.(engine|inc|info|install|make|module|profile|test|po|sh|.*sql|theme|tpl(\.php)?|xtmpl)$|^(\..*|Entries.*|Repository|Root|Tag|Template)$|\.php_ {
deny all;
}
# Deny all attempts to access hidden files such as .htaccess, .htpasswd, .DS_Store (Mac).
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location ~* \.(jpg|jpeg|png|gif|css|js|ico)$ {
expires max;
log_not_found off;
}
location ~ \.php$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
website 2
Code:
server {
server_name URL.com;
access_log /var/log/nginx/URL.com.access.log;
error_log /var/log/nginx/URL.com.error.log;
root /var/www/wordpress;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
}
}
What am I doing wrong?