優化Web伺服器

2021-09-26 19:11:50 字數 2001 閱讀 9380

優化web伺服器,實現如下效果:

自定義**404錯誤頁面

公升級nginx至1.15.8版本,開啟status模組

編寫日誌切割指令碼,實現每週五備份日誌

2.2 步驟

實現此案例需要按照如下步驟進行。

步驟一:自定義404錯誤頁面

1)優化前測試(客戶端訪問乙個不存在的頁面)。

[root@room9pc01 ~]# firefox
修改nginx配置檔案,自定義錯誤頁面

[root@web1 ~]# vim /usr/local/nginx/conf/nginx.conf

error_page 404 /404.html; //自定義錯誤頁面

[root@web2 ~]# vim /usr/local/nginx/conf/nginx.conf

error_page 404 /404.html; //自定義錯誤頁面

[root@web3 ~]# vim /usr/local/nginx/conf/nginx.conf

error_page 404 /404.html; //自定義錯誤頁面

3) 重啟nginx

[root@web1 ~]# /usr/local/nginx/sbin/nginx -s reload

[root@web2 ~]# /usr/local/nginx/sbin/nginx -s reload

[root@web3 ~]# /usr/local/nginx/sbin/nginx -s reload

步驟二:公升級nginx版本,開啟status模組

1)配置、編譯新的nginx(web1、web2、web3做相同操作,下面以web1為例)

[root@web1 ~]# make備份老版本nginx,更新新版本nginx

[root@web1 ~]# mv /usr/local/nginx/sbin/nginx

[root@web1 ~]# cp objs/nginx /usr/local/nginx/sbin/

3)修改配置檔案

[root@web1 ~]# vim /usr/local/nginx/conf/nginx.conf

... ...

location /status

... ...

重啟服務

[root@web1 ~]# killall nginx

[root@web1 ~]# /usr/local/nginx/sbin/nginx

步驟三:編寫日誌切割指令碼

1)編寫指令碼(以web1為例)

[root@web1 ~]# vim /usr/local/nginx/logbak.sh

#!/bin/bash

date=`date +%y%m%d`

logpath=/usr/local/nginx/logs

mv $logpath/access.log $logpath/access-$date.log

mv $logpath/error.log $logpath/error-$date.log

kill -usr1 $(cat $logpath/nginx.pid)

2)建立計畫任務

[root@web1 ~]# crontab -e

03 03 * * 5 /usr/local/nginx/logbak.sh

優化Web伺服器

2.1 問題 優化web伺服器,實現如下效果 自定義 404錯誤頁面 公升級nginx至1.15.8版本,開啟status模組 編寫日誌切割指令碼,實現每週五備份日誌 開啟gzip壓縮功能,提高資料傳輸效率 開啟檔案快取功能2.2 步驟 實現此案例需要按照如下步驟進行。步驟一 自定義404錯誤頁面 ...

Mysql優化和web伺服器優化

1 提高併發量 負載均衡 分布式服務架構 併發量更高的軟體例如nginx 2.頁面靜態化 不經常發生資料變動的動態網頁生成靜態網頁,提高訪問速度 3.記憶體快取優化 把資料快取到記憶體中,提高資料相應速度 4.資料庫優化 一般資料讀寫頻繁,可以快取到記憶體中。但是記憶體容量有限,不能夠把大量資料快取...

針對Web伺服器總體優化

一 檔案系統 在fstab裡加入noatime,如 cat etc fstab dev sda1 home ext3 noatime,defaults 1 2 reboot或者重新mount生效 二 tcp優化 在 etc sysctl.conf裡加入 net.ipv4.netfilter.ip c...