### nginx在fedora上的安裝
原理:
安裝nginx沒什么好說的,安裝php-cig,讓lighthttp的spawn-fcgi對其進行管理
1.用yum倉庫安裝所需的軟件
```
#yum install –y php php-cgi??nginx lighttpd-fastcgi
```
2.生成php-cgi的環境變量配置文件
```
# vim /etc/nginx/fastcgi_params
```
輸入以下內容,并把該文件設置為相應屬性,可以設置為0777
```
astcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
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;
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 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;
```
3.使用spawn-fcgi來控制php-fastcgi的進程
```
# /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 200 -u nginx -g nginx -f /usr/bin/php-cgi
```
其中,a綁定的地址,p是端口
-C是PHPCGI的進程數,一般根據自己服務器的內存大小設置,4G服務器,如果是純WEBSERVER的,可以設置200左右
4.增加server
```
# vim /etc/nginx/nginx.conf
server{
??listen 80;
??server_name pylong.com [www.pylong.com](http://www.pylong.com/);#多個域名,用空格分開
??index index.html index.php index.htm;
??root /var/www/pylong.com;
??location ~ .*.php$
??{
??include /etc/nginx/fastcgi_params;
??fastcgi_pass 127.0.0.1:9000;
??}
??}
```
一些更加詳細的conf設置請參看nginx的維基,以及相關資料
一些提示:
yum安裝的nginx,相關命令:servie nginx start|stop|reload
把nginx添加到系統啟動項里:chkconfig nginx on
其中,a綁定的地址,p是端口
-C是PHPCGI的進程數,一般根據自己服務器的內存大小設置,4G服務器,如果是純WEBSERVER的,可以設置200左右
4.增加server
```
# vim /etc/nginx/nginx.conf
server{
??listen 80;
??server_name pylong.com [www.pylong.com](http://www.pylong.com/);#多個域名,用空格分開
??index index.html index.php index.htm;
??root /var/www/pylong.com;
??location ~ .*.php$
??{
??include /etc/nginx/fastcgi_params;
??fastcgi_pass 127.0.0.1:9000;
??}
??}
```
一些更加詳細的conf設置請參看nginx的維基,以及相關資料
一些提示:
yum安裝的nginx,相關命令:servie nginx start|stop|reload
把nginx添加到系統啟動項里:chkconfig nginx on
讓spawn-fcgi隨系統自動啟動。
```
vim /etc/rc.loal
```
在文件最后加上
```
# /usr/bin/spawn-fcgi -a 127.0.0.1 -p 9000 -C 200 -u nginx -g nginx -f /usr/bin/php-cgi
```
如果php的session不可用,一般是因為 /var/lib/php/session這個目錄的對于nginx不可寫,把它所有者改為nginx相應用戶已經用戶組
轉載請注明地址:[http://www.pylong.com/?p=6](http://www.pylong.com/?p=6)
- 主要文檔
- Nginx功能概述
- 為什么選擇Nginx
- Nginx安裝
- 運行和控制Nginx
- 配置符號參考
- 優化 Nginx
- 常見問題(FAQ)
- 調試 nginx
- 核心模塊
- Nginx主模塊
- Nginx事件模塊
- 基本模塊
- http核心模塊
- HttpIndex模塊
- HttpAccess模塊
- HttpAuthBasic模塊
- HttpAutoindex模塊
- Browser模塊
- Charset模塊
- HttpEmptyGif模塊
- HttpFcgi模塊
- Geo模塊
- HttpGzip模塊
- HttpHeaders模塊
- HttpIndex模塊
- HttpReferer模塊
- HttpLimit zone
- HttpLimitReqest模塊
- HttpLog模塊
- map
- Memcached
- HttpProxy模塊
- HttpRewrite模塊
- HttpSSI模塊
- HttpUserId
- 其他模塊
- Addition模塊
- EmbeddedPerl
- flv
- HttpGzipStatic
- RandomIndex
- HttpGeoIP
- HttpRealIp
- HttpSSL
- StubStatus模塊
- HttpSubstitution
- HttpDav模塊
- GooglePerftools
- HttpXSLT
- HttpSecureLink
- HttpImageFilter
- mail模塊
- MailCore
- MailAuth
- MailProxy
- MailSSL
- 安裝
- nginx在windows上的安裝
- nginx在freebsd上的安裝
- nginx在ubuntu上的安裝
- nginx在fedora上的安裝
- nginx php-fpm安裝配置
- 配置示例和方法
- 完整例子
- 完整例子2
- 虛擬主機
- 負載均衡
- nginx防盜鏈
- HWLoadbalancerCheckErrors