Answer the question
In order to leave comments, you need to log in
What's wrong with configuring Nginx on MacOS X?
Friends, good afternoon.
Please help me figure it out, I've already broken my head. I'm setting up virtual hosts on a macbook to test a couple of CMSs locally. I follow the instructions to link via Homebrew: nginx+php-fpm+mysql
Localhost works fine:
localhost:~ user$ curl -IL http://localhost:80
HTTP/1.1 200 OK
Server: nginx/1.8.0
Date: Sun, 24 May 2015 12:39:19 GMT
Content-Type: text/html
Content-Length: 853
Last-Modified: Sun, 24 May 2015 08:15:56 GMT
Connection: keep-alive
ETag: "556188bc-355"
Accept-Ranges: bytes
localhost:~ user$ curl -IL http://site.local:80
HTTP/1.1 403 Forbidden
Server: nginx/1.8.0
Date: Sun, 24 May 2015 12:43:52 GMT
Content-Type: text/html
Content-Length: 168
Connection: keep-alive
worker_processes 1;
error_log /usr/local/etc/nginx/logs/error.log debug;
events {
worker_connections 1024;
}
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 /usr/local/etc/nginx/logs/access.log main;
sendfile on;
keepalive_timeout 65;
index index.html index.php;
include /usr/local/etc/nginx/sites-enabled/*;
}
server {
listen 80;
server_name site.local www.site.local;
root /Users/user/Dropbox/Sites/site.local;
# Enable compression, this will help if you have for instance advagg module
# by serving Gzip versions of the files.
gzip_static on;
# Block access to "hidden" files and directories whose names begin with a
# period. This includes directories used by version control systems such
# as Subversion or Git to store control files.
location ~ (^|/)\. {
return 403;
}
location / {
# This is cool because no php is touched for static content
include /usr/local/etc/nginx/conf.d/php-fpm;
try_files $uri @rewrite;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
Answer the question
In order to leave comments, you need to log in
server {
charset utf-8;
client_max_body_size 128M;
listen 80; ## listen for ipv4
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name site.local www.site.local;
root /Users/user/Dropbox/Sites/site.local;;
index index.php;
#Если нужно хранить логи nginx в папке проекта
#то создать указанные ниже файлы и раскомментировать
#access_log /Users/user/Dropbox/Sites/site.local/log/access.log;
#error_log /Users/user/Dropbox/Sites/site.local/error.log;
location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php?$args;
}
# uncomment to avoid processing of calls to non-existing static files by
#location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
# try_files $uri =404;
#}
#error_page 404 /404.html;
location ~ \.php$ {
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/php5-fpm.sock;
try_files $uri =404;
}
location ~ /\.(ht|svn|git) {
deny all;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question