fatsandwich 发表于 2011-12-20 09:48

nginx在fedora上的安装

<meta charset="utf-8"><span class="Apple-style-span" style="color: rgb(51, 51, 51); font-family: 'Lucida Grande', Verdana, Geneva, sans-serif, 宋体; font-size: 14px; "><div id="content" style="margin-top: 20px; margin-right: 40px; margin-bottom: 0px; margin-left: 40px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">原理:<br>安装nginx没什么好说的,安装php-cig,让lighthttp的spawn-fcgi对其进行管理<br>1.用yum仓库安装所需的软件<br>#yum install –y php php-cgi&nbsp;&nbsp;nginx&nbsp;<span style="color: rgb(51, 51, 51); ">lighttpd-fastcgi</span><br><span style="color: rgb(51, 51, 51); ">2.生成php-cgi的环境变量配置文件</span><br><span style="color: rgb(51, 51, 51); "><span style="color: rgb(0, 0, 0); "># vim /etc/nginx/fastcgi_params</span></span><br><span style="color: rgb(51, 51, 51); "><span style="color: rgb(0, 0, 0); ">输入以下内容,并把该文件设置为相应属性,可以设置为0777</span></span><br><br><span style="color: rgb(0, 0, 0); ">astcgi_param GATEWAY_INTERFACE CGI/1.1;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param SERVER_SOFTWARE nginx;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param QUERY_STRING $query_string;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param REQUEST_METHOD $request_method;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param CONTENT_TYPE $content_type;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param CONTENT_LENGTH $content_length;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param SCRIPT_NAME $fastcgi_script_name;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param REQUEST_URI $request_uri;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param DOCUMENT_URI $document_uri;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param DOCUMENT_ROOT $document_root;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param SERVER_PROTOCOL $server_protocol;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param REMOTE_ADDR $remote_addr;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param REMOTE_PORT $remote_port;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param SERVER_ADDR $server_addr;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param SERVER_PORT $server_port;</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param SERVER_NAME $server_name;</span><br><span style="color: rgb(0, 0, 0); "># PHP only, required if PHP was built with –enable-force-cgi-redirect</span><br><span style="color: rgb(0, 0, 0); ">fastcgi_param REDIRECT_STATUS 200;</span><br>3.使用<span style="color: rgb(0, 0, 0); ">spawn-fcgi来控制php-fastcgi的进程</span><br><br># /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 200 -u nginx -g nginx -f /usr/bin/php-cgi<br><br>其中,a绑定的地址,p是端口 -C是PHPCGI的进程数,一般根据自己<span id="rlt_2" style="cursor: pointer; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(250, 137, 27); ">服务</span>器的内存大小设置,4G服务器,如果是纯WEBSERVER的,可以设置200左右<br>4.增加server<br><span style="color: rgb(0, 0, 0); "># vim /etc/nginx/nginx.conf</span><br>server{<br>&nbsp;&nbsp;listen 80;<br>&nbsp;&nbsp;server_name pylong.com&nbsp;<a href="http://www.pylong.com/" target="_blank" id="url_1" style="color: rgb(1, 52, 197); background-color: transparent; text-decoration: none; font-weight: normal; "><span style="color: rgb(0, 136, 204); ">www.pylong.com</span></a>;#多个域名,用空格分开<br>&nbsp;&nbsp;index index.html index.php index.htm;<br>&nbsp;&nbsp;root /var/www/pylong.com;<br>&nbsp;&nbsp;location ~ .*.php$<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;include /etc/nginx/fastcgi_params;<br>&nbsp;&nbsp;fastcgi_pass 127.0.0.1:9000;<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;}<br>一些更加详细的conf设置请参看nginx的维基,以及相关资料<br>一些提示:<br>yum安装的nginx,相关命令:servie nginx start|stop|reload<br>把nginx添加到系统<span id="rlt_1" style="cursor: pointer; border-bottom-width: 1px; border-bottom-style: solid; border-bottom-color: rgb(250, 137, 27); ">启动</span>项里:chkconfig nginx on<br><br>其中,a绑定的地址,p是端口 -C是PHPCGI的进程数,一般根据自己服务器的内存大小设置,4G服务器,如果是纯WEBSERVER的,可以设置200左右<br>4.增加server<br><span style="color: rgb(0, 0, 0); "># vim /etc/nginx/nginx.conf</span><br>server{<br>&nbsp;&nbsp;listen 80;<br>&nbsp;&nbsp;server_name pylong.com&nbsp;<a href="http://www.pylong.com/" target="_blank" id="url_2" style="color: rgb(1, 52, 197); background-color: transparent; text-decoration: none; font-weight: normal; "><span style="color: rgb(0, 136, 204); ">www.pylong.com</span></a>;#多个域名,用空格分开<br>&nbsp;&nbsp;index index.html index.php index.htm;<br>&nbsp;&nbsp;root /var/www/pylong.com;<br>&nbsp;&nbsp;location ~ .*.php$<br>&nbsp;&nbsp;{<br>&nbsp;&nbsp;include /etc/nginx/fastcgi_params;<br>&nbsp;&nbsp;fastcgi_pass 127.0.0.1:9000;<br>&nbsp;&nbsp;}<br>&nbsp;&nbsp;}<br>一些更加详细的conf设置请参看nginx的维基,以及相关资料<br>一些提示:<br>yum安装的nginx,相关命令:servie nginx start|stop|reload<br>把nginx添加到系统启动项里:chkconfig nginx on<br><br>让<span style="color: rgb(0, 0, 0); ">spawn-fcgi随系统自动启动。</span><br><span style="color: rgb(0, 0, 0); ">vim /etc/rc.loal</span><br><span style="color: rgb(0, 0, 0); ">在文件最后加上</span><br># /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 200 -u nginx -g nginx -f /usr/bin/php-cgi<br>如果php的session不可用,一般是因为 /var/lib/php/session这个目录的对于nginx不可写,把它所有者改为nginx相应用户已经用户组<br><br>转载请注明地址:<a href="http://www.pylong.com/?p=6" target="_blank" id="url_3" style="color: rgb(1, 52, 197); background-color: transparent; text-decoration: none; font-weight: normal; ">http://www.pylong.com/?p=6</a><br></div><div id="footer" style="background-color: transparent; font-size: 12px; padding-top: 16px; padding-right: 0px; padding-bottom: 15px; padding-left: 0px; margin-top: 20px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; text-align: center; "></div></span>
               
               
               
               
页: [1]
查看完整版本: nginx在fedora上的安装