婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁(yè) > 知識(shí)庫(kù) > CentOS6使用nginx搭建web網(wǎng)站服務(wù)的方法

CentOS6使用nginx搭建web網(wǎng)站服務(wù)的方法

熱門(mén)標(biāo)簽:達(dá)亞電銷(xiāo)機(jī)器人官網(wǎng) 如何分析地圖標(biāo)注 電銷(xiāo)機(jī)器人怎么接線路 電銷(xiāo)機(jī)器人價(jià)值 外呼系統(tǒng)坐席費(fèi)計(jì)入會(huì)計(jì)哪個(gè)科目 新余高德地圖標(biāo)注怎么修改 撫順地圖標(biāo)注 大連400電話如何申請(qǐng) 高德地圖標(biāo)注好做嗎

利用CentOS6搭建簡(jiǎn)易的web服務(wù)

提示: 其中沒(méi)有涉及到MySQl、MongoDB的安裝和使用,包括docker容器等,使用nginx反向代理靜態(tài)服務(wù)

centOS服務(wù)器

可以選用國(guó)外或者國(guó)內(nèi)的服務(wù)器,這里只展示centOS系統(tǒng)配置,本人實(shí)在window系統(tǒng)下完成下列操作
選購(gòu)一臺(tái)合適的云服務(wù)器,系統(tǒng)為centOS

在window系統(tǒng)下安裝xshell和xftp, 保證可以系統(tǒng)訪問(wèn)centOS系統(tǒng)

使用xshell連接上云服務(wù)器,使用超級(jí)管理員root登錄

登錄完成之后安裝nginx

下面是需要下載的文件:

  • 首先安裝wget # yum install wget
  • nginx以來(lái)與gcc的編譯環(huán)境 # yum install gcc-c++
  • nginx的http模塊需要使用pcre來(lái)解析正則表達(dá)式 # yum -y install pcre pcre-devel
  • 依賴(lài)的解壓包 # yum -y install zlib zlib-devel
  • 下載nginx壓縮包 # wget -c https://nginx.org/download/nginx-1.10.3.tar.gz

解壓與安裝:

  • 解壓nginx # tar -zxvf nginx-1.10.3.tar.gz
  • 進(jìn)入nginx目錄 #cd nginx-1.10.3
  • 對(duì)nginx的源碼進(jìn)行編譯 # ./configure
  • 開(kāi)始編譯 # make
  • 繼續(xù)編譯 # make install
  • 查看nginx安裝的目錄 # whereis nginx 它會(huì)告訴你nginx在哪,nginx的命令在/usr/local/nginx/sbin目錄下

nginx命令:

nginx命令開(kāi)啟# ./nginx

停止# ./nginx -s stop

# ./nginx -s quit

重啟# ./nginx -s reload

開(kāi)啟nginx # ./nginx 必須在nginx的安裝目錄下的sbi文件開(kāi)啟,當(dāng)然也可全局配置

查看是否開(kāi)啟nginx # ps aux|grep nginx

nginx配置

以下是nginx配置的部分參考

# http server
server {
  listen    80;
  server_name www.didiheng.com;

  #charset koi8-r;

  #access_log logs/host.access.log main;

  access_log off; #緩存日志關(guān)閉
  server_tokens off;
  tcp_nopush on;
  tcp_nodelay on;

  gzip on; #gzip開(kāi)啟
  gzip_comp_level 6; #gzip比率
  gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;

  proxy_connect_timeout 5; #緩存鏈接
  proxy_read_timeout 60; 
  proxy_send_timeout 5; 
  proxy_buffer_size 16k; 
  proxy_buffers 4 64k; 
  proxy_busy_buffers_size 128k; 
  proxy_temp_file_write_size 128k;   

  location / {
    root  /www; #此處絕對(duì)地址
    index index.html index.htm;
    try_files $uri $uri/ /index.html; //使用客戶端路由需配置
    rewrite ^(.*)$ https://$host$1 permanent; /強(qiáng)制定向https   
  }

  #error_page 404       /404.html;

  # redirect server error pages to the static page /50x.html
  #
  error_page  500 502 503 504 /50x.html;
  location = /50x.html {
    root  html;
  }
  
  #https server
  server {
    listen    443 ssl;
    server_name www.didiheng.com;

    ssl_certificate   server.crt;
    ssl_certificate_key server.key;

    ssl_session_cache  shared:SSL:1m;
    ssl_session_timeout 5m;

    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers on;

    access_log off;
    server_tokens off;

    tcp_nopush on;
    tcp_nodelay on;

    expires epoch;
  gzip on;
    gzip_comp_level 6;
    gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;

    proxy_connect_timeout 5;
    proxy_read_timeout 60;
    proxy_send_timeout 5;
    proxy_buffer_size 16k;
    proxy_buffers 4 64k;
    proxy_busy_buffers_size 128k;
    proxy_temp_file_write_size 128k;

    location / {
      root  /www;
      index index.html index.htm;
      try_files $uri $uri/ /index.html;
    }
  }
  
}

在以上配置中我直接將https開(kāi)啟了,若沒(méi)有相關(guān)的ssl配置,請(qǐng)將https服務(wù)注釋 使用 # 即可

修改之后重啟nginx

# ./nginx -s reload

使用serverIP或域名訪問(wèn) 訪問(wèn)

github原址

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

標(biāo)簽:楊凌 衡水 遼源 南通 新鄉(xiāng) 黃石 湖南 海東

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《CentOS6使用nginx搭建web網(wǎng)站服務(wù)的方法》,本文關(guān)鍵詞  CentOS6,使用,nginx,搭建,web,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《CentOS6使用nginx搭建web網(wǎng)站服務(wù)的方法》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于CentOS6使用nginx搭建web網(wǎng)站服務(wù)的方法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 贺州市| 广德县| 民县| 库伦旗| 延寿县| 沈丘县| 杭锦后旗| 冀州市| 涟源市| 吐鲁番市| 天柱县| 沙坪坝区| 长沙市| 白河县| 衡阳县| 仙居县| 邮箱| 牟定县| 瑞安市| 龙州县| 东台市| 盐津县| 垣曲县| 郓城县| 芦溪县| 萍乡市| 桐庐县| 祁阳县| 连州市| 稷山县| 新兴县| 伊吾县| 乌兰浩特市| 龙岩市| 东莞市| 阿瓦提县| 吕梁市| 红河县| 壶关县| 上虞市| 长汀县|