Nginx 實踐案例(源碼編譯安裝方式):利用LNMP搭建wordpress站點

来源:https://www.cnblogs.com/helong-123/archive/2022/04/01/16086894.html
-Advertisement-
Play Games

鏡像下載、功能變數名稱解析、時間同步請點擊 阿裡雲開源鏡像站 ​LNMP是Linux + Nginx + MySQL + PHP 四個系統的首字母縮寫,相對於 LAMP(Linux + Apache + MySQL + PHP )來說的。曾經在虛擬主機建站界風靡一時,隨著新的編程語言和容器技術、微服務等發展 ...


鏡像下載、功能變數名稱解析、時間同步請點擊 阿裡雲開源鏡像站

​LNMP是Linux + Nginx + MySQL + PHP 四個系統的首字母縮寫,相對於 LAMP(Linux + Apache + MySQL + PHP )來說的。曾經在虛擬主機建站界風靡一時,隨著新的編程語言和容器技術、微服務等發展,慢慢沒落了,尤其是PHP編程語言的使用量急劇下降了。​

​ WordPress是一款能讓您建立出色網站、博客或應用程式的開源軟體。它具有美觀的設計,強大的功能,可以助您自由發揮心中所想。WordPress既是免費的,也是無價的​。

# 本實踐過程中的系統及環境描述
L:Linux     https://mirrors.aliyun.com/centos/
N:Nginx     https://nginx.org/en/download.html
M:MySQL     https://dev.mysql.com/downloads/mysql/
P:PHP       http://php.net/downloads.php
Wordpress    https://cn.wordpress.org/latest-zh_CN.tar.gz
#部署規劃:
192.168.250.47:Nginx php-fpm 運行web服務
192.168.250.48:運行MySQL資料庫,Redis服務

1. 架構拓撲及主機說明

file

# 三台主機
1  1台  Linux+Nginx+PHP+WordPress (簡稱 LNP) 伺服器 :
主機名:LNP-Server-IP47
CentOS 7.9
IP:192.168.250.47


2  1台 MySQL+Redis 伺服器 :
主機名: MySQL-Redis-IP48
CentOS 8.4
IP:192.168.250.48/24

3  1台 client主機 :
WIN10-PC機

2. 準備 MySQL 資料庫

# CentOS系統的優化,可以查以前的文章;按照架構圖修改好主機名
[root@CentOS84-IP48 ]#hostnamectl set-hostname MySQL-Redis-IP48
[root@CentOS84-IP48 ]#exit

# yum 安裝 mysql-server 資料庫
[root@MySQL-Redis-IP48 ]#yum info mysql-server
Last metadata expiration check: 19:31:21 ago on Mon 28 Mar 2022 02:34:38 AM CST.
Available Packages
Name         : mysql-server
Version      : 8.0.26
[root@MySQL-Redis-IP48 ]#yum -y install mysql-server

# 啟動服務並開啟自啟
[root@MySQL-Redis-IP48 ]#systemctl enable --now mysqld

# 進入資料庫
[root@MySQL-Redis-IP48 ]#mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.26 Source distribution

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
# 創建 wordpress 庫
mysql> create database wordpress;
Query OK, 1 row affected (0.00 sec)
# 創建wordpress的資料庫賬戶名和密碼
mysql> create user wordpress@'192.168.250.%' identified by '123456';
Query OK, 0 rows affected (0.01 sec)
# 資料庫授權
mysql> grant all on wordpress.* to wordpress@'192.168.250.%';
Query OK, 0 rows affected (0.01 sec)
# 本機登錄並驗證資料庫
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
| wordpress          |
+--------------------+
5 rows in set (0.01 sec)

mysql> use wordpress
Database changed
mysql> show tables;
Empty set (0.00 sec)

mysql> quit
Bye
[root@MySQL-Redis-IP48 ]#

3. 網路驗證MySQL服務

