nginx 配置

626 阅读1分钟

1 nginx预装在了路径 /export/servers/nginx

2 cd /export/servers/nginx

然后执行 ./sbin/nginx 启动nginx

如果报错 nginx: [emerg] mkdir() “/dev/shm/nginx_temp/client_body” failed (2: No such file or directory)

解决办法:mkdir -p /dev/shm/nginx_temp/client_body

3 启动之后,浏览器输入IP,即可访问,但是返回信息有误

Active connections: 1

server accepts handled requests

3 3 3

Reading: 0 Writing: 1 Waiting: 0

4 修改nginx.conf

server

{

listen 80;

server_name jcard-test.jd.com;

location / {

root /export/www;

index index.html;

try_files uriuri uri/ /index.html =404;

}

location /nginx-status {

access_log off;

stub_status off;

}

}

1 查看nginx路径

nginx -t 

2 配置返回json

location ~ ^/get_json {

default_type application/json;

return 200 '{"status":"success","result":"nginx json"}';

}