centos安裝配置nginx

來源:互聯網
上載者:User

標籤:

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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.