編譯httpd細節

来源:http://www.cnblogs.com/f-ck-need-u/archive/2017/09/28/7605563.html
-Advertisement-
Play Games

本文目錄1.1 下載和解決依賴關係1.2 httpd編譯選項1.3 模塊動靜態編譯1.4 動靜態編譯的優先順序規則1.5 MPM的安裝1.6 關於"--enable-so"1.7 開始編譯httpd1.8 編譯後的規範操作 1.1 下載和解決依賴 以httpd 2.4.27為例。 資源下載: apac ...


本文目錄
1.1 下載和解決依賴關係
1.2 httpd編譯選項
1.3 模塊動靜態編譯
1.4 動靜態編譯的優先順序規則
1.5 MPM的安裝
1.6 關於"--enable-so"
1.7 開始編譯httpd
1.8 編譯後的規範操作

1.1 下載和解決依賴

以httpd 2.4.27為例。

資源下載:

apache自己的站點提供了基金會下所有的(包括所有版本)資源,包括httpd。

地址:http://archive.apache.org/dist/
httpd下載地址:http://archive.apache.org/dist/httpd

清華大學有一個httpd歸檔的鏡像站點,裡面提供最新測試版和最新穩定版的下載,還提供一些依賴包或模塊的下載。

地址:http://mirrors.tuna.tsinghua.edu.cn/apache/httpd/
apache基金會下所有資源地址:http://mirrors.tuna.tsinghua.edu.cn/apache/

httpd同樣使用"./configure"、"make && make install"的編譯流程編譯。但是它有一些依賴包需要提前裝好。官方上指定的依賴環境有:apr、apr-util、pcre、pcre-devle,此外還需要expat-devel包。其中pcre、pcre-devel和expat.devel可以直接使用yum安裝,apr和apr-util需要編譯安裝。下載地址可以從站點 http://mirrors.tuna.tsinghua.edu.cn/apache/ap/ 找到。

yum -y install pcre pcre-devel expat-devel

以下是編譯apr和apr-util的過程。

tar xf apr-1.6.2.tar.gz
tar xf arp-1.6.0.tar.gz
cd apr-1.6.0
./configure --prefix=/usr/local/apr 
make
make install
cd ../apr-util-1.6.2
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install

然後是編譯httpd,httpd編譯對剛接觸的人來說可能有些麻煩,因為編譯選項太多,其中的一些"潛規則"也不太熟悉。所以下麵詳細地說明說明。

1.2 httpd編譯選項