# 通過網路在另外一臺機器上登錄上面建好的資料庫伺服器
# 安裝資料庫客戶端 mysql 包
[root@CentOS84-IP172-48 ]#yum -y install mysql

# 網路方式登錄遠程資料庫
[root@CentOS84-IP172-48 ]#mysql -uwordpress -p123456 -h192.168.250.48
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.26 Source distribution

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| wordpress          |
+--------------------+
2 rows in set (0.00 sec)

mysql>

4. 配置 LNP 伺服器

​基本任務: 編譯安裝和部署 php 支持 redis,並準備配置和啟動服務文件,啟動 php-fpm; 編譯安裝Nginx ,並準備配置和啟動服務文件,啟動Nginx​

4.1 部署php-fpm服務

# 按照架構圖修改好主機名
[root@centos79 <sub>]# hostnamectl set-hostname LNP-Server-IP47
[root@centos79 </sub>]# exit

# 安裝編譯PHP需要的依賴包
[root@lnp-server-ip47 ]# yum -y install gcc openssl-devel libxml2-devel bzip2-devel libmcrypt-devel sqlite-devel oniguruma-devel

# 下載 php-7.4.28.tar.xz 源碼包
[root@lnp-server-ip47 src]# wget https://www.php.net/distributions/php-7.4.28.tar.xz
[root@lnp-server-ip47 src]# ll -h php-7.4.28.tar.xz 
-rw-r--r-- 1 root root 10M Feb 15 21:40 php-7.4.28.tar.xz

# 解壓源碼包,進入源碼包所在目錄
[root@lnp-server-ip47 src]# tar xf php-7.4.28.tar.xz 
[root@lnp-server-ip47 src]# ll
total 11220
drwxr-xr-x  9 1001 1001      186 Mar 28 17:06 nginx-1.20.2
-rw-r--r--  1 root root  1062124 Nov 16 22:51 nginx-1.20.2.tar.gz
drwxrwxr-x 16 root root     4096 Feb 15 21:23 php-7.4.28
-rw-r--r--  1 root root 10418352 Feb 15 21:40 php-7.4.28.tar.xz

# 準備編譯參數
[root@lnp-server-ip47 src]#cd  php-7.4.28/
[root@lnp-server-ip47 php-7.4.28]# ./configure --prefix=/apps/php74 --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-zlib --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets --enable-fpm -enable-maintainer-zts --disable-fileinfo
....................................
Thank you for using PHP.    # 需要看到這個信息才算成功了

# 查看cpu個數,作為編譯參數CPU選項輸入
[root@lnp-server-ip47 nginx-1.20.2]# lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                8
On-line CPU(s) list:   0-7
[root@lnp-server-ip47 php-7.4.28]# 

# 編譯安裝
[root@lnp-server-ip47 php-7.4.28]# make -j 8 && make install

...................  #此處刪除很多屏顯內容,需要看到下麵成功信息再進入下一步
Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /apps/php74/lib/php/extensions/no-debug-zts-20190902/
Installing PHP CLI binary:        /apps/php74/bin/
Installing PHP CLI man page:      /apps/php74/php/man/man1/
Installing PHP FPM binary:        /apps/php74/sbin/
Installing PHP FPM defconfig:     /apps/php74/etc/
Installing PHP FPM man page:      /apps/php74/php/man/man8/
Installing PHP FPM status page:   /apps/php74/php/php/fpm/
Installing phpdbg binary:         /apps/php74/bin/
Installing phpdbg man page:       /apps/php74/php/man/man1/
Installing PHP CGI binary:        /apps/php74/bin/
Installing PHP CGI man page:      /apps/php74/php/man/man1/
Installing build environment:     /apps/php74/lib/php/build/
Installing header files:          /apps/php74/include/php/
Installing helper programs:       /apps/php74/bin/
  program: phpize
  program: php-config
Installing man pages:             /apps/php74/php/man/man1/
  page: phpize.1
  page: php-config.1
