nginx安装方法:
debhttp://nginx.org/packages/debian/squeezenginx
deb-srchttp://nginx.org/packages/debian/squeezenginx
更新源列表并通过apt安装nginx
apt-keyaddnginx_signing.key
apt-getinstallnginx
2源码编译安装先安装编译环境,由于nginx在以后的使用中会需要用到perl正则、压缩算法、ssl等特性,所以我们需要提前安装相关库文件。
apt-getinstallbuild-essential
apt-getinstalllibpcre3libpcre3-devzlib1gzlib1g-devopenssllibssl-devlibssl0.9.8
tarzxvfnginx-1.2.3.tar.gz
#--help可以看到可以配置的参数
https://www.fruan.com/post/configure--help
编译安装
https://www.fruan.com/post/configure--prefix=/etc/nginx/--user=nginx--group=nginx--with-http_ssl_module--with-http_realip_module--with-http_addition_module
--with-http_sub_module--with-http_dav_module--with-http_flv_module--with-http_mp4_module--with-http_gzip_static_module
--with-http_random_index_module--with-http_secure_link_module--with-http_stub_status_module--with-file-aio--with-ipv6
php-fpm
php5.3版本源码已经默认支持php-fpm了,但是debian6认为它还没经过广泛的测试,所以在debian6的软件仓库中,虽然php版本为5.3.3,但是却没包含php-fpm,如果不想手工编译安装php的话可以换一个源。修改源列表
debhttp://packages.dotdeb.orgstableall
deb-srchttp://packages.dotdeb.orgstableall
更新源列表,安装php5-fpm
apt-getupdatewgethttp://www.dotdeb.org/dotdeb.gpg
catdotdeb.gpg|apt-keyadd-
apt-getinstallphp5-fpm
error_loglogs/error.log;
设置pid文件路径,可以使用kill命令发送相关信号
pidlogs/nginx.pid;
event模块配置选项,event模块主要控制nginx处理连接的方式
#如果在configure时指定的不止一个事件模型,可以通过use告诉nginx要使用哪一个模型:seletc、poll、kqueue、epoll、rtsig、/dev/poll、eventport等
#worker_connections和worker_processes可以计算你的理论最大链接数,worker_connections*worker_processes

default_typeapplication/octet-stream;
#描述记录日志的格式,在定义格式时可以使用一些变量,各个变了的含义可以从各个模块汇总查找
log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'
'$status$body_bytes_sent"$http_referer"'
'"$http_user_agent""$http_x_forwarded_for"';
#指定访问日志的路径和格式,缓冲区大小
access_loglogs/access.logmain;
#sendfile拷贝文件在内核态完成,更加高效
#可以设置两个值,第一个表示客户端与服务器长连接的超时时间,超过这个时间,服务器将关闭连接。第二个值指定的应答头中keep-alive中timeout的值,让浏览器知道什么时候关闭连接。
#在三次握手时,发送给客户端应答后的超时时间,目前还没进入连接状态,只完成了两次握手,如果在规定时间没收到应答包,nginx将关闭链接
#指定server字段中可以被访问到的ip地址及端口
#将http请求的主机头与server中的server_name参数进行匹配,并找出第一个结果,如果没有server_name参数匹配上,则第一个出现listen的server将被匹配,多域名用空格分割
server_namewww.nginx.com;
#设个指令是应答头重的content-type字段使用指定的编码集,off表示不在应答头重添加content-type信息
#指定www.nginx.com域名的访问日志路径及格式
access_loglogs/host.access.logmain;
#如果在url中没有指定文件,则设置一个默认主页,可以设置多个文件,空格分开,可以在http、server、location中设置
#根据url的不同需求进行配置,可以使用字符串和正则匹配,最确切的匹配被使用,搜索到第一个后会停止
#~*不区分大小写;~区分大小写;^~禁止在字符串匹配后检查正则;=在url和location之间精确匹配,匹配完成后不做额外搜索。
#请求到达后的文件根目录,在请求中root会把location匹配的值加到root指定的值后面,请求/i/a.php,则会是/html/i/a.php响应
indexindex.htmlindex.htm;
#为错误代码指定相应的错误界面,可以用在http、server、location字段中。
#redirectservererrorpagestothestaticpage/50x.html
error_page500502503504/50x.html;
#精确匹配50x.html,真实响应是/html/50x.html
#proxythephpscriptstoapachelisteningon127.0.0.1:80
proxy_passhttp://127.0.0.1;
fastcgi_pass127.0.0.1:9000;
#/scripts是php脚本所在的目录
fastcgi_paramscript_filename/scripts$fastcgi_script_name;
}
以上就是Debian系统下怎么为PHP程序配置Nginx服务器的详细内容,更多请关注主机测评网其它相关文章!
本文来源:国外服务器--debiannginxphp
本文地址:https://www.idcbaba.com/guowai/5478.html
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 1919100645@qq.com 举报,一经查实,本站将立刻删除。



