[root@nginx ~]# yum -y install pcre-devel zlib-devel openssl-devel gcc gcc-c++ makejavascript
[root@nginx ~]# tar xf nginx-1.6.0.tar.gz -C /usr/src/php
[root@nginx ~]# useradd -M -s /sbin/nologin nginxcss
[root@nginx ~]# cd /usr/src/nginx-1.6.0html
[root@nginx nginx-1.6.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-pcre && make && make install前端
在生產環境中,須要隱藏 Nginx 等服務的版本信息,以免安全風險。java
[root@nginx ~]# curl -I http://192.168.200.111linux
HTTP/1.1 200 OK
Server: nginx/1.6.0
Date: Fri, 13 Sep 2019 01:48:29 GMT
Content-Type: text/html
Content-Length: 667
Last-Modified: Fri, 13 Sep 2019 01:22:06 GMT
Connection: keep-alive
ETag: "5d7aef3e-29b"
Accept-Ranges: bytesnginx
隱藏的方法:c++
(1)安裝以前,修改源碼包web
[root@nginx ~]# tar xf nginx-1.6.0.tar.gz
[root@nginx ~]# vim nginx-1.6.0 /src/core/nginx.h
13 #define NGINX_VERSION "12138"
14 #define NGINX_VER "DaBaiTu"
[root@nginx ~]# useradd -M -s /sbin/nologin nginx
[root@nginx ~]# cd nginx-1.6.0
[root@nginx nginx-1.6.0]# yum -y install pcre-devel zlib-devel
[root@nginx nginx-1.6.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-file-aio --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-pcre && make && make install
[root@nginx ~]# /usr/local/nginx/sbin/nginx
[root@nginx ~]# netstat -anpt | grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 23521/nginx: master
root@nginx ~]# curl -I http://192.168.200.111
HTTP/1.1 200 OK
Server: DaBaiTu/12138
Date: Fri, 13 Sep 2019 01:48:29 GMT
Content-Type: text/html
Content-Length: 667
Last-Modified: Fri, 13 Sep 2019 01:22:06 GMT
Connection: keep-alive
ETag: "5d7aef3e-29b"
Accept-Ranges: bytes
(2)啓服務以後,修改配置文件
[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
28 server_tokens off;
[root@nginx ~]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@nginx ~]# killall -1 nginx
[root@nginx ~]# curl -I http://192.168.200.111
HTTP/1.1 200 OK
Server: nginx
Date: Fri, 13 Sep 2019 01:48:29 GMT
Content-Type: text/html
Content-Length: 667
Last-Modified: Fri, 13 Sep 2019 01:22:06 GMT
Connection: keep-alive
ETag: "5d7aef3e-29b"
Accept-Ranges: bytes
Nginx運行時進程須要有用戶與組身份的支持,以實現對網站文件讀取時進行訪問控制。Nginx默認使用nobody用戶帳號與組帳號,通常也要進行修改。
1、編譯安裝時指定
[root@localhost ~]# useradd -M -s /sbin/nologin nginx
[root@localhost nginx-1.14.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx && make && make install
2、修改配置文件
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
2 user nginx nginx;
[root@localhost ~]# killall -HUP nginx
[root@localhost ~]# ps aux |grep nginx
root 6651 0.0 0.2 20300 1248 ? Ss 13:38 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 6746 0.0 1.0 24472 5048 ? S 14:27 0:00 nginx: worker process
當Nginx將網頁數據返回給客戶端後,可設置資源在客戶端緩存的時間,以方便客戶端在往後進行相同內容的請求時直接返回,以免重複請求,加快了訪問速度,通常針對靜態網頁進行設置,對動態網頁不用設置緩存時間。可在Windows客戶端中使用fiddler查看網頁緩存時間。
設置方法:可修改配置文件,在http段、或server段、或者location段加入對特定內容的過時參數。
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
49 location ~ \.(gif|jpg|jpeg|png|bmp|ico)$ {
50 expires 1d;
51 }
52 location ~ .*\.(js|css)$ {
53 expires 1h;
54 }
[root@localhost ~]# killall -HUP nginx
[root@localhost ~]# ll /usr/local/nginx/html/
total 124
-rw-r--r-- 1 root root 537 Nov 18 00:05 50x.html
-rw-r--r-- 1 root root 643 Nov 18 00:21 index.html
-rw-r--r-- 1 root root 116309 Nov 14 11:54 linux.png
[root@localhost ~]# vim /usr/local/nginx/html/index.html
15 <hr />
16 <img src="linux.png" />
抓包查看:
[root@localhost ~]# vim /opt/cut_nginx_log.sh
#!/bin/bash
# cut_nginx_log.sh
datetime=$(date -d "-1 day" "+%Y%m%d")
log_path="/usr/local/nginx/logs"
pid_path="/usr/local/nginx/logs/nginx.pid"
[ -d $log_path/backup ] || mkdir -p $log_path/backup
if [ -f $pid_path ]
then
mv $log_path/access.log $log_path/backup/access.log-$datetime
kill -USR1 $(cat $pid_path)
find $log_path/backup -mtime +30 | xargs rm -f
else
echo "Error,Nginx is not working!" | tee -a /var/log/messages
fi
[root@localhost ~]# chmod +x /opt/cut_nginx_log.sh
[root@localhost ~]# crontab -e
0 0 * * * /opt/cut_nginx_log.sh
[root@localhost ~]# /opt/cut_nginx_log.sh
[root@localhost ~]# ls /usr/local/nginx/logs/backup/
access.log-20161117
[root@localhost ~]# killall -9 nginx
[root@localhost ~]# /opt/cut_nginx_log.sh
Error,Nginx is not working!
[root@localhost ~]# tail -1 /var/log/messages
Error,Nginx is not working!
在企業網站中,爲了不同一個客戶長時間佔用鏈接,形成服務器資源浪費,能夠設置相應的鏈接超時參數,實現控制鏈接訪問時間。
keepalived_timeout:設置鏈接保持超時時間,通常可只設置該參數,默認爲65秒,可根據網站的狀況設置,或者關閉,可在http段、server段、或者location段設置。
client_header_timeout:指定等待客戶端發送請求頭的超時時間。
client_body_timeout:設置請求體讀取超時時間。
注意:若出現超時,會返回408報錯
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
34 keepalive_timeout 65;
35 client_header_timeout 60;
36 client_body_timeout 60;
[root@localhost ~]# killall -HUP nginx
在高併發場景,須要啓動更多的nginx進程以保證快速影響,以處理用戶的請求,避免形成阻塞。
修改配置文件的worker_processes參數,通常設置爲CPU的個數或者核數的2倍
[root@localhost ~]# grep 'core id' /proc/cpuinfo | uniq | wc -l
1
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
3 worker_processes 2;
[root@localhost ~]# /usr/local/nginx/sbin/nginx
[root@localhost ~]# ps aux | grep nginx | grep -v grep
root 4431 0.0 0.2 45040 1160 ? Ss 00:50 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 4432 0.0 0.3 45492 1844 ? S 00:50 0:00 nginx: worker process
nginx 4433 0.0 0.3 45492 1756 ? S 00:50 0:00 nginx: worker process
默認Nginx的多個進程可能更多的跑在一顆CPU上,能夠分配不一樣的進程給不一樣的CPU處理,充分利用硬件多核多CPU。在一臺4核物理服務器,能夠進行下面的配置,將進程進行分配。
worker_cpu_affinity 0001 0010 0100 1000
Nginx的ngx_http_gzip_module壓縮模塊提供了對文件內容壓縮的功能,容許nginx服務器將輸出內容發送到客戶端以前進行壓縮,以節約網站帶寬,提高用戶的訪問體驗,模塊默認已經安裝。
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
38 gzip on; //開啓gzip壓縮輸出
39 gzip_min_length 1k; //用於設置容許壓縮的頁面最小字節數
40 gzip_buffers 4 16k; //表示申請4個單位爲16k的內存做爲壓縮結果流緩存,默認值是申請與原始數據大小相同的內存空間來儲存gzip壓縮結果
41 gzip_http_version 1.1; //設置識別http協議版本,默認是1.1
42 gzip_comp_level 2; //gzip壓縮比,1-9等級
43 gzip_types text/plain text/javascript application/x-javascript text/css text/xml application/xml application/xml+rss; //壓縮類型,是就對哪些網頁文檔啓用壓縮功能
44 #gzip_vary on; //選項可讓前端的緩存服務器通過gzip壓縮的頁面
[root@localhost ~]# killall -HUP nginx
Nginx防盜鏈功能也很是強大,在默認狀況下只須要進行簡單的配置,便可實現防盜處理
資源主機 www.source.com 192.168.200.101
盜鏈主機 www.steal.com 192.168.200.102
[root@localhost ~]# vim /usr/local/nginx/html/index.html
<html>
<head>
<title>source page</title>
</head>
<body>
<h1>www.source.com</h1>
<img src="linux.png" />
</body>
</html>
[root@localhost ~]# ls /usr/local/nginx/html/
50x.html error.jpg index.html linux.png
客戶機測試:
[root@localhost ~]# vim /usr/local/nginx/html/index.html
<html>
<head>
<title>steal page</title>
</head>
<body>
<h1>www.steal.com</h1>
<img src="http://www.source.com/linux.png" />
</body>
</html>
配置說明:
valid_referers 設置信任網站
none 瀏覽器中referer(Referer是header的一部分,當瀏覽器向web服務器發送請求的時候,通常會帶上Referer,告訴服務器我是從哪一個頁面連接過來的,服務器基此能夠得到一些信息用於處理)爲空的狀況,就直接在瀏覽器訪問圖片
blocked referer不爲空的狀況,可是值被代理或防火牆刪除了,這些值不以http://或https://開頭
[root@localhost ~]# ls /var/www/
error.jpg index.html test.jpg
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
location ~* \.(wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv)$ {
valid_referers none blocked *.source.com source.com;
if ($invalid_referer) {
rewrite ^/ http://www.source.com/error.jpg;
#return 403;
}
}
[root@localhost ~]# nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@localhost ~]# killall -HUP nginx
第一行:wma|wmv|asf|mp3|mmf|zip|rar|jpg|gif|png|swf|flv表示對這些後綴的文件實行防盜鏈
第二行:none blocked *.source.com source.com; //不區分大小寫
表示referers信息中匹配none blocked *.source.com source.com (*表明任何,任何的二級域名)
if{}裏面內容的意思是,若是連接不是來自第二行指定的就強制跳轉到403錯誤頁面,固然直接返回404也是能夠的,也能夠是圖片。
注意:設置客戶機的hosts文件
Nginx的PHP解析功能實現若是是交由FPM(fastcgi 進程管理器)處理的,爲了提升PHP的處理速度,可對FPM模塊進行參數跳轉。
FPM優化參數:
pm 使用哪一種方式啓動fpm進程,能夠說static和dynamic,前者將產生 固定數量的fpm進程,後者將以動態的方式產生fpm進程
pm.max_children static方式下開啓的fpm進程數
pm.start_servers 動態方式下初始的fpm進程數量
pm.min_spare_servers 動態方式下最小的fpm空閒進程數
pm.max_spare_servers 動態方式下最大的fpm空閒進程數
注:以上調整要根據服務器的內存與服務器負載進行調整
示例:
服務器爲雲服務器,運行了我的論壇,內存爲1.5G,fpm進程數爲20,內存消耗近1G,處理比較慢
優化參數調整:
# vim /usr/local/php5/etc/php-fpm.conf
pm = dynamic
pm=start_servers = 5
pm.min_spare_servers = 2
pm.max_spare_servers = 8
用戶訪問控制:使用apache 的 htpasswd 來建立密碼文件
[root@localhost ~]# yum -y install httpd-tools
[root@localhost ~]# htpasswd -c /usr/local/nginx/.htpasswd crushlinux
New password:
Re-type new password:
Adding password for user crushlinux
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
location ~ /status {
stub_status on;
access_log off;
auth_basic "Nginx Status";
auth_basic_user_file /usr/local/nginx/.htpasswd;
}
客戶端地址訪問控制:
[root@localhost ~]# vim /usr/local/nginx/conf/nginx.conf
location ~ /status {
stub_status on;
access_log off;
auth_basic "Nginx Status";
auth_basic_user_file /usr/local/nginx/.htpasswd;
allow 192.168.200.2;
deny 192.168.200.0/24;
}
error_page 403 404 /404.html;
location = /404.html {
root html;
}
[root@localhost html]# echo "Sorry,Page Not Found" > /usr/local/nginx/html/404.html
[root@localhost html]# service nginx reload
瀏覽器訪問 http://192.168.200.101/abc
返回結果: Sorry,Page Not Found
location /download {
autoindex on;
}
[root@localhost ~]# cd /usr/local/nginx/html/
[root@localhost html]# mkdir download/dir{1,2} -p
[root@localhost html]# touch download/1.txt
[root@localhost html]# touch download/2.txt
[root@localhost html]# service nginx reload
瀏覽器訪問 http://192.168.200.101/download
[root@localhost html]# mkdir Centos RedHat
[root@localhost ~]# echo "hello,students" > /usr/local/nginx/html/RedHat/index.html
[root@localhost ~]# vi /usr/local/nginx/conf/nginx.conf
location ~ /Centos {
alias /usr/local/nginx/html/RedHat;
}
[root@localhost ~]# service nginx restart
在瀏覽器中http://192.168.200.101/Centos 進行測試
實現nginx區分pc和手機訪問不一樣的網站,是物理上徹底隔離的兩套網站(一套移動端、一套pc端),這樣帶來的好處pc端和移動端的內容能夠不同,移動版網站不須要包含特別多的內容,只要包含必要的文字和較小的圖片,這樣會更節省流量。有好處固然也就會增長困難,難題就是你須要維護兩套環境,而且須要自動識別出來用戶的物理設備並跳轉到相應的網站,當判斷錯誤時用戶能夠本身手動切換回正確的網站。
有兩套網站代碼,一套PC版放在/usr/local/nginx/html/web,一套移動版放在/usr/local/nginx/html/mobile。只須要修改nginx的配置文件,nginx經過UA來判斷是否來自移動端訪問,實現不一樣的客戶端訪問不一樣內容。
location / {
#默認PC端訪問內容
root /usr/local/nginx/html/web;
#若是是手機移動端訪問內容
if ( $http_user_agent ~ "(MIDP)|(WAP)|(UP.Browser)|(Smartphone)|(Obigo)|(Mobile)|(AU.Browser)|(wxd.Mms)|(WxdB.Browser)|(CLDC)|(UP.Link)|(KM.Browser)|(UCWEB)|(SEMC-Browser)|(Mini)|(Symbian)|(Palm)|(Nokia)|(Panasonic)|(MOT-)|(SonyEricsson)|(NEC-)|(Alcatel)|(Ericsson)|(BENQ)|(BenQ)|(Amoisonic)|(Amoi-)|(Capitel)|(PHILIPS)|(SAMSUNG)|(Lenovo)|(Mitsu)|(Motorola)|(SHARP)|(WAPPER)|(LG-)|(LG/)|(EG900)|(CECT)|(Compal)|(kejian)|(Bird)|(BIRD)|(G900/V1.0)|(Arima)|(CTL)|(TDG)|(Daxian)|(DAXIAN)|(DBTEL)|(Eastcom)|(EASTCOM)|(PANTECH)|(Dopod)|(Haier)|(HAIER)|(KONKA)|(KEJIAN)|(LENOVO)|(Soutec)|(SOUTEC)|(SAGEM)|(SEC-)|(SED-)|(EMOL-)|(INNO55)|(ZTE)|(iPhone)|(Android)|(Windows CE)|(Wget)|(Java)|(curl)|(Opera)" )
{
root /usr/local/nginx/html/mobile;
}
index index.html index.htm;
}
[root@localhost html]# mkdir firefox msie
[root@localhost html]# echo "hello,firefox" > firefox/index.html
[root@localhost html]# echo "hello,msie" > msie/index.html
location / {
if ($http_user_agent ~ Firefox) {
root /usr/local/nginx/html/firefox;
}
if ($http_user_agent ~ MSIE) {
root /usr/local/nginx/html/msie;
}
index index.html index.htm;
}
隨着網站併發訪問量愈來愈高,nginx web 服務器也愈來愈流行,nginx 版本換代愈來愈頻繁,1.15.2版本的nginx更新了許多新功能,生產環境中版本升級必然的,可是線上業務不能停,此時nginx的升級就是運維的重要工做了。
多進程模式下的請求分配方式
Nginx默認工做在多進程模式下,即主進程(master process)啓動後完成配置加載和端口綁定等動做,fork出指定數量的工做進程(worker process),這些子進程會持有監聽端口的文件描述符(fd),並經過在該描述符上添加監聽事件來接受鏈接(accept)。
信號的接收和處理
Nginx主進程在啓動完成後會進入等待狀態,負責響應各種系統消息,如SIGCHLD、SIGHUP、SIGUSR2等。
Nginx信號簡介
主進程支持的信號
TERM, INT: 馬上退出
QUIT: 等待工做進程結束後再退出
KILL: 強制終止進程
HUP: 從新加載配置文件,使用新的配置啓動工做進程,並逐步關閉舊進程。
USR1: 從新打開日誌文件
USR2: 啓動新的主進程,實現熱升級
WINCH: 逐步關閉工做進程
工做進程支持的信號
TERM, INT: 馬上退出
QUIT: 等待請求處理結束後再退出
USR1: 從新打開日誌文件
[root@localhost ~]# rpm -q httpd
package httpd is not installed
[root@localhost ~]# yum -y install pcre-devel zlib-devel
[root@localhost ~]# ll nginx-*
-rw-r--r-- 1 root root 910812 Nov 15 15:00 nginx-1.15.9.tar.gz
-rw-r--r-- 1 root root 804164 Dec 11 2014 nginx-1.14.2.tar.gz
[root@localhost ~]# useradd -M -s /sbin/nologin nginx
[root@localhost ~]# tar xf nginx-1.14.2.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/nginx-1.14.2/
[root@localhost nginx-1.14.2]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module && make && make install
[root@localhost ~]# /usr/local/nginx/sbin/nginx
[root@localhost ~]# netstat -anpt |grep :80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 4178/nginx
[root@localhost ~]# elinks --dump http://localhost
Welcome to nginx!
[root@localhost ~]# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.6.2
built by gcc 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module
[root@localhost ~]# tar xf nginx-1.15.9.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/nginx-1.15.9/
[root@localhost nginx-1.15.9]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module && make
[root@localhost nginx-1.15.9]# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.old
[root@localhost nginx-1.15.9]# ls
auto CHANGES.ru configure html Makefile objs src
CHANGES conf contrib LICENSE man README
[root@localhost nginx-1.15.9]# cp objs/nginx /usr/local/nginx/sbin/
[root@localhost nginx-1.15.9]# /usr/local/nginx/sbin/nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
向主進程(master)發送USR2信號,Nginx會啓動一個新版本的master進程和對應工做進程,和舊版一塊兒處理請求
[root@localhost ~]# ps aux | grep nginx | grep -v grep
root 4108 0.0 0.2 45028 1152 ? Ss 16:58 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 4109 0.0 0.4 45456 2012 ? S 16:58 0:00 nginx: worker process
[root@localhost ~]# kill -USR2 4108
[root@localhost ~]# ps aux | grep nginx | grep -v grep
root 4108 0.0 0.2 45028 1316 ? Ss 16:58 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 4109 0.0 0.4 45456 2012 ? S 16:58 0:00 nginx: worker process
root 6605 0.5 0.6 45196 3364 ? S 17:02 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 6607 0.0 0.3 45624 1756 ? S 17:02 0:00 nginx: worker process
向舊的Nginx主進程(master)發送WINCH信號,它會逐步關閉本身的工做進程(主進程不退出),這時全部請求都會由新版Nginx處理
[root@localhost ~]# kill -WINCH 4108
[root@localhost ~]# ps aux | grep nginx | grep -v grep
root 4108 0.0 0.2 45028 1320 ? Ss 16:58 0:00 nginx: master process /usr/local/nginx/sbin/nginx
root 6605 0.0 0.6 45196 3364 ? S 17:02 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 6607 0.0 0.3 45624 1756 ? S 17:02 0:00 nginx: worker process
注意:回滾步驟,發送HUP信號
若是這時須要回退繼續使用舊版本,可向舊的Nginx主進程發送HUP信號,它會從新啓動工做進程, 仍使用舊版配置文件。而後能夠將新版Nginx進程殺死(使用QUIT、TERM、或者KILL)
[root@localhost ~]# kill -HUP 4108
升級完畢,可向舊的Nginx主進程(master)發送(QUIT、TERM、或者KILL)信號,使舊的主進程退出
[root@localhost ~]# kill -QUIT 4108
[root@localhost ~]# ps aux | grep nginx | grep -v grep
root 6605 0.0 0.6 45196 3364 ? S 17:02 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx 6607 0.0 0.4 45624 2056 ? S 17:02 0:00 nginx: worker process
[root@localhost nginx-1.15.9]# /usr/local/nginx/sbin/nginx -v
nginx version: nginx/1.10.2
查看CPU型號:
[root@localhost ~]# grep "model name" /proc/cpuinfo | uniq
model name : Intel(R) Core(TM) i7 CPU M 620 @ 2.67GHz
[root@localhost ~]# dmidecode -s processor-version | uniq
Intel(R) Core(TM) i7 CPU M 620 @ 2.67GHz
查看物理CPU個數:
[root@localhost ~]# grep 'physical id' /proc/cpuinfo |sort -u |wc -l
1
[root@localhost ~]# grep 'physical id' /proc/cpuinfo |uniq |wc -l
1
查看CPU核心數:
[root@localhost ~]# grep 'core id' /proc/cpuinfo | sort -u | wc -l
4
[root@localhost ~]# grep 'core id' /proc/cpuinfo | uniq | wc -l
4
查看CPU線程數:
[root@localhost ~]# grep 'processor' /proc/cpuinfo | sort -u | wc -l
4
[root@localhost ~]# grep 'processor' /proc/cpuinfo | uniq | wc -l
4
free -m
df -Th
[root@localhost ~]# mii-tool ens32
ens32: negotiated 1000baseT-FD flow-control, link ok