这是我用标准的nginx.conf做的
如果我使用端口boo.dev:8060我没有问题,但如果我做localhost或它的别名它总是下载的东西?
我似乎无法设置虚拟主机名称,只是让它工作。
感谢您的任何build议。
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; error_log /var/log/nginx-error.log debug; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; # include /usr/local/etc/nginx/conf.d/*.conf; 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 logs/access.log main; error_log /var/log/nginx-error.log debug; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server{ listen 80; #listen njsphp.dev; root /Users/redres/Webdev/nodejsphp; index index.phtml; server_name localhost njsphp.dev; location / { } location = /favicon.ico { log_not_found off; access_log off; } } server { listen 8060; # server_name localhost; server_name boo.dev; #charset koi8-r; #access_log logs/host.access.log main; location / { # root html; root /Users/redres/Webdev/nodejsphp; index index.html index.php index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { # root html; root /Users/redres/Webdev/nodejsphp; #fastcgi_pass 127.0.0.1:9000; fastcgi_pass unix:/tmp/php-fpm.socket; fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
我猜这个端口是一个红鲱鱼,具体问题是你的浏览器不知道如何处理一个.phtml后缀的文件。
当你在每个端口上运行服务器时,你可以发布curl输出来排除吗?
像这样的东西可能是有益的:
$ curl -v http://localhost/ $ curl -v http://boo.dev/
(例如,你可能会看到端口80上的Apache的响应,如果这已经在听..?)
它发送一个八位字节stream,因为它不知道一个phtml文件是什么。
将phtml添加到文本/ html行中的mime.types文件,以便发送正确的MIMEtypes:
第二个服务器块不指向一个phtml文件,因此你不会得到下载。
text/html html htm shtml phtml;
然后它应该发送一个头,您的浏览器将喜欢显示,而不是下载。