搭建lamp架構

来源:https://www.cnblogs.com/Their-own/archive/2022/08/02/16543616.html
-Advertisement-
Play Games

搭建lamp架構 1.LAMP架構介紹 所謂lamp,其實就是由Linux+Apache+Mysql/MariaDB+Php/Perl/Python的一組動態網站或者伺服器的開源軟體,除Linux外其它各部件本身都是各自獨立的程式,但是因為經常被放在一起使用,擁有了越來越高的相容度,共同組成了一個強 ...


搭建lamp架構

目錄

1.LAMP架構介紹

所謂lamp,其實就是由Linux+Apache+Mysql/MariaDB+Php/Perl/Python的一組動態網站或者伺服器的開源軟體,除Linux外其它各部件本身都是各自獨立的程式,但是因為經常被放在一起使用,擁有了越來越高的相容度,共同組成了一個強大的Web應用程式平臺。

LAMP指的是Linux(操作系統)、Apache(HTTP伺服器)、MySQL(也指MariaDB,資料庫軟體)和PHP(有時也是指Perl或Python)的第一個字母,一般用來建立web應用平臺。

2.架構說明

LAMP架構說明.png

apache主要實現如下功能:

第一:處理http的請求、構建響應報文等自身服務;

第二:配置讓Apache支持PHP程式的響應(通過PHP模塊或FPM);

第三:配置Apache具體處理php程式的方法,如通過反向代理將php程式交給fcgi處理。

mariadb主要實現如下功能:

第一:提供PHP程式對數據的存儲;

第二:提供PHP程式對數據的讀取(通常情況下從性能的角度考慮,儘量實現資料庫的讀寫分離)。

php主要實現如下功能:

第一:提供apache的訪問介面,即CGI或Fast CGI(FPM);

第二:提供PHP程式的解釋器;

第三:提供mairadb資料庫的連接函數的基本環境。

由此可知,要實現LAMP在配置每一個服務時,安裝功能需求進行配置,即可實現LAMP的架構,當然apache、mariadb和php服務都可配置為獨立服務,安裝在不同伺服器之上。

3.lamp平臺搭建

環境說明

系統平臺 IP 需要安裝的服務
centos8 192.168.111.135 http
mysql
php
php-mysql

lamp平臺軟體安裝次序:

http - - > mysql - - > php			//順序不可逆

註意:php要求httpd使用prefork MPM

阿裡雲

需要配置一個epel源

[root@localhost ~]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
[root@localhost ~]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@localhost ~]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*

3.1 編譯安裝httpd

//先下載需要的依賴包
[root@localhost ~]# dnf -y groupinstall "Development Tools" --allowerasing
[root@localhost ~]# dnf -y install wget openssl-devel pcre-devel expat-devel libtool libxml2-devel make gcc gcc-c++

//創建一個apache的用戶
[root@localhost ~]# useradd -r -M -s /sbin/nologin apache
[root@localhost ~]# id apache
uid=994(apache) gid=991(apache) groups=991(apache)

//wget下載安裝httpd所需要的包
[root@localhost ~]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz https://downloads.apache.org/httpd/httpd-2.4.54.tar.gz
[root@localhost ~]# ls
anaconda-ks.cfg  apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.54.tar.gz

//解壓並編譯
[root@localhost ~]# tar xf apr-1.7.0.tar.gz 
[root@localhost ~]# tar xf apr-util-1.6.1.tar.gz 
[root@localhost ~]# tar xf httpd-2.4.54.tar.gz 
[root@localhost ~]# ls
anaconda-ks.cfg  apr-1.7.0  apr-1.7.0.tar.gz  apr-util-1.6.1  apr-util-1.6.1.tar.gz  httpd-2.4.54  httpd-2.4.54.tar.gz

//進入apr-1.7.0的configure刪除這一行或者註釋這一行
[root@localhost ~]# cd apr-1.7.0
[root@localhost apr-1.7.0]# vim configure
cfgfile=${ofile}T
    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
    #$RM "$cfgfile"			//註釋這行

//編譯apr
[root@localhost apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.7.0]# make && make install

//編譯apr-util
[root@localhost httpd-2.4.54]# cd ../apr-util-1.6.1
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
[root@localhost apr-util-1.6.1]# make && make install

//編譯httpd
[root@localhost ~]# cd httpd-2.4.54
[root@localhost httpd-2.4.54]# ./configure --prefix=/usr/local/apache --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-rpm=prefork
[root@localhost httpd-2.4.54]# make && make install

//配置環境變數
[root@localhost ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/apache.sh
[root@localhost ~]# source /etc/profile.d/apache.sh
[root@localhost ~]# which apachectl
/usr/local/apache/bin/apachectl

//創建頭文件軟連接
[root@localhost ~]# ln -s /usr/local/apache/include/ /usr/include/apache

//添加幫助文檔
[root@localhost ~]# vim /etc/man_db.conf 
MANDATORY_MANPATH                       /usr/man
MANDATORY_MANPATH                       /usr/share/man
MANDATORY_MANPATH                       /usr/local/share/man
MANDATORY_MANPATH                       /usr/local/apache/man		//添加

//取消警報
[root@localhost ~]# vim /usr/local/apache/conf/httpd.conf
ServerName www.example.com:80 		//取消這行註釋

//編寫控制腳本
[root@localhost ~]# cd /usr/lib/systemd/system/
[root@localhost system]# cp sshd.service httpd.service
[root@localhost system]# vim httpd.service 
[Unit]
Description=httpd server daemon
After=network.target sshd-keygen.target

[Service]
Type=forking
ExecStart=/usr/local/apache/bin/apachectl start
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/usr/local/apache/bin/apachectl stop

[Install]
WantedBy=multi-user.target
[root@localhost ~]# systemctl daemon-reload			//刷新一下

//設置開機自啟動
[root@localhost ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# ss -anlt
State            Recv-Q           Send-Q                     Local Address:Port                     Peer Address:Port           Process           
LISTEN           0                128                              0.0.0.0:22                            0.0.0.0:*                                
LISTEN           0                128                                    *:80                                  *:*                                
LISTEN           0                128                                 [::]:22                               [::]:*                                

//關閉防火牆和selinux
[root@localhost ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# vim /etc/selinux/config 
SELINUX=disabled
[root@localhost ~]# setenforce 0

3.2 二進位安裝mysql

//安裝依賴包
[root@localhost ~]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel ncurses-compat-libs

//創建用戶
[root@localhost ~]# useradd -r -M -s /sbin/nologin mysql
[root@localhost ~]# id mysql
uid=993(mysql) gid=990(mysql) groups=990(mysql)

//下載二進位包
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz

//解壓軟體包
[root@localhost src]# tar xf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz -C /usr/local/

//更改軟體名,更改屬主屬組
[root@localhost src]# cd /usr/local/
[root@localhost local]# mv mysql-5.7.38-linux-glibc2.12-x86_64 mysql
[root@localhost local]# chown -R mysql.mysql mysql*
[root@localhost local]# ll -d mysql
drwxr-xr-x. 9 mysql mysql 129 Aug  2 19:08 mysql

//配置環境變數
[root@localhost local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost local]# source /etc/profile.d/mysql.sh

//創建頭文件
[root@localhost local]# ln -s /usr/local/mysql/include /usr/include/mysql

//添加幫助文檔
[root@localhost ~]# vim /etc/man_db.conf 
MANDATORY_MANPATH                       /usr/man
MANDATORY_MANPATH                       /usr/share/man
MANDATORY_MANPATH                       /usr/local/share/man
MANDATORY_MANPATH                       /usr/local/apache/man
MANDATORY_MANPATH                       /usr/local/mysql/man		//添加

//創建庫文件
[root@localhost ~]# vim /etc/ld.so.conf.d/mysql.conf
[root@localhost ~]# cat /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib/
[root@localhost ~]# ldconfig 

//創建數據存放目錄
[root@localhost ~]# mkdir /opt/data
[root@localhost ~]# chown -R mysql.mysql /opt/data/
[root@localhost ~]# ll -d /opt/data/
drwxr-xr-x. 2 mysql mysql 6 Aug  2 19:13 /opt/data/

//初始化
[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data/
2022-08-02T11:33:30.837163Z 0 [Warning] CA certificate ca.pem is self signed.
2022-08-02T11:33:30.882575Z 1 [Note] A temporary password is generated for root@localhost: ,%//ikYZV3tZ		//最後一行會生成臨時密碼
[root@localhost ~]# echo ',%//ikYZV3tZ' > passwd		//記錄一下密碼

//編寫配置文件
[root@localhost ~]# dnf -y remove mariadb*
[root@localhost ~]# vim /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve

//編寫服務控制腳本
[root@localhost ~]# cd /usr/lib/systemd/system/
[root@localhost system]# cp httpd.service mysqld.service
[root@localhost system]# vim mysqld.service 
[Unit]
Description=mysql server daemon
After=network.target sshd-keygen.target

[Service]
Type=forking
ExecStart=/usr/local/mysql/support-files/mysql.server start
ExecStop=/usr/local/mysql/support-files/mysql.server stop
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target
[root@localhost ~]# systemctl daemon-reload		//刷新一下

//設置開機自啟
[root@localhost ~]# systemctl enable --now mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
[root@localhost ~]# ss -anlt
State            Recv-Q           Send-Q                     Local Address:Port                     Peer Address:Port           Process           
LISTEN           0                128                              0.0.0.0:22                            0.0.0.0:*                                
LISTEN           0                80                                     *:3306                                *:*                                
LISTEN           0                128                                    *:80                                  *:*                                
LISTEN           0                128                                 [::]:22                               [::]:*                                

//設置密碼
[root@localhost ~]# cat passwd 
,%//ikYZV3tZ
[root@localhost ~]# mysql -uroot -p',%//ikYZV3tZ'
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 2
Server version: 5.7.38

Copyright (c) 2000, 2022, 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> set password = password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)

//登錄查看是否修改成功
[root@localhost ~]# mysql -uroot -p123456
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 3
Server version: 5.7.38 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, 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> 

3.3 編譯安裝php

//下載php軟體包
[root@localhost ~]# cd /usr/src/
[root@localhost src]# wget https://www.php.net/distributions/php-7.4.30.tar.gz

//解壓軟體包
[root@localhost src]# tar xf php-7.4.30.tar.gz 
[root@localhost src]# ls
debug  kernels  mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz  php-7.4.30  php-7.4.30.tar.gz

//安裝依賴包
[root@localhost ~]# yum -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libicu-devel libjpeg libjpeg-devel libpng libpng-devel openldap-devel  pcre-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel mhash mhash-devel php-mysqlnd
[root@localhost ~]# yum -y install http://mirror.centos.org/centos/8-stream/PowerTools/x86_64/os/Packages/oniguruma-devel-6.8.2-2.el8.x86_64.rpm
[root@localhost ~]# dnf -y install libsqlite3x-devel
[root@localhost ~]# dnf -y install libzip-devel

//編譯安裝
[root@localhost ~]# cd /usr/src/
[root@localhost src]# cd php-7.4.30
[root@localhost php-7.4.30]# ./configure --prefix=/usr/local/php7  \
--with-config-file-path=/etc \
--enable-fpm \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-openssl \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--enable-exif  \
--enable-ftp \
--enable-gd \
--with-jpeg \
--with-zlib-dir \
--with-freetype \
--with-gettext \
--enable-json \
--enable-mbstring \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-readline \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--with-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-pcntl \
--enable-posix
[root@localhost php-7.4.30]# make && make install

//配置環境變數
[root@localhost local]# echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php.sh
[root@localhost local]# source /etc/profile.d/php.sh
[root@localhost local]# which php
/usr/local/php7/bin/php
[root@localhost php-7.4.30]# php -v
PHP 7.4.30 (cli) (built: Aug  2 2022 22:27:01) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

//配置php-fpm
[root@localhost php-7.4.30]# cp php.ini-production /etc/php.ini
cp: overwrite '/etc/php.ini'? y
[root@localhost php-7.4.30]# cd sapi/
[root@localhost sapi]# cd fpm/
[root@localhost fpm]# file init.d.php-fpm
init.d.php-fpm: POSIX shell script, ASCII text executable
[root@localhost fpm]# cp init.d.php-fpm /etc/init.d/php-fpm
[root@localhost fpm]# chmod +x /etc/init.d/php-fpm
[root@localhost fpm]# cd /usr/local/php7/
[root@localhost php7]# ls
bin  etc  include  lib  php  sbin  var
[root@localhost php7]# cd etc/
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# ls
pear.conf  php-fpm.conf  php-fpm.conf.default  php-fpm.d
[root@localhost etc]# cd php-fpm.d/
[root@localhost php-fpm.d]# ls
www.conf.default
[root@localhost php-fpm.d]# cp www.conf.default www.conf
[root@localhost php-fpm.d]# ls
www.conf  www.conf.default

//編輯php-fpm的配置文件(/usr/local/php7/etc/php-fpm.conf):
//配置fpm的相關選項為你所需要的值:
[root@localhost ~]# vim /usr/local/php7/etc/php-fpm.conf
[root@localhost ~]# tail /usr/local/php7/etc/php-fpm.conf
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; Relative path can also be used. They will be prefixed by:
;  - the global prefix if it's been set (-p argument)
;  - /usr/local/php7 otherwise
include=/usr/local/php7/etc/php-fpm.d/*.conf
pm.max_children = 50		//最多同時提供50個進程提供50個併發服務
pm.start_servers = 5		//啟動時啟動5個進程
pm.min_spare_servers = 2	//最小空閑進程數
pm.max_spare_servers = 8	//最大空閑進程數

//取消httpd.conf的註釋,啟動httpd的相關模塊
[root@localhost php-fpm.d]# vim /usr/local/apache/conf/httpd.conf 
#LoadModule proxy_module modules/mod_proxy.so				//取消井號
#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so		//取消井號

//編寫測試文件
[root@localhost ~]# rm -rf /usr/local/apache/htdocs/index.html 
[root@localhost ~]# vim /usr/local/apache/htdocs/index.php
[root@localhost ~]# cat /usr/local/apache/htdocs/index.php
<?php
   phpinfo();
?>
[root@localhost ~]# chown -R apache.apache /usr/local/apache/htdocs/
[root@localhost ~]# ll -d /usr/local/apache/htdocs/
drwxr-xr-x. 3 apache apache 39 Aug  2 22:45 /usr/local/apache/htdocs/

//配置虛擬主機
[root@localhost ~]# vim /usr/local/apache/conf/httpd.conf 
//在配置文件的最後加入以下內容
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs"
    ServerName www.zxr.com
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/$1
    <Directory "/usr/local/apache/htdocs">
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>

[root@localhost ~]# vim /usr/local/apache/conf/httpd.conf 
//搜索ADDType,添加以下內容
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    AddType application/x-httpd-php .php				//添加此行
    AddType application/x-httpd-php-source .phps		//添加此行


//啟動php httpd
[root@localhost local]# service php-fpm start
Starting php-fpm  done
[root@localhost ~]# service php-fpm --full-restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done
[root@localhost local]# systemctl restart httpd
[root@localhost local]# ss -anlt
State            Recv-Q           Send-Q                     Local Address:Port                     Peer Address:Port           Process           
LISTEN           0                128                            127.0.0.1:9000                          0.0.0.0:*                                
LISTEN           0                128                              0.0.0.0:22                            0.0.0.0:*                                
LISTEN           0                80                                     *:3306                                *:*                                
LISTEN           0                128                                    *:80                                  *:*                                
LISTEN           0                128                                 [::]:22                               [::]:*                                

3.4 查看結果

image

編譯安裝php報錯

Package 'sqlite3', required by 'virtual:world', not found
//解決方法
[root@localhost ~]# dnf -y install libsqlite3x-devel
Package 'libzip', required by 'virtual:world', not found
//解決方法
[root@localhost ~]# dnf -y install libzip-devel

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

-Advertisement-
Play Games
更多相關文章
  • 基礎確認:HTML、CSS、JavaScript AJAX可以: 不刷新頁面更新網頁 在頁面載入後從伺服器請求數據 在頁面載入後從伺服器接收數據 在後臺向伺服器發送數據 Ajax 的核心是 XMLHttpRequest 對象,用於和伺服器交換數據。 xmlhttp.open("GET","ajax_ ...
  • 多商戶商城系統,也稱為B2B2C(BBC)平臺電商模式多商家商城系統。可以快速幫助企業搭建類似拼多多/京東/天貓/淘寶的綜合商城。 多商戶商城系統支持商家入駐加盟,同時滿足平臺自營、旗艦店等多種經營方式。平臺可以通過收取商家入駐費,訂單交易服務費,提現手續費,簡訊通道費等多手段方式,實現整體盈利。 ...
  • 3 hashCode的內幕 tips:面試常問/常用/常出錯 hashCode到底是什麼?是不是對象的記憶體地址? 1) 直接用記憶體地址? 目標:通過一個Demo驗證這個hasCode到底是不是記憶體地址 public native int hashCode(); com.hashcode.HashCo ...
  • 函數 封裝功能,提高應用的模塊性和代碼重用率 1. 定義函數 1.1 函數內的第一條語句是字元串時,該字元串就是文檔字元串(docstring) def my_fun(): '''我是文檔字元串 函數內第一句是字元串時 該字元串就是文檔字元串 ''' pass print(my_fun.__doc_ ...
  • 前言 做了幾道關於defer的測試題,嚇了一大跳,感覺自己之前的理解有些問題,所以寫下這篇博客,加深下印象。 正文: 多個defer的執行順序: 先進後出,類似於棧的特性。 下麵我們來測試下: 1.defer 與 panic: func deferAndPanic() { defer func() ...
  • 前言 接著上周寫的截圖控制項繼續更新 繪製箭頭。 1.WPF實現截屏「仿微信」 2.WPF 實現截屏控制項之移動(二)「仿微信」 3.WPF 截圖控制項之伸縮(三) 「仿微信」 4.WPF 截圖控制項之繪製方框與橢圓(四) 「仿微信」 正文 一、首先接著ScreenCut繼續發電。 1)繪製箭頭因為需要只修 ...
  • 此案例基於拖曳和彈動球兩個技術功能實現,如有不懂的可以參考之前的相關文章,屬於遞進式教程。 五環彈動球 好吧,名字是我起的,其實,你可以任意個球進行聯動彈動,效果還是很不錯的,有很多前端都是基於這個特效,可以搞出一些很有科技感的效果出來。 Wpf 和 SkiaSharp 新建一個WPF項目,然後,N ...
  • lamp 1. lamp簡介 lamp,其實就是由Linux+Apache+Mysql/MariaDB+Php/Perl/Python的一組動態網站或者伺服器的開源軟體 LAMP指的是Linux(操作系統)、Apache(HTTP伺服器)、MySQL(也指MariaDB,資料庫軟體)和PHP(有時也 ...
一周排行
    -Advertisement-
    Play Games
  • Dapr Outbox 是1.12中的功能。 本文只介紹Dapr Outbox 執行流程,Dapr Outbox基本用法請閱讀官方文檔 。本文中appID=order-processor,topic=orders 本文前提知識:熟悉Dapr狀態管理、Dapr發佈訂閱和Outbox 模式。 Outbo ...
  • 引言 在前幾章我們深度講解了單元測試和集成測試的基礎知識,這一章我們來講解一下代碼覆蓋率,代碼覆蓋率是單元測試運行的度量值,覆蓋率通常以百分比表示,用於衡量代碼被測試覆蓋的程度,幫助開發人員評估測試用例的質量和代碼的健壯性。常見的覆蓋率包括語句覆蓋率(Line Coverage)、分支覆蓋率(Bra ...
  • 前言 本文介紹瞭如何使用S7.NET庫實現對西門子PLC DB塊數據的讀寫,記錄了使用電腦模擬,模擬PLC,自至完成測試的詳細流程,並重點介紹了在這個過程中的易錯點,供參考。 用到的軟體: 1.Windows環境下鏈路層網路訪問的行業標準工具(WinPcap_4_1_3.exe)下載鏈接:http ...
  • 從依賴倒置原則(Dependency Inversion Principle, DIP)到控制反轉(Inversion of Control, IoC)再到依賴註入(Dependency Injection, DI)的演進過程,我們可以理解為一種逐步抽象和解耦的設計思想。這種思想在C#等面向對象的編 ...
  • 關於Python中的私有屬性和私有方法 Python對於類的成員沒有嚴格的訪問控制限制,這與其他面相對對象語言有區別。關於私有屬性和私有方法,有如下要點: 1、通常我們約定,兩個下劃線開頭的屬性是私有的(private)。其他為公共的(public); 2、類內部可以訪問私有屬性(方法); 3、類外 ...
  • C++ 訪問說明符 訪問說明符是 C++ 中控制類成員(屬性和方法)可訪問性的關鍵字。它們用於封裝類數據並保護其免受意外修改或濫用。 三種訪問說明符: public:允許從類外部的任何地方訪問成員。 private:僅允許在類內部訪問成員。 protected:允許在類內部及其派生類中訪問成員。 示 ...
  • 寫這個隨筆說一下C++的static_cast和dynamic_cast用在子類與父類的指針轉換時的一些事宜。首先,【static_cast,dynamic_cast】【父類指針,子類指針】,兩兩一組,共有4種組合:用 static_cast 父類轉子類、用 static_cast 子類轉父類、使用 ...
  • /******************************************************************************************************** * * * 設計雙向鏈表的介面 * * * * Copyright (c) 2023-2 ...
  • 相信接觸過spring做開發的小伙伴們一定使用過@ComponentScan註解 @ComponentScan("com.wangm.lifecycle") public class AppConfig { } @ComponentScan指定basePackage,將包下的類按照一定規則註冊成Be ...
  • 操作系統 :CentOS 7.6_x64 opensips版本: 2.4.9 python版本:2.7.5 python作為腳本語言,使用起來很方便,查了下opensips的文檔,支持使用python腳本寫邏輯代碼。今天整理下CentOS7環境下opensips2.4.9的python模塊筆記及使用 ...