nginx.conf 里面的 主服务器设置
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html; -->这里就指定documentroot目录为html,加绝对路径可以,不加也可
index index.html index.htm;
stub_status on; -->这个是用来查看nginx的运行状态数(还不是太清楚他的数据怎么看,看清楚再说)
}
nginx.conf 里面的使用fpm来调用php和fastcgi
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000; ---这个要跟fpm.conf里面的
Valid syntax is 'ip.ad.re.ss:port' or just 'port' or '/path/to/unix/socket'
127.0.0.1:9000对上
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; --这个东西就是fastcgi_params文件里面没有的那一个目录项,他这里帮咱们提出来做赋值了,不过优先级别里面是include的比较高,所以这里可以删除,当然你也可以将全部变量写到nginx.conf里面,不过这样既不好看也不方便
include fastcgi_params; --->这个就是类似apache的include功能,默认是以conf/目录做相对路径
}
这个是nginx目录下的fastcgi_params文件(这个文件就是将变量进行赋值)
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
这里的默认文件并没有,要自行添加,nginx是根据url来判断,以/开始 /表示www的目录,就是apache
里面的documentroot,这这个为基础,配合各种各样的regular正则来寻址,你可以写绝对路径的目录
例如 /server/www$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS 200;
fpm安装完成后 (其实是php的编译前打上fpm的补丁,在编译的时候增加fpm的参数)
要将 Unix user of processes
nobody
Unix group of processes
nobody
这2个的注释去掉,不然就会提示
root@yuan:/server/nginx/html# /server/php/sbin/php-fpm start
Starting php_fpm Sep 11 17:12:07.248390 [ERROR] fpm_unix_conf_wp(), line 124: please specify user and group other than root, pool 'default'
done
阅读(1699) | 评论(2) | 转发(0) |