標籤:
1、安裝gcc
yum install gcc
2、安裝PCRE,zlib,OpenSSL(其中devel,是develop開發包的意思)
yum install -y pcre pcre-devel
yum install -y zlib zlib-devel
yum install -y openssl openssl-devel
3、下載並安裝nginx
mkdir nginx-src && cd nginx-src
wget http://nginx.org/download/nginx-1.7.3.tar.gz
tar xzf nginx-1.7.3.tar.gz
cd nginx-1.7.3
./configure
make
make install
whereis nginx
4、sbin/nginx 啟動nginx
啟動:nginx
停止:nginx -s stop
5、配置
#啟動進程,通常設定成和cpu的數量相等worker_processes 1;#全域錯誤記錄檔及PID檔案error_log /var/log/nginx/error.log;pid /var/run/nginx.pid;#工作模式及串連數上限events { use epoll; #epoll是多工IO(I/O Multiplexing)中的一種方式,但是僅用於linux2.6以上核心,可以大大提高nginx的效能 worker_connections 1024;}#設定http伺服器,利用它的反向 Proxy功能提供負載平衡支援http { include mime.types; #設定mime類型,類型由mime.type檔案定義 default_type application/octet-stream; sendfile on; #設定連結逾時時間 keepalive_timeout 65; #開啟gzip壓縮 # gzip on; # gzip_disable "MSIE [1-6]\.(?!.*SV1)"; #設定負載平衡的伺服器列表 upstream mysvr { #weigth參數表示權值,權值越高被分配到的幾率越大 # #本機上的Squid開啟3128連接埠 server 192.168.8.151:80 weight=6; server 192.168.8.120:80 weight=6; } server { #偵聽80連接埠 listen 80; #定義使用www.xx.com訪問 server_name localhost; location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~ \.php$ { root /root; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /home/www/www$fastcgi_script_name; include fastcgi_params; } #設定查看Nginx狀態的地址 # location /NginxStatus { # stub_status on; # access_log on; # auth_basic "NginxStatus"; # auth_basic_user_file conf/htpasswd; # } # #禁止訪問 .htxxx 檔案 # location ~ /\.ht { # deny all; # } }}
View Code
centos安裝配置nginx