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

首頁 > 網站 > Nginx > 正文

構建Nginx服務器的方法

2024-08-30 12:23:53
字體:
來源:轉載
供稿:網友
  構建Nginx服務器:
  1)源碼安裝Nginx軟件
  [root@svr5 ~]# yum -y install gcc pcre-devel openssl-devel //安裝常見依賴包
  [root@svr5 ~]# useradd -s /sbin/nologin nginx
  [root@svr5 ~]# tar  -zxvf   nginx-0.8.55.tar.gz
  [root@svr5 ~]# cd  nginx-0.8.55
  [root@svr5 nginx-0.8.55]# ./configure   /
  > --prefix=/usr/local/nginx   / //指定安裝路徑
  > --user=nginx   / //指定用戶
  > --group=nginx  / //指定組
  > --with-http_stub_status_module  / //開啟狀態統計功能
  > --with-http_ssl_module //開啟SSL加密功能
  .. ..
  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"
  [root@svr5 nginx-0.8.55]# make && make install //編譯并安裝
  2)啟用Nginx服務并查看監聽端口狀態
  [root@svr5 ~]# /usr/local/nginx/sbin/nginx –c /usr/local/nginx/conf/nginx.conf
  [root@svr5 ~]# netstat  -anptu  |  grep nginx
  tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 10441/nginx
  3)為Nginx Web服務器建立測試頁面文件
  Nginx Web服務默認首頁文檔存儲目錄為/usr/local/nginx/html/,在此目錄下建立一個名為index.html的文件:
  [root@svr5 ~]# cat  /usr/local/nginx/html/index.html
  <html>
  <head>
  <title>Welcome to nginx!</title>
  </head>
  <body bgcolor="white" text="black">
  <center><h1>Welcome to nginx!</h1></center>
  </body>
  </html>
  從系統中隨機拷貝一份jpg圖片資源,供測試使用:
  [root@svr5 ~]# cp /usr/share/pixmaps/faces/energy-arc.jpg /
  >/usr/local/nginx/html/a.jpg
  提前生成404錯誤頁面,供測試使用:
  [root@svr5 ~]# echo "<h1>~~~~^^^Error^^^~~~</h1>" > /usr/local/nginx/html/40x.html
  4)修改Nginx實現防止盜鏈
  [root@svr5 ~]# /usr/local/nginx/conf/nginx.conf
  .. ..
  location ~* /.(gif|jpg|png|swf|flv)$ {
  valid_referers none blocked www.tarena.com;
  if ($invalid_referer) {
  rewrite ^/ http://www.tarena.com/403.html;
  }
  }
  5)再創建一臺Nginx服務器(192.168.4.205,使用客戶端模式另一臺盜鏈服務器),并創建連接資源
  [root@svr205 ~]# vim /usr/local/nginx/html/index.html
  <html>
  <body>
  <a href=”http://www.tarena.com/a.jpg”> 圖片</a>
  </body>
  </html>
  6)客戶端測試
  從客戶機訪問192.168.4.205,驗證是否可以通過鏈接訪問www.tarena.com服務器上的資源,使用火狐瀏覽器訪問192.168.4.205:
  [root@pc205 ~]# firefox http://192.168.4.205

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 鹤壁市| 图片| 苍溪县| 桐柏县| 阜新市| 家居| 泸水县| 潜江市| 浦城县| 杭锦后旗| 涿鹿县| 读书| 平泉县| 南昌市| 梅州市| 楚雄市| 宣化县| 高唐县| 治多县| 盘锦市| 家居| 蓬安县| 河池市| 九龙坡区| 昂仁县| 康马县| 屏南县| 宣汉县| 呼伦贝尔市| 增城市| 贵溪市| 太原市| 新晃| 三门县| 昭通市| 乐亭县| 东光县| 神木县| 大新县| 大港区| 莎车县|