/usr/local/src/php-7.4.28/build/shtool install -c ext/phar/phar.phar /apps/php74/bin/phar.phar
ln -s -f phar.phar /apps/php74/bin/phar
Installing PDO headers:           /apps/php74/include/php/ext/pdo/

##############################################################################
## 準備 php 配置文件
# 從配置文件模板複製,併進行修改
[root@lnp-server-ip47 php-7.4.28]# cp /usr/local/src/php-7.4.28/php.ini-production /etc/php.ini

# 進入當時編譯參數內定義的目錄 /apps/php74/    從模板複製創建 php-fpm.conf
[root@lnp-server-ip47 php-7.4.28]# cd /apps/php74/etc
[root@lnp-server-ip47 etc]# cp php-fpm.conf.default php-fpm.conf

# 進入子配置文件目錄,從模板 文件創建 www.conf  
[root@lnp-server-ip47 etc]# cd php-fpm.d/

[root@lnp-server-ip47 php-fpm.d]# cp www.conf.default www.conf   
[root@lnp-server-ip47 php-fpm.d]# 

# 按照本實踐的思路修改 www.conf
[root@lnp-server-ip47 php-fpm.d]# vim www.conf
;user = nobody
user = www

;group = nobody
group = www

;pm.status_path = /status
pm.status_path = /status

;ping.path = /ping
ping.path = /ping

;access.log = log/$pool.access.log
access.log = log/$pool.access.log 

;slowlog = log/$pool.log.slow
slowlog = log/$pool.log.slow 

# 修改後的 www.conf 文件去除 ; 註釋行的所有文件內容 供比對
[root@lnp-server-ip47 php-fpm.d]# grep '^[^;]' www.conf
[www]
user = www
group = www
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
pm.status_path = /status
ping.path = /ping
access.log = log/$pool.access.log
slowlog = log/$pool.log.slow  
[root@lnp-server-ip47 php-fpm.d]# 

# 創建 www 用戶
[root@lnp-server-ip47 php-fpm.d]# useradd -r -s /sbin/nologin www
# 創建訪問日誌文件路徑
[root@lnp-server-ip47 php-fpm.d]# mkdir /apps/php74/log
[root@lnp-server-ip47 php-fpm.d]# 

##############################################################################
## 啟動並驗證 php-fpm 服務
# 檢查配置文件語法等
[root@lnp-server-ip47 php-fpm.d]# /apps/php74/sbin/php-fpm -t
[28-Mar-2022 18:05:51] NOTICE: configuration file /apps/php74/etc/php-fpm.conf test is successful
# 準備啟動服務文件
[root@lnp-server-ip47 php-fpm.d]# cp /usr/local/src/php-7.4.28/sapi/fpm/php-fpm.service /usr/lib/systemd/system/

# 啟動並開機自啟動 php-fpm
[root@lnp-server-ip47 php-fpm.d]# systemctl daemon-reload
[root@lnp-server-ip47 php-fpm.d]# systemctl enable --now php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to /usr/lib/systemd/system/php-fpm.service.
# 驗證監聽埠
[root@lnp-server-ip47 php-fpm.d]# ss -ltn
State       Recv-Q Send-Q   Local Address:Port         Peer Address:Port   
LISTEN      0      511      127.0.0.1:9000             *:*                  
              
