国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網(wǎng)站 > 建站經(jīng)驗(yàn) > 正文

Nginx 安裝筆記(含PHP支持、虛擬主機(jī)、反向代理負(fù)載均衡)

2019-11-02 16:26:43
字體:
供稿:網(wǎng)友

系統(tǒng)環(huán)境:RHEL5 [ 2.6.18-8.el5xen ]

軟件環(huán)境:

nginx-0.7.17

lighttpd-1.4.20.tar.gz

pcre-6.6-1.1

pcre-devel-6.6-1.1

php-5.1.6-5.el5

參考下載地址:

http://sysoev.ru/nginx/nginx-0.7.17.tar.gz (最新穩(wěn)定版為0.6.32)

http://www.lighttpd.net/download/lighttpd-1.4.20.tar.gz

##########################################################################

一、安裝支持軟件

1、安裝lighttpd以提取spawn-fcgi (如果站點(diǎn)不包含php頁面,可以不安裝spaw-fcgi、PHP)

shell> tar zxvf lighttpd-1.4.20.tar.gz

shell> cd lighttpd-1.4.20/

shell> ./configure && make

shell> cp -p src/spawn-fcgi /usr/sbin/spawn-fcgi

2、安裝pcre和php(以下軟件)

可使用RHEL5自帶的rpm包安裝,過程略。

二、安裝nginx

shell> tar zxvf nginx-0.7.17.tar.gz

shell> cd nginx-0.7.17/

shell> ./configure --prefix=/opt/nginx --with-http_stub_status_module --with-http_ssl_module

shell> make && make install

shell> ln -sf /opt/nginx/sbin/nginx /usr/sbin/

三、nginx運(yùn)行控制

1、檢查配置文件有無語法錯(cuò)誤

shell> nginx -t

2、啟動(dòng)(不帶任何參數(shù)直接運(yùn)行即可)

shell> nginx

3、重新加載nginx配置

shell> killall -s HUP nginx #//或者 killall -1 nginx

4、處理完當(dāng)前請求后退出nginx

shell> killall -s QUIT nginx #//或者 killall -3 nginx

四、nginx配置用例

1、常規(guī)配置

shell> vi /opt/nginx/conf/nginx.conf

worker_processes 1; #//工作進(jìn)程數(shù)

events {

use epoll; #//增加該事件提高I/O性能

work_connections 4096;

}

http {

include mime.types;

default_types application/octet-stream;

sendfile on;

tcp_nodelay on

keepalive_timeout 60;

server {

listen 80; #//設(shè)置監(jiān)聽端口,注意不要和Apache等其他Web程序沖突

server_name www.linux.org; #//指定使用的主機(jī)名

charset utf-8; #//指定站點(diǎn)文件的默認(rèn)編碼

location / {

root html; #//設(shè)置網(wǎng)站根目錄

index index.html index.html;

}

error_page 500 502 503 504 /50x.html

location = /50x.html {

root html;

}

}

}

2、添加狀態(tài)監(jiān)控

shell> vi /opt/nginx/conf/nginx.conf #//增加以下內(nèi)容

location ~ ^/NginxStatus/ {

stub_status on;

access_log off;

}

shell> killall -1 nginx

#//使用瀏覽器訪問 http://nginx_server_ip/NginxStatus/ 即可看到狀態(tài)統(tǒng)計(jì)頁面。(三個(gè)數(shù)字分別表示:總共處理連接數(shù)、成功創(chuàng)建的握手次數(shù)、總共處理的請求數(shù))

3、通過FastCGI方式支持PHP語言

1)啟動(dòng)FastCGI服務(wù)(用php-cgi做實(shí)際處理php頁面的程序,用spawn-fcgi是便于同時(shí)開啟多個(gè)php-cgi進(jìn)程――“-C”選項(xiàng)控制子進(jìn)程數(shù))

shell>/usr/sbin/spawn-fcgi -a 127.0.0.1 -p 9000 -f /usr/bin/php-cgi -C 10

2)修改/opt/nginx/conf/nginx.conf配置文件,添加以下內(nèi)容:

location ~ /.php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 武宣县| 连山| 云安县| 鄂托克旗| 南召县| 上饶市| 德格县| 同江市| 桂东县| 绥江县| 巍山| 和田县| 尼木县| 丰宁| 页游| 新绛县| 历史| 金阳县| 饶平县| 新邵县| 石楼县| 临澧县| 黑河市| 明光市| 平邑县| 红河县| 图片| 西乡县| 高碑店市| 左贡县| 平江县| 封开县| 常德市| 嘉荫县| 余姚市| 化德县| 保康县| 思茅市| 遂宁市| 西吉县| 吉林省|