一、按系列羅列Linux的發行版,並描述不一樣發行版之間的聯繫與區別。php
二、安裝Centos7.6操做系統,建立一個本身名字的用戶名,並能夠正常登陸,將主要步驟截圖。html
三、配置環境變量,實現執行history的時候能夠看到執行命令的時間。nginx
四、總結Linux哲學思想。git
五、總結Linux經常使用命令使用格式,並用實例說明。例如echo、screen、date、ifconfig、export等命令web
1) Linux的發行版(distribution)chrome
Debian、RedHat、SUSEshell
2) 聯繫json
基於LINUX發展而來,基於公開的標準的POSIX標準從新編寫而成,LINUXJ是自由軟件,免費、公開源代碼的ubuntu
LINUX的思想源於UNIXvim
基於GPL協議
LINUX只是個內核,發行版本都是在此實現
3) 區別
按發行版本 一類是商業公司公司,如RedHat, 一類是以debian爲表明,社區組織維護
Debian是包含Ubuntu的,遵循GNU規範,包管理工具 apt-get / dpkg
RedHat 是紅帽公司研發, 包括Fedora、 Rhel、 Centos
安裝忽略
ubuntu下 groupadd -g 1002 developer useradd -u 1002 -g 1002 -d /home/zzw1 -s /bin/bash -m zzw1 passwd zzw1 id zzw1 uid=1002(zzw1) gid=1002(developer) groups=1002(developer)
vim ~/.bashrc HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S " . ~/.bashrc
1) 一切皆文件
2)提供不少小型的單一用途的程序
3) 鏈接程序,共同完成複雜的功能
4)配置數據存儲在文本中
分爲內部命令和外部命令,使用type查看
內置命令 xxx is a shell builtin,如echo, export
外部命令 xxx is $PATH/xxx, 如 screen、date、ifconfig
內置命令查看
help echo echo: echo [-neE] [arg ...] Write arguments to the standard output. Display the ARGs, separated by a single space character and followed by a newline, on the standard output. Options: -n do not append a newline -e enable interpretation of the following backslash escapes -E explicitly suppress interpretation of backslash escapes
外部命令 xxx --help
screen --help Use: screen [-opts] [cmd [args]] or: screen -r [host.tty] Options: -4 Resolve hostnames only to IPv4 addresses. -6 Resolve hostnames only to IPv6 addresses. -a Force all capabilities into each window's termcap. -A -[r|R] Adapt all windows to the new display width & height. -c file Read configuration file instead of '.screenrc'. -d (-r) Detach the elsewhere running screen (and reattach here). -dmS name Start as daemon: Screen session in detached mode. -D (-r) Detach and logout remote (and reattach here). -D -RR Do whatever is needed to get a screen session. -e xy Change command characters. -f Flow control on, -fn = off, -fa = auto. -h lines Set the size of the scrollback history buffer. -i Interrupt output sooner when flow control is on.
外部命令還有man能夠查看幫助手冊
man手冊的分類(通常分爲九類,可是隻有前八類比較經常使用)
1 普通的命令(外部程序或者shell命令)
2 系統調用(內核提供的函數)
3 庫調用(庫中提供的函數)
4 特殊文件(常常是/dev下的設備文件)
5 文件格式,在其中會說明配置文件的格式
6 遊戲相關
7 雜項
8 管理員命令
9 內核程序(非標準)
能夠經過man -f man查看哪類,也能夠經過 whatis查看
通常格式
command [options] [arguments] - command:命令 - options:--單詞 或 -單字 - arguments:參數,有時候選項也帶參數。
編譯php
下載源文件 ./configure --prefix=/opt/php74 --enable-fpm --with-libzip --with-openssl --with-freetype --with-jpeg --enable-bcmath --enable-pcntl make make install 配置 vim /lib/systemd/system/php74-fpm.service [Unit] Description=The PHP 7.4 FastCGI Process Manager After=network.target [Service] Type=simple PIDFile=/opt/php74/var/run/php-fpm.pid ExecStart=/opt/php74/sbin/php-fpm --nodaemonize --fpm-config /opt/php74/etc/php-fpm.conf ExecReload=/bin/kill -USR2 $MAINPID [Install] WantedBy=multi-user.target systemctl start php74-fpm
編譯openresty
./configure --prefix=/opt/openresty --with-luajit --with-http_iconv_module gmake gmake install
nginx 配置文件
自定義404 和 問日誌爲json格式
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; log_format log_json '{ "@timestamp": "$time_local", ' '"remote_addr": "$remote_addr", ' '"referer": "$http_referer", ' '"request": "$request", ' '"status": $status, ' '"bytes": $body_bytes_sent, ' '"agent": "$http_user_agent", ' '"x_forwarded": "$http_x_forwarded_for", ' '"up_addr": "$upstream_addr",' '"up_host": "$upstream_http_host",' '"up_resp_time": "$upstream_response_time",' '"request_time": "$request_time"' ' }'; access_log /var/run/access.log log_json; sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; #gzip on; server { listen 80; server_name blog.chromev.com localhost; root /var/www/php; #charset koi8-r; #access_log logs/host.access.log main; location / { index index.html index.htm index.php; } 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; } location = /404.html { root /var/www/html2; } # proxy the PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ { # proxy_pass http://127.0.0.1; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } # another virtual host using mix of IP-, name-, and port-based configuration # #server { # listen 8000; # listen somename:8080; # server_name somename alias another.alias; # location / { # root html; # index index.html index.htm; # } #} # HTTPS server # #server { # listen 443 ssl; # server_name localhost; # ssl_certificate cert.pem; # ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m; # ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5; # ssl_prefer_server_ciphers on; # location / { # root html; # index index.html index.htm; # } #} }
json格式
tail -f /var/run/access.log { "@timestamp": "19/Apr/2020:21:48:52 +0800", "remote_addr": "108.162.215.50", "referer": "http://blog.chromev.com/asd", "request": "GET /404.html HTTP/1.1", "status": 304, "bytes": 0, "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36", "x_forwarded": "36.57.145.226", "up_addr": "-","up_host": "-","up_resp_time": "-","request_time": "0.000" }
基於OpenSSL自建CA和頒發SSL證書
CA服務器上操做
1) 配置文件
/etc/pki/tls/openssl.cnf
2)在CA目錄下建立兩個初始文件
cd /etc/pki/CA touch index.txt serial echo 01 > serial
3) 生成根密鑰
cd /etc/pki/CA/ openssl genrsa -out private/cakey.pem 2048
爲了安全起見,修改cakey.pem私鑰文件權限爲600或400,也可使用子shell生成( umask 077; openssl genrsa -out private/cakey.pem 2048 )
,下面再也不重複。
4) 生成根證書 (須要加入本機)
使用req命令生成自簽證書
cd /etc/pki/CA/ openssl req -new -x509 -key private/cakey.pem -out cacert.pem
WEB服務器上
1) 生成私鑰
cd /opt/openresty/nginx/ssl/ openssl genrsa -out nginx.key 2048
2) 爲nginx生成證書籤署請求
cd /opt/openresty/nginx/ssl/ openssl req -new -key nginx.key -out nginx.csr ... Country Name (2 letter code) [AU]:CN State or Province Name (full name) [Some-State]:GD Locality Name (eg, city) []:SZ Organization Name (eg, company) [Internet Widgits Pty Ltd]:COMPANY Organizational Unit Name (eg, section) []:IT_SECTION Common Name (e.g. server FQDN or YOUR name) []: blog.chroemv.com Email Address []: Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: ...
一樣會提示輸入一些內容,其它隨便,除了Commone Name
必定要是你要授予證書的服務器域名或主機名,challenge password不填。
3) 用 CA公鑰加簽
openssl ca -in nginx.csr -out nginx.crt
3 使用證書
1) Nginx 使用 ssl 證書
# HTTPS server # server { listen 443 ssl; server_name blog.chromev.com; root /var/www/php/; #ssl_certificate cert.pem; #ssl_certificate_key cert.key; ssl_certificate /opt/openresty/nginx/ssl/nginx.crt; ssl_certificate_key /opt/openresty/nginx/ssl/nginx.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { index index.html index.htm; } location ~ \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }
2 添加 CA 根證書到操做系統得到信任
mac 添加
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain /cacert.pem
除了用命令行管理證書,還能夠在 鑰匙串訪問
中進行管理
Linux (CentOs 6)
#安裝 ca-certificates package: yum install ca-certificates #啓用dynamic CA configuration feature: update-ca-trust force-enable #將證書文件放到 /etc/pki/ca-trust/source/anchors/ 目錄下 mv /cacert.pem /etc/pki/ca-trust/source/anchors/ #執行: update-ca-trust extract
3 驗證是否成功
curl -k https://blog.chromev.com <h4>Hello World</h4>