# 查看並跟蹤 進程信息
[root@lnp-server-ip47 php-fpm.d]# pstree -p |grep php
           |-php-fpm(20700)-+-php-fpm(20701)
           |                `-php-fpm(20702)
[root@lnp-server-ip47 php-fpm.d]# ps -ef |grep php
root     20700     1  0 18:06 ?        00:00:00 php-fpm: master process (/apps/php74/etc/php-fpm.conf)
www      20701 20700  0 18:06 ?        00:00:00 php-fpm: pool www
www      20702 20700  0 18:06 ?        00:00:00 php-fpm: pool www
root     20707  5036  0 18:07 pts/0    00:00:00 grep --color=auto php
[root@lnp-server-ip47 php-fpm.d]#

4.2 部署 Nginx 服務

4.2.1 編譯安裝 nginx

#### 編譯安裝 nginx
# 準備Nginx編譯安裝的依賴包
[root@lnp-server-ip47 <sub>]# yum -y install gcc pcre-devel openssl-devel zlib-devel
# 下載 nginx 1.20.2 源碼包  一般/usr/local/src/  作為源碼文件存放目錄
[root@lnp-server-ip47 </sub>]# cd /usr/local/src/
[root@lnp-server-ip47 src]# wget http://nginx.org/download/nginx-1.20.2.tar.gz
# 解壓源碼包
[root@lnp-server-ip47 src]# tar xf nginx-1.20.2.tar.gz
[root@lnp-server-ip47 src]# ll
total 1040
drwxr-xr-x 8 1001 1001     158 Nov 16 22:44 nginx-1.20.2
-rw-r--r-- 1 root root 1062124 Nov 16 22:51 nginx-1.20.2.tar.gz
[root@lnp-server-ip47 src]# 

# 進入nginx-1.20.2 目錄,準備編譯參數
[root@lnp-server-ip47 src]# cd nginx-1.20.2
[root@lnp-server-ip47 nginx-1.20.2]# ./configure --prefix=/apps/nginx \
> --user=www \
> --group=www \
> --with-http_ssl_module \
> --with-http_v2_module \
> --with-http_realip_module \
> --with-http_stub_status_module \
> --with-http_gzip_static_module \
> --with-pcre \
> --with-stream \
> --with-stream_ssl_module \
> --with-stream_realip_module

[root@lnp-server-ip47 nginx-1.20.2]# make -j 8 && make install

##############################################################################
# 準備服務文件並啟動 nginx
[root@lnp-server-ip47 nginx-1.20.2]# vim /usr/lib/systemd/system/nginx.service
[root@lnp-server-ip47 nginx-1.20.2]# cat /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/apps/nginx/run/nginx.pid
ExecStart=/apps/nginx/sbin/nginx -c /apps/nginx/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s TERM $MAINPID

[Install]
WantedBy=multi-user.target
[root@lnp-server-ip47 nginx-1.20.2]#

# 創建目錄
[root@lnp-server-ip47 nginx-1.20.2]# mkdir /apps/nginx/run/

# 修改配置文件
[root@lnp-server-ip47 nginx-1.20.2]# vim /apps/nginx/conf/nginx.conf
# 僅修改下麵這行的內容
pid        /apps/nginx/run/nginx.pid; 

# 啟動並開機自啟服務
[root@lnp-server-ip47 wordpress]# systemctl daemon-reload
[root@lnp-server-ip47 wordpress]# systemctl enable --now nginx
[root@lnp-server-ip47 wordpress]# ss -tln
State       Recv-Q Send-Q    Local Address:Port         Peer Address:Port 
LISTEN      0      511       127.0.0.1:9000             *:*
LISTEN      0      511       *:80                       *:* 
             
[root@lnp-server-ip47 wordpress]#

4.2.2 配置 Nginx 支持 fastcgi

##############################################################################
#### 配置 Nginx 支持 fastcgi
[root@lnp-server-ip47 nginx-1.20.2]# vim /apps/nginx/conf/nginx.conf
# 僅僅修改下麵這些內容,其他都市預設值
worker_processes  auto;
pid        /apps/nginx/run/nginx.pid;
    server {
        listen       80;
        server_name  blog.shone.cn;
        location / {
        root /data/nginx/wordpress;
        index index.php index.html index.htm; 
        }

        location <sub> \.php$ {
            root /data/nginx/wordpress;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }

        location </sub> ^/(ping|pm_status)$ {
        include fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
        }

# 通過命令篩選出有效的配置行
[root@lnp-server-ip47 nginx-1.20.2]# grep -Ev '#|^$' /apps/nginx/conf/nginx.conf
worker_processes  auto;
pid        /apps/nginx/run/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  blog.shone.cn;    #指定功能變數名稱
        location / {
        root /data/nginx/wordpress;    #指定數據目錄
        index index.php index.html index.htm;    # 指定預設主頁文件
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        
        location <sub> \.php$ {                      #實現php-fpm
            root /data/nginx/wordpress;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
        }
        location </sub> ^/(ping|pm_status)$ {         #PHP檢測狀態頁
        include fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
        }
    }
}
[root@lnp-server-ip47 nginx-1.20.2]#

# 重新啟動 nginx 讓新配置文件生效
[root@lnp-server-ip47 php-fpm.d]# systemctl reload nginx
[root@lnp-server-ip47 php-fpm.d]# ss -ltn
State       Recv-Q Send-Q   Local Address:Port        Peer Address:Port 
LISTEN      0      511      127.0.0.1:9000             *:*  
LISTEN      0      511      *:80                       *:*  
    
[root@lnp-server-ip47 php-fpm.d]#

4.2.3 測試PHP工作是否正常

準備測試頁面

[root@lnp-server-ip47 php-fpm.d]# mkdir -p /data/nginx/wordpress
[root@lnp-server-ip47 php-fpm.d]# vim /data/nginx/wordpress/phpinfo.php
[root@lnp-server-ip47 php-fpm.d]# cat /data/nginx/wordpress/phpinfo.php
<?php
phpinfo();
?>

測試PHP的ping

file

查看狀態頁

file

5. 部署 WordPress

5.1 準備 WordPress 文件

# 下載源文件,並複製到前面定義的網頁目錄下,並修改權屬
[root@lnp-server-ip47 <sub>]# wget https://cn.wordpress.org/latest-zh_CN.tar.gz
[root@lnp-server-ip47 </sub>]# ll
total 19012
-rw-r--r--  1 root root 19462197 Mar 19 00:00 latest-zh_CN.tar.gz
[root@lnp-server-ip47 <sub>]# tar xf latest-zh_CN.tar.gz                       
[root@lnp-server-ip47 </sub>]# ll
total 19016
-rw-r--r--  1 root root 19462197 Mar 19 00:00 latest-zh_CN.tar.gz
drwxr-xr-x  5 1006 1006     4096 Mar 19 00:00 wordpress
[root@lnp-server-ip47 <sub>]# cp -r wordpress/* /data/nginx/wordpress
[root@lnp-server-ip47 </sub>]# chown -R www.www /data/nginx/wordpress/
[root@lnp-server-ip47 ~]#

5.2 初始化 WordPress

# 修改WIN10的本地hosts文件,路徑為  C:\Windows\System32\drivers\etc\hosts   在最後添加一行
192.168.250.47  blog.shone.cn

在瀏覽器內輸入 blog.shone.cn  出現可道雲的初始化嚮導,按照嚮導完成初始化

在瀏覽器內輸入 http://blog.shone.cn

file

file

file

file

file

file

file

file

6. 優化 WordPress

6.1 允許上傳大文件

#註意:預設只支持1M以下文件上傳,要利用php程式上傳大文件,需要修改下麵的配置,最大上傳由下列項值的最小值決定,直接上傳大於1M文件,會出現下麵413錯誤

[root@lnp-server-ip47 wordpress]# vim /apps/nginx/conf/nginx.conf
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"';

    #access_log  logs/access.log  main;
    client_max_body_size 100m;       #nginx上傳文件大小修改成100M,預設1M 
    .........
        



[root@lnp-server-ip47 wordpress]# vim /etc/php.ini
; http://php.net/post-max-size
;post_max_size = 8M              # 預設值為8M
post_max_size = 30M

;upload_max_filesize = 2M        # 預設值為2M
upload_max_filesize = 20M 



[root@lnp-server-ip47 wordpress]# systemctl restart nginx php-fpm

6.2 安全加固

# 關閉版本顯示
[root@lnp-server-ip47 wordpress]# grep -Ev '#|^$' /apps/nginx/conf/nginx.conf
worker_processes  auto;
pid        /apps/nginx/run/nginx.pid;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    client_max_body_size 100m;
    sendfile        on;
    
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  blog.shone.cn;
        server_tokens off;                             # 安全加固選項
        location / {
        root /data/nginx/wordpress;
        index index.php index.html index.htm; 
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        
        location <sub> \.php$ {
            root /data/nginx/wordpress;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            fastcgi_hide_header X-Powered-By;     # 安全加固選項
        }
        location </sub> ^/(ping|pm_status)$ {
        include fastcgi_params;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;
        }
    }
}
[root@lnp-server-ip47 wordpress]# 


# 關閉 PHP版本暴露
[root@lnp-server-ip47 wordpress]# vim /etc/php.ini
; http://php.net/expose-php
;expose_php = On                # 預設值為ON  可以在客戶端看到版本信息
expose_php = Off

file

6.3 配置 php 開啟 opcache 加速

[root@lnp-server-ip47 wordpress]# vim /etc/php.ini
.....................
[opcache]
; Determines if Zend OPCache is enabled
zend_extension=opcache.so 
opcache.enable=1
.......................

[root@lnp-server-ip47 wordpress]#systemctl restart php-fpm

本文轉自:https://blog.51cto.com/shone/5165650


您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • springboot微服務整合swagger3方法很簡單,下文會演示。但是在分散式項目中如果每個微服務都需要單獨的分開訪問獲取介面文檔就不方便了,本文將詳細講解springcloud gateway網關如何聚合統一管理swagger介面文檔。 先貼張整合後的效果圖(通過切換左上角的下拉視窗獲取每個微 ...
  • 如何才能寫好Python代碼?很多小伙伴都會問這樣的問題,今天這篇就來告訴大家怎樣寫好Python代碼。 程式設計的好與壞,早在我們青蔥歲月時就接觸過了,只是那是並不知道這竟如此重要。能夠立即改善程式設計、寫出“好”代碼的知識有以下幾點: •面向對象五個基本原則; •常見的三種架構; •繪圖; •起 ...
  • 大家好,我是棧長。 最近技術棧真是醉了,Log4j2 的核彈級漏洞剛告一段落,這個月初 Spring Cloud Gateway 又突發高危漏洞,現在連最要命的 Spring 框架也淪陷了。。。 棧長今天看到了一些安全機構發佈的相關漏洞通告,Spring 官方博客也發佈了漏洞聲明: 漏洞描述: 用戶 ...
  • 前言: 請各大網友尊重本人原創知識分享,謹記本人博客:南國以南i 上篇我們介紹到 保姆教程系列二、Nacos實現註冊中心 配置中心原理 一、 服務配置中心介紹 首先我們來看一下,微服務架構下關於配置文件的一些問題: 配置文件相對分散。在一個微服務架構下,配置文件會隨著微服務的增多變的越來越多,而且分 ...
  • Python之所以能夠成為流行的數據分析語言,有一部分原因在於其簡潔易用的字元串處理能力。 Python的字元串對象封裝了很多開箱即用的內置方法,處理單個字元串時十分方便;對於Excel、csv等表格文件中整列的批量字元串操作,pandas庫也提供了簡潔高效的處理函數,幾乎與內置字元串函數一一對應。 ...
  • 昨天凌晨發了篇關於Spring大漏洞的推文,白天就有不少小伙伴問文章怎麼刪了。 主要是因為收到朋友提醒說可能發這個會違規(原因可參考:阿裡雲因發現Log4j2核彈級漏洞但未及時上報,被工信部處罰),所以就刪除了。 經過一天的時間,似乎這個事情變得有點看不懂了。所以下麵聊聊這個網傳的Spring大漏洞 ...
  • 在學習net core中接觸到了swagger、學習並記錄 純API項目中 引入swagger可以生成可視化的API介面頁面 引入包 nuget包: Swashbuckle.AspNetCore(最新穩定版) 配置 1.配置Startup類ConfigureServices方法的相關配置 1 pub ...
  • 故事背景 在linux開發中我們經常會用到dbus來進行進程間通信,但是如何理解dbus服務端和客戶端呢?很多小伙伴可能都會遇到類似的問題,而且都是含含糊糊的,接下來我們直接上硬菜。 探索之路 首先要明白dbus是什麼,有什麼作用? 如何把自己的程式做成dbus服務? 如何調用dbus介面? 經驗心 ...
一周排行
    -Advertisement-
    Play Games
  • 示例項目結構 在 Visual Studio 中創建一個 WinForms 應用程式後,項目結構如下所示: MyWinFormsApp/ │ ├───Properties/ │ └───Settings.settings │ ├───bin/ │ ├───Debug/ │ └───Release/ ...
  • [STAThread] 特性用於需要與 COM 組件交互的應用程式,尤其是依賴單線程模型(如 Windows Forms 應用程式)的組件。在 STA 模式下,線程擁有自己的消息迴圈,這對於處理用戶界面和某些 COM 組件是必要的。 [STAThread] static void Main(stri ...
  • 在WinForm中使用全局異常捕獲處理 在WinForm應用程式中,全局異常捕獲是確保程式穩定性的關鍵。通過在Program類的Main方法中設置全局異常處理,可以有效地捕獲並處理未預見的異常,從而避免程式崩潰。 註冊全局異常事件 [STAThread] static void Main() { / ...
  • 前言 給大家推薦一款開源的 Winform 控制項庫,可以幫助我們開發更加美觀、漂亮的 WinForm 界面。 項目介紹 SunnyUI.NET 是一個基於 .NET Framework 4.0+、.NET 6、.NET 7 和 .NET 8 的 WinForm 開源控制項庫,同時也提供了工具類庫、擴展 ...
  • 說明 該文章是屬於OverallAuth2.0系列文章,每周更新一篇該系列文章(從0到1完成系統開發)。 該系統文章,我會儘量說的非常詳細,做到不管新手、老手都能看懂。 說明:OverallAuth2.0 是一個簡單、易懂、功能強大的許可權+可視化流程管理系統。 有興趣的朋友,請關註我吧(*^▽^*) ...
  • 一、下載安裝 1.下載git 必須先下載並安裝git,再TortoiseGit下載安裝 git安裝參考教程:https://blog.csdn.net/mukes/article/details/115693833 2.TortoiseGit下載與安裝 TortoiseGit,Git客戶端,32/6 ...
  • 前言 在項目開發過程中,理解數據結構和演算法如同掌握蓋房子的秘訣。演算法不僅能幫助我們編寫高效、優質的代碼,還能解決項目中遇到的各種難題。 給大家推薦一個支持C#的開源免費、新手友好的數據結構與演算法入門教程:Hello演算法。 項目介紹 《Hello Algo》是一本開源免費、新手友好的數據結構與演算法入門 ...
  • 1.生成單個Proto.bat內容 @rem Copyright 2016, Google Inc. @rem All rights reserved. @rem @rem Redistribution and use in source and binary forms, with or with ...
  • 一:背景 1. 講故事 前段時間有位朋友找到我,說他的窗體程式在客戶這邊出現了卡死,讓我幫忙看下怎麼回事?dump也生成了,既然有dump了那就上 windbg 分析吧。 二:WinDbg 分析 1. 為什麼會卡死 窗體程式的卡死,入口門檻很低,後續往下分析就不一定了,不管怎麼說先用 !clrsta ...
  • 前言 人工智慧時代,人臉識別技術已成為安全驗證、身份識別和用戶交互的關鍵工具。 給大家推薦一款.NET 開源提供了強大的人臉識別 API,工具不僅易於集成,還具備高效處理能力。 本文將介紹一款如何利用這些API,為我們的項目添加智能識別的亮點。 項目介紹 GitHub 上擁有 1.2k 星標的 C# ...