httpd的編譯選項非常多。以下是截取./configure -h中的一部分,使用"......"表示省略了一堆信息。

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local/apache2]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/apache2/bin', `/usr/local/apache2/lib' etc.  You can specify
an installation prefix other than `/usr/local/apache2' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
........................................

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  --target=TARGET   configure for building compilers for TARGET [HOST]

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --enable-layout=LAYOUT
  --enable-dtrace         Enable DTrace probes
  --enable-hook-probes    Enable APR hook probes
  --enable-exception-hook Enable fatal exception hook
  --enable-load-all-modules
                          Load all modules
  --enable-maintainer-mode
                          Turn on debugging and compile time warnings and load
                          all compiled modules
  --enable-debugger-mode  Turn on debugging and compile time warnings and turn
                          off optimization
  --enable-pie            Build httpd as a Position Independent Executable
  --enable-modules=MODULE-LIST
                          Space-separated list of modules to enable | "all" |
                          "most" | "few" | "none" | "reallyall"
  --enable-mods-shared=MODULE-LIST
                          Space-separated list of shared modules to enable |
                          "all" | "most" | "few" | "reallyall"
  --enable-mods-static=MODULE-LIST
                          Space-separated list of static modules to enable |
                          "all" | "most" | "few" | "reallyall"
.........................................

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-included-apr     Use bundled copies of APR/APR-Util
  --with-apr=PATH         prefix for installed APR or the full path to
                             apr-config
  --with-apr-util=PATH    prefix for installed APU or the full path to
                             apu-config
  --with-pcre=PATH        Use external PCRE library
....................

以下是一個編譯配置:

./configure --prefix=/usr/local/apache --sysconfdir=/etc/apache --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-modules=most --enable-mpms-shared=all --with-z --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-mpm=event

但這個配置中有些項是多餘的,以下是等價編譯配置:

./configure --prefix=/usr/local/apache --sysconfdir=/etc/apache --enable-mpms-shared=all --with-z --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-mpm=event

具體哪些項多餘,看完下麵的1.3-1.6就知道了。

1.3 模塊動靜態編譯

httpd是高度模塊化的程式,各個功能通過載入各個模塊來實現。但前提是將功能對應的模塊先編譯好,以供httpd載入。

httpd對模塊有兩種編譯方式:靜態編譯和動態編譯。

  • 靜態編譯:將模塊直接編譯進httpd的核心中。靜態編譯的所有模塊都會隨著httpd的啟動和啟動。
  • 動態編譯:將模塊編譯好,但不編譯到httpd的核心中。要啟動動態編譯的模塊,需要在httpd的配置文件中使用LoadModule指令載入。

httpd的一個優點是可以實現動態模塊的熱插拔。因為httpd是獨立於終端的守護進程,可以通過發送HUP信號給httpd讓其重讀配置文件。而是否載入動態編譯模塊正是由httpd配置文件中的LoadModule指令決定的。當想要載入某個模塊A時(即模塊熱插),使用LoadModule指定A模塊的鏈接地址,再發送HUP信號重讀配置文件即可。而想要停止某個模塊A時(即模塊熱拔),只需將對應模塊的LoadModule指令行給註釋,再重讀配置文件即可。

甚至,可以隨時動態編譯某個外部模塊到httpd中,然後再熱插。因為何時編譯需要動態載入的模塊對httpd來說是無關緊要的,它只需LoadModule和重讀配置文件兩個過程對模塊進行控制。

在編譯選項中,有幾種類型的選項:

--disable-FEATURE:禁用某特性,等價於--enable-FEATURE=no
--enable-FEATURE[=ARG]:啟用某特性,預設參數值為YES
--enable-Module_Name=shared:指定的模塊Module_Name以動態編譯方式安裝
--enable-Module_Name=static:指定的模塊Module_Name以靜態編譯方式安裝

對於./configure --help中給定的選項,如果該選項是--disable的,那麼表示該選項預設是啟用的,需要顯式使用--disable選項禁用;如果該選項是--enable的,那麼表示該選項預設是禁用的,需要使用--enable選項來啟用。例如:

--disable-authz-user  :表示authz-user特性預設啟用,編譯時無需指定該項。如果要禁用,編譯時需顯式指定--disable-authz-user
--enable-echo    :表示echo特性預設是禁用的,如果要啟用,則編譯時需顯式指定--enable-echo

模塊名的書寫是有規則的,一般模塊的全稱類似於"mod_BASENAME.so"格式,例如"mod_charset_lite.so",但在編譯選項中指定模塊時,只需指定BASENAME,且如果basename中包含下劃線時,需要轉換為短橫線。例如"--enable-echo"表示編譯的模塊是"mod_echo.so"。

此外,還支持3種列表方式的動靜態編譯選項:列表項之間使用空格分隔,但要使用單引號包圍。

--enable-modules='Module_Name1 Moduel_Name2'
--enable-mods-shared='Module_Name1 Module_Name2'
--enable-mods-statics='Module_Name1 Module_Name2'

列表部分還可以使用關鍵字"all/few/most/reallyall"。分別表示編譯所有、少量、大多數、真正的所有模塊。

"--enable-modules"基本等價於"--enable-mods-shared",都是動態編譯給定列表中的模塊,但"--enable-modules"可以額外使用一個關鍵字"none",表示不編譯所有模塊。

1.4 動靜態編譯的優先順序規則

httpd動靜態模塊編譯有一套規則,各種動靜態便宜選項之間有優先順序的存在。例如,某個非核心模塊既指定了動態編譯,同時又指定了靜態編譯,那到底是靜態還是動態編譯?

以下是我總結的一些優先順序規則。

  1. 不指定任何模塊編譯選項時,預設的選項為"--enable-mods-shared",而該選項的預設值又是most,所以等價於"--enable-mods-shared=most"。
  2. 顯式指定要動態或靜態編譯的優先順序最高。有以下幾種方式顯式指定:
    --enable-Module_Name=shared 
    --enable-Module_Name=static 
    --enable-mods-shared='Module_Name1 Module_Name2'
    --enable-mods-statics='Module_Name1 Module_Name2'
    --enable-modules='Module_Name1 Moduel_Name2'
    
    如果某個模塊既顯式指定了動態,又顯式指定了靜態編譯,則靜態編譯優先順序更高。例如:
    --enable-echo=shared
    --enable-echo=static
    
    那麼,mod_echo模塊將被靜態編譯。
  3. 指定了關鍵字(all/most/few/reallyall)的"--enable-mods-static"選項,優先順序高於指定或未指定關鍵字的"--enable-mods-shared"和"--enable-modules"選項,即靜態關鍵字規則強於動態關鍵字規則。
    例如,下麵兩個編譯配置中,都是"--enable-mods-static=few"生效。第二個編譯配置語句中將忽略"--enable-mods-shared=all"。
    ./configure --prefix=/tmp/apache --enable-mods-static=few
    ./configure --prefix=/tmp/apache --enable-mods-static=few --enable-mods-shared=all
    
    對於下麵的例子,authn-file和echo這兩個模塊既指定了動態編譯又指定了靜態編譯,靜態優先順序高於動態,所以這兩個模塊靜態被靜態編譯。由於沒有使用關鍵字,所以會使用預設的"--enable-mods-shared=most"配置。即動態編譯大部分,但指定的這兩個模塊被靜態編譯。
    ./configure --prefix=/tmp/apache \
    --enable-mods-static='authn-file echo' --enable-mods-shared='authn-file echo'
    
    而下麵這個例子由於額外指定了使用"--enable-mods-static=few"選項,其優先順序高於預設的"--enable-mods-shared=most",所以結果是靜態編譯few,且顯式指定的兩個模塊也被靜態編譯。
    ./configure --prefix=/tmp/apache \
    --enable-mods-static='authn-file echo' \
    --enable-mods-shared='authn-file echo' \
    --enable-mods-static=few
    
  4. 使用了關鍵字的"--enable-mods-static"、"--enable-mods-shared "和"--enable-modules"的選項,隱含了"沒有指定何種編譯方式的模塊"的預設編譯方式。
    例如下麵的編譯配置,"--enable-mods-static"指定了關鍵字few,它將優先於預設的配置規則"--enable-mods-shared=most",所以沒有指定編譯方式的模塊"data"將以靜態的方式編譯。
    ./configure --prefix=/tmp/apache --enable-mods-static=few --enable-data
    
    下麵的配置如何編譯的?由於預設的是"--enable-mods-shared=most"編譯方式,所以模塊"data"將以動態的方式編譯。
    ./configure --prefix=/tmp/apache --enable-data
    
    再看下麵的例子,配置中出現了"--enable-mods-static=few"和"--enable-mods-shared"(未給定值時也是預設為most),static的優先順序高於shared,所以沒有指定編譯方式的模塊"data"使用靜態編譯方式編譯,而顯式指定了編譯方式的模塊"echo"其優先順序最強,所以動態編譯"echo"。
    ./configure --prefix=/tmp/apache \
    --enable-mods-static=few --enable-mods-shared --enable-data --enable-echo=shared
    

1.5 MPM的安裝

編譯mpm模塊(prefork/worker/event)和其他模塊差不多,唯一的區別是必須至少編譯一個mpm模塊,且必須有且僅有一個載入被httpd載入。

編譯安裝時預設的mpm是event模式(和發行版有關)。但可以通過"--with-mpm=MPM_NAME"來指定被載入的mpm模塊。以下是幾個相關編譯選項:

--with-mpm=MPM_Name:用於指定預設的mpm模塊,它所指定的模塊會被靜態編譯,併在httpd啟動時載入。
--enable-mpms-shared=MPM-LIST:指定動態編譯安裝的MPM列表,動態編譯的MPM必須使用LoadModule指令載入才能使用。

如果定"--with-mpm"選項指定了某個mpm,則預設該模塊被靜態編譯,但如果同時使用"--enable-mpms-shared"指定了該mpm,則該mpm模塊被動態編譯。

如果某個mpm模塊被靜態編譯,在httpd啟動時會載入它,如果想要切換到其他mpm模塊,只有一種方法:重新編譯httpd。

而動態編譯mpm模塊時,則可以通過LoadModule來切換到其他mpm模塊。由於編譯時自帶預設mpm模塊,還可以使用"--with-mpm"指定預設mpm模塊,所以動態編譯mpm模塊無疑比靜態編譯要好。

"--enable-mpms-shared"可以指定動態編譯的mpm列表,使用空格分隔,但需要使用單引號包圍。還可以使用關鍵字"all"表示動態編譯所有mpm模塊。 例如:

--enable-mpms-shared='prefork worker'
--enable-mpms-shared=all

1.6 關於"--enable-so"

一個模塊被動態編譯,在需要載入的時候使用LoadModule指令指定該模塊,並重讀配置文件即可。但httpd為什麼能載入該動態模塊?這就是mod_so的能力。實際上,LoadModule和LoadFile指令就是該模塊提供的。

該選項使得httpd有載入某動態模塊的能力(DSO,Dynamic Shared Object),也因此它只能使用靜態編譯方式隨httpd啟動被載入。只要不顯式指定"--enable-so=shared"或者將其加入顯式編譯列表,它都會預設以靜態方式編譯。實際上,只要顯式指定了動態方式編譯該選項,編譯時會報錯。

1.7 開始編譯httpd

至此,就可以開始編譯httpd了。過程如下:

cd
tar xf httpd-2.4.27.tar.gz
cd httpd-2.4.27
./configure --prefix=/usr/local/apache --sysconfdir=/etc/apache --with-z --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-mpm=event --enable-mpms-shared=all

其中安裝路徑為/usr/local/apache,配置文件路徑為/etc/apache。

[root@xuexi ~]# ls /usr/local/apache/
bin  build  cgi-bin  error  htdocs  icons  include  logs  man  manual  modules

bin目錄為二進位程式存放位置,如啟動腳本apachectl、httpd、htpasswd、ab(壓力測試工具)等;htdocs目錄存放網頁文件,預設裡面有index.html;logs目錄存放了日誌文件,除了日誌文件,預設還有httpd運行的pid文件httpd.pid,這個建議修改到/var/run目錄下(方便判斷);modules存放了編譯後的模塊;man目錄為幫助文檔路徑。

使用httpd的啟動腳本bin/apahcectl啟動httpd,然後測試其是否正常。

[root@xuexi apache]# bin/apachectl start
[root@xuexi apache]# netstat -tnlp | grep httpd
tcp        0      0 :::80          :::*         LISTEN      38798/httpd

在瀏覽器中輸入IP地址即可訪問。

1.8 編譯後的規範化操作

  1. 設置man路徑。
    echo "MANPATH /usr/local/apache/man" >>/etc/man.config
    
  2. 設置PATH環境變數。
    echo 'PATH=/usr/local/apache/bin:$PATH' >/etc/profile.d/apache.sh
    source /etc/profile.d/apache.sh
    
  3. 輸出頭文件。
    ln -s /usr/include /usr/local/apache/include
    
  4. 提供服務啟動腳本。

提供不提供沒多大所謂,因為apachectl或httpd命令自身可以管理進程的啟停,但自身管理啟停時不提供lock文件。

如果要提供的話,從yum安裝的httpd提供的/usr/lib/systemd/system/httpd.service(systemd)或/etc/init.d/httpd(sysV)拷貝後稍作修改就可以了。以下是按照我上面編譯的環境做了修改後的systemd和sysV服務管理腳本。

以下是httpd的systemd服務管理腳本/usr/lib/systemd/system/httpd.service。

[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)

[Service]
Type=notify
EnvironmentFile=/etc/sysconfig/httpd
ExecStart=/usr/local/apache/bin/httpd $OPTIONS -DFOREGROUND
ExecReload=/usr/local/apache/bin/httpd $OPTIONS -k graceful
ExecStop=/bin/kill -WINCH ${MAINPID}
# We want systemd to give httpd some time to finish gracefully, but still want
# it to kill httpd after TimeoutStopSec if something went wrong during the
# graceful stop. Normally, Systemd sends SIGTERM signal right after the
# ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
# httpd time to finish.
KillSignal=SIGCONT
PrivateTmp=true

[Install]
WantedBy=multi-user.target

說明:上面的腳本中使用了"kill -WINCH"信號,它是graceful stop的信號。如不明白,見我的另一篇文章:進程和信號

以下是httpd的sysV服務管理腳本/etc/rc.d/init.d/httpd。

#!/bin/bash
#
# httpd        Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: The Apache HTTP Server is an efficient and extensible  \
#           server implementing the current HTTP standards.
#
######################################################################
#  若httpd配置文件中指定了PidFile,則修改此腳本中的pidfile變數            #
######################################################################

. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd ]; then
        . /etc/sysconfig/httpd
fi

# Start httpd in the C locale by default.
HTTPD_LANG=${HTTPD_LANG-"C"}

# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""

# Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
# with the thread-based "worker" MPM; BE WARNED that some modules may not
# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=/usr/local/apache/bin/apachectl
prog=httpd
pidfile=${PIDFILE-/var/run/httpd/httpd.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0
STOP_TIMEOUT=${STOP_TIMEOUT-10}
config=/etc/apache/httpd.conf

# The semantics of these two functions differ from the way apachectl does
# things -- attempting to start while running is a failure, and shutdown
# when not running is also a failure.  So we just do it the way init scripts
# are expected to behave here.
start() {
        echo -n $"Starting $prog: "
        LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd -f $config $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
}

# When stopping httpd, a delay (of default 10 second) is required
# before SIGKILLing the httpd parent; this gives enough time for the
# httpd parent to SIGKILL any errant children.
stop() {
    status -p ${pidfile} $httpd > /dev/null
    if [[ $? = 0 ]]; then
        echo -n $"Stopping $prog: "
        killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd
    else
        echo -n $"Stopping $prog: "
        success
    fi
    RETVAL=$?
    echo
    [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}

reload() {
    echo -n $"Reloading $prog: "
    if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
        RETVAL=6
        echo $"not reloading due to configuration syntax error"
        failure $"not reloading $httpd due to configuration syntax error"
    else
        # Force LSB behaviour from killproc
        LSB=1 killproc -p ${pidfile} $httpd -HUP
        RETVAL=$?
        if [ $RETVAL -eq 7 ]; then
            failure $"httpd shutdown"
        fi
    fi
    echo
}

# See how we were called.
case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  status)
        status -p ${pidfile} $httpd
    RETVAL=$?
    ;;
  restart)
    stop
    start
    ;;
  condrestart|try-restart)
    if status -p ${pidfile} $httpd >&/dev/null; then
        stop
        start
    fi
    ;;
  force-reload|reload)
        reload
    ;;
  graceful|help|configtest|fullstatus)
    $apachectl $@
    RETVAL=$?
    ;;
  *)
    echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"
    RETVAL=2
esac

exit $RETVAL

回到Linux系列文章大綱:http://www.cnblogs.com/f-ck-need-u/p/7048359.html

回到資料庫系列文章大綱:http://www.cnblogs.com/f-ck-need-u/p/7586194.html

轉載請註明出處:http://www.cnblogs.com/f-ck-need-u/p/7605563.html

註:若您覺得這篇文章還不錯請點擊右下角推薦,您的支持能激發作者更大的寫作熱情,非常感謝!


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

-Advertisement-
Play Games
更多相關文章
  • CREATE DATABASE `mybank`;/*創建表*/USE mybank;CREATE TABLE `bank`( `customerName` CHAR(10), #用戶名 `currentMoney` DECIMAL(10,2) #當前餘額);/*插入數據*/INSERT INTO ...
  • --顯示專員內容的統計 --香港 Geovin Du 塗聚文 select count(*) as 'Tatol',BrandService,ServerName,Qualified=isnull(count(case IsSucces when '合格' then IsSucces end),0)... ...
  • "文章參考" 在Windows上安裝MongoDB 首先,在官網下載安裝包。 "下載地址" 內容如下所示: 配置 1. 創建數據目錄 2. 配置環境變數 運行 1. 命令行下運行 MongoDB 伺服器 2. 新開一個cmd 運行下麵語句 3. 打開網頁 "http://localhost:2701 ...
  • 轉自博客園: 1、獲取當前日期GetDate getdate()函數以datetime數據類型的格式返回當前SQLServer伺服器所在電腦的日期和時間。其語法格式為getdate()。返回值舍入到最近的秒小數部分,精度為.333秒資料庫十七偏移量不包含在內。 示例: 2、GetUTCDate 獲 ...
  • 一.表設計階段: 1.主鍵的使用 a.業務日誌表、安全審計表採用自增長; b.自定義編號用於業務流程類表,根據一定的編號規則; c.int型主鍵 用於基礎數據表; 2.邏輯刪除欄位的設計 a.tinyint類型,1或0; b.聯合主鍵(如ID+starDate),另加starDate,endDate ...
  • 第四章 高級查詢(二) (1)通過在子查詢中使用EXISTS子句,可以對子查詢中的行是否存在進行檢查。子查詢可以出現在表達式出現的如何位置 (2)子查詢語句可以嵌套在SQL語句中任何表達式出現的位置。 一、EXISTS子查詢 1.使用EXISTS語句判斷該資料庫對象是否存在: DROP TABLE ...
  • 在執行mysqldump命令時候報如下錯誤: [root@localhost ~]# mysqldump -uroot -p -d test> test.sql mysqldump: Got error: 2002: Can't connect to local MySQL server throu ...
  • 1 修改network配置文件 vi /etc/sysconfig/network 將配置文件中的HOSTNAME的內容改成需要修改的主機名 2 修改hosts配置文件 vi /etc/hosts 將配置文件中的localhost.localdomain改成需要修改的主機名 3 重啟機器 reboo ...
一周排行
    -Advertisement-
    Play Games
  • 前言 本文介紹一款使用 C# 與 WPF 開發的音頻播放器,其界面簡潔大方,操作體驗流暢。該播放器支持多種音頻格式(如 MP4、WMA、OGG、FLAC 等),並具備標記、實時歌詞顯示等功能。 另外,還支持換膚及多語言(中英文)切換。核心音頻處理採用 FFmpeg 組件,獲得了廣泛認可,目前 Git ...
  • OAuth2.0授權驗證-gitee授權碼模式 本文主要介紹如何筆者自己是如何使用gitee提供的OAuth2.0協議完成授權驗證並登錄到自己的系統,完整模式如圖 1、創建應用 打開gitee個人中心->第三方應用->創建應用 創建應用後在我的應用界面,查看已創建應用的Client ID和Clien ...
  • 解決了這個問題:《winForm下,fastReport.net 從.net framework 升級到.net5遇到的錯誤“Operation is not supported on this platform.”》 本文內容轉載自:https://www.fcnsoft.com/Home/Sho ...
  • 國內文章 WPF 從裸 Win 32 的 WM_Pointer 消息獲取觸摸點繪製筆跡 https://www.cnblogs.com/lindexi/p/18390983 本文將告訴大家如何在 WPF 裡面,接收裸 Win 32 的 WM_Pointer 消息,從消息裡面獲取觸摸點信息,使用觸摸點 ...
  • 前言 給大家推薦一個專為新零售快消行業打造了一套高效的進銷存管理系統。 系統不僅具備強大的庫存管理功能,還集成了高性能的輕量級 POS 解決方案,確保頁面載入速度極快,提供良好的用戶體驗。 項目介紹 Dorisoy.POS 是一款基於 .NET 7 和 Angular 4 開發的新零售快消進銷存管理 ...
  • ABP CLI常用的代碼分享 一、確保環境配置正確 安裝.NET CLI: ABP CLI是基於.NET Core或.NET 5/6/7等更高版本構建的,因此首先需要在你的開發環境中安裝.NET CLI。這可以通過訪問Microsoft官網下載並安裝相應版本的.NET SDK來實現。 安裝ABP ...
  • 問題 問題是這樣的:第三方的webapi,需要先調用登陸介面獲取Cookie,訪問其它介面時攜帶Cookie信息。 但使用HttpClient類調用登陸介面,返回的Headers中沒有找到Cookie信息。 分析 首先,使用Postman測試該登陸介面,正常返回Cookie信息,說明是HttpCli ...
  • 國內文章 關於.NET在中國為什麼工資低的分析 https://www.cnblogs.com/thinkingmore/p/18406244 .NET在中國開發者的薪資偏低,主要因市場需求、技術棧選擇和企業文化等因素所致。歷史上,.NET曾因微軟的閉源策略發展受限,儘管後來推出了跨平臺的.NET ...
  • 在WPF開發應用中,動畫不僅可以引起用戶的註意與興趣,而且還使軟體更加便於使用。前面幾篇文章講解了畫筆(Brush),形狀(Shape),幾何圖形(Geometry),變換(Transform)等相關內容,今天繼續講解動畫相關內容和知識點,僅供學習分享使用,如有不足之處,還請指正。 ...
  • 什麼是委托? 委托可以說是把一個方法代入另一個方法執行,相當於指向函數的指針;事件就相當於保存委托的數組; 1.實例化委托的方式: 方式1:通過new創建實例: public delegate void ShowDelegate(); 或者 public delegate string ShowDe ...