主頁 > 資料庫 > lamp

lamp

2022-08-04 09:29:57 資料庫

lamp

目錄
  • 1. lamp簡介
  • 2. web服務器作業流程
    • 2.1 cgi與fastcgi
    • 2.2 httpd與php結合的方式
    • 2.3 web作業流程
  • 3. lamp平臺搭建
    • 3.1 安裝httpd
    • 3.2 安裝mysql
    • 3.3 安裝php
    • 3.4 配置apache
      • 3.4.1 啟用代理模塊
      • 3.4.2 配置虛擬主機
    • 3.5 驗證

1. lamp簡介

有了前面學習的知識的鋪墊,今天可以來學習下第一個常用的web架構了,

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

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

2. web服務器作業流程

在說lamp架構平臺的搭建前,我們先來了解下什么是CGI,什么是FastCGI,什么是......

web服務器的資源分為兩種,靜態資源和動態資源

  • 靜態資源就是指靜態內容,客戶端從服務器獲得的資源的表現形式與原檔案相同,可以簡單的理解為就是直接存盤于檔案系統中的資源
  • 動態資源則通常是程式檔案,需要在服務器執行之后,將執行的結果回傳給客戶端

那么web服務器如何執行程式并將結果回傳給客戶端呢?下面通過一張圖來說明一下web服務器如何處理客戶端的請求

階段①顯示的是httpd服務器(即apache)和php服務器通過FastCGI協議進行通信,且php作為獨立的服務行程運行

階段②顯示的是php程式和mysql資料庫間通過mysql協議進行通信,php與mysql本沒有什么聯系,但是由Php語言寫成的程式可以與mysql進行資料互動,同理perl和python寫的程式也可以與mysql資料庫進行互動

2.1 cgi與fastcgi

CGI(Common Gateway Interface,通用網關介面),CGI是外部應用程式(CGI程式)與WEB服務器之間的介面標準,是在CGI程式和Web服務器之間傳遞資訊的程序,CGI規范允許Web服務器執行外部程式,并將它們的輸出發送給Web瀏覽器,CGI將web的一組簡單的靜態超媒體檔案變成一個完整的新的互動式媒體,

FastCGI(Fast Common Gateway Interface)是CGI的改良版,CGI是通過啟用一個解釋器行程來處理每個請求,耗時且耗資源,而FastCGI則是通過master-worker形式來處理每個請求,即啟動一個master主行程,然后根據配置啟動幾個worker行程,當請求進來時,master會從worker行程中選擇一個去處理請求,這樣就避免了重復的生成和殺死行程帶來的頻繁cpu背景關系切換而導致耗時

2.2 httpd與php結合的方式

httpd與php結合的方式有以下三種:

  • modules:php將以httpd的擴展模塊形式存在,需要加載動態資源時,httpd可以直接通過php模塊來加工資源并回傳給客戶端
    • httpd prefork:libphp5.so(多行程模型的php)
    • httpd event or worker:libphp5-zts.so(執行緒模型的php)
  • CGI:httpd需要加載動態資源時,通過CGI與php解釋器聯系,獲得php執行的結果,此時httpd負責與php連接的建立和斷開等
  • FastCGI:利用php-fpm機制,啟動為服務行程,php自行運行為一個服務,https通過socket與php通信

較于CGI方式,FastCGI更為常用,很少有人使用CGI方式來加載動態資源

2.3 web作業流程

  • 客戶端通過http協議請求web服務器資源
  • web服務器收到請求后判斷客戶端請求的資源是靜態資源或是動態資源
    • 若是靜態資源則直接從本地檔案系統取之回傳給客戶端,
    • 否則若為動態資源則通過FastCGI協議與php服務器聯系,通過CGI程式的master行程調度worker行程來執行程式以獲得客戶端請求的動態資源,并將執行的結果通過FastCGI協議回傳給httpd服務器,httpd服務器收到php的執行結果后將其封裝為http回應報文回應給客戶端,在執行程式獲取動態資源時若需要獲得資料庫中的資源時,由Php服務器通過mysql協議與MySQL/MariaDB服務器互動,取之而后回傳給httpd,httpd將從php服務器收到的執行結果封裝成http回應報文回應給客戶端,

3. lamp平臺搭建

環境說明:

系統平臺 IP 需要安裝的服務
centos7 redhat7 172.16.12.128 httpd-2.4 mysql-5.7 php php-mysql

lamp平臺軟體安裝次序:
httpd --> mysql --> php

3.1 安裝httpd

[root@mr ~]# cd /etc/yum.repos.d/
[root@mr yum.repos.d]# ls
CentOS-Stream-AppStream.repo  CentOS-Stream-Extras.repo            CentOS-Stream-PowerTools.repo
CentOS-Stream-BaseOS.repo     CentOS-Stream-HighAvailability.repo  CentOS-Stream-RealTime.repo
CentOS-Stream-Debuginfo.repo  CentOS-Stream-Media.repo
[root@mr yum.repos.d]# rm -rf *
[root@mr yum.repos.d]# ls
[root@mr yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  2495  100  2495    0     0  15993      0 --:--:-- --:--:-- --:--:-- 16096
[root@mr yum.repos.d]# ls
CentOS-Base.repo
[root@mr yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@mr yum.repos.d]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
CentOS-8.5.2111 - Base - mirrors.aliyun.com                              144 kB/s | 3.9 kB     00:00    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com                             69 kB/s | 1.5 kB     00:00    
CentOS-8.5.2111 - AppStream - mirrors.aliyun.com                         176 kB/s | 4.3 kB     00:00    
epel-release-latest-8.noarch.rpm                                         449 kB/s |  24 kB     00:00    
Dependencies resolved.
=========================================================================================================
 Package                    Architecture         Version                Repository                  Size
=========================================================================================================
Installing:
 epel-release               noarch               8-16.el8               @commandline                24 k

Transaction Summary
=========================================================================================================
Install  1 Package

Total size: 24 k
Installed size: 34 k
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                 1/1 
  Installing       : epel-release-8-16.el8.noarch                                                    1/1 
  Running scriptlet: epel-release-8-16.el8.noarch                                                    1/1 
Many EPEL packages require the CodeReady Builder (CRB) repository.
It is recommended that you run /usr/bin/crb enable to enable the CRB repository.

  Verifying        : epel-release-8-16.el8.noarch                                                    1/1 
Installed products updated.

Installed:
  epel-release-8-16.el8.noarch                                                                           

Complete!
[root@mr yum.repos.d]# 
[root@mr yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@mr yum.repos.d]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
[root@mr yum.repos.d]# ls
CentOS-Base.repo  epel-modular.repo  epel.repo  epel-testing-modular.repo  epel-testing.repo
[root@mr yum.repos.d]# cd
[root@mr ~]# dnf clean all
37 files removed
[root@mr ~]# 
[root@mr ~]# dnf makecache
CentOS-8.5.2111 - Base - mirrors.aliyun.com                               10 MB/s | 4.6 MB     00:00    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com                            104 kB/s |  10 kB     00:00    
CentOS-8.5.2111 - AppStream - mirrors.aliyun.com                          11 MB/s | 8.4 MB     00:00    
Extra Packages for Enterprise Linux Modular 8 - x86_64                   3.2 MB/s | 1.0 MB     00:00    
Extra Packages for Enterprise Linux 8 - x86_64                            10 MB/s |  13 MB     00:01    
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Metadata cache created.
[root@mr ~]# dnf -y install 
openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make vim wget
......
  perl-threads-shared-1.58-2.el8.x86_64                                                                  
  pkgconf-1.4.2-1.el8.x86_64                                                                             
  pkgconf-m4-1.4.2-1.el8.noarch                                                                          
  pkgconf-pkg-config-1.4.2-1.el8.x86_64                                                                  
  zlib-devel-1.2.11-17.el8.x86_64                                                                        

Complete!
[root@mr ~]# [root@mr ~]# useradd -r -M -s /sbin/nologin apache
[root@mr ~]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz
--2022-08-02 19:20:01--  https://downloads.apache.org/apr/apr-1.7.0.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 135.181.214.104, 88.99.95.219, 2a01:4f9:3a:2c57::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|135.181.214.104|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1093896 (1.0M) [application/x-gzip]
Saving to: ‘apr-1.7.0.tar.gz’

apr-1.7.0.tar.gz           100%[=====================================>]   1.04M  15.8KB/s    in 54s     

2022-08-02 19:20:56 (19.9 KB/s) - ‘apr-1.7.0.tar.gz’ saved [1093896/1093896]

[root@mr~]#https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
......
--2022-08-02 19:21:15--  https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 135.181.214.104, 88.99.95.219, 2a01:4f9:3a:2c57::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|135.181.214.104|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 554301 (541K) [application/x-gzip]
Saving to: ‘apr-util-1.6.1.tar.gz’

apr-util-1.6.1.tar.gz      100%[=====================================>] 541.31K  4.23KB/s    in 2m 13s  

2022-08-02 19:23:29 (4.08 KB/s) - ‘apr-util-1.6.1.tar.gz’ saved [554301/554301]

[root@mr ~]# wget https://downloads.apache.org/httpd/httpd-2.4.54.tar.gz
--2022-08-02 19:25:49--  https://downloads.apache.org/httpd/httpd-2.4.54.tar.gz
Resolving downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 2a01:4f9:3a:2c57::2, ...
Connecting to downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9743277 (9.3M) [application/x-gzip]
Saving to: ‘httpd-2.4.54.tar.gz’

httpd-2.4.54.tar.gz        100%[=====================================>]   9.29M  48.2KB/s    in 4m 57s  

2022-08-02 19:30:47 (32.0 KB/s) - ‘httpd-2.4.54.tar.gz’ saved [9743277/9743277]
[root@mr ~]# ls
anaconda-ks.cfg  apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.54.tar.gz
[root@mr ~]# tar xf apr-1.7.0.tar.gz 
[root@mr ~]# tar xf apr-util-1.6.1.tar.gz 
[root@mr ~]# 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.tar.gz
[root@mr ~]# cd apr-1.7.0
[root@mr apr-1.7.0]# ls
apr-config.in  atomic            config.layout  file_io     LICENSE       network_io     README.cmake  time
apr.dep        build             configure      helpers     locks         NOTICE         shmem         tools
apr.dsp        build.conf        configure.in   include     Makefile.in   NWGNUmakefile  strings       user
apr.dsw        buildconf         docs           libapr.dep  Makefile.win  passwd         support
apr.mak        build-outputs.mk  dso            libapr.dsp  memory        poll           tables
apr.pc.in      CHANGES           emacs-mode     libapr.mak  misc          random         test
apr.spec       CMakeLists.txt    encoding       libapr.rc   mmap          README         threadproc
[root@mr apr-1.7.0]# vim configure

  # $RM "$cfgfile"        //將此行加上注釋,或者洗掉此行
 [root@mr apr-1.7.0]# ./configure --prefix=/usr/local/apr
 ......
config.status: creating build/apr_rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating apr-1-config
config.status: creating apr.pc
config.status: creating test/Makefile
config.status: creating test/internal/Makefile
config.status: creating include/arch/unix/apr_private.h
config.status: executing libtool commands
config.status: executing default commands
[root@mr apr-1.7.0]# make
......
/unix -I/root/apr-1.7.0/include/arch/unix -I/root/apr-1.7.0/include -I/root/apr-1.7.0/include/private -I/root/apr-1.7.0/include/private  export_vars.c | sed -e 's/^\#[^!]*//' | sed -e '/^$/d' >> apr.exp
sed 's,^\(location=\).*$,\1installed,' < apr-1-config > apr-config.out
sed -e 's,^\(apr_build.*=\).*$,\1/usr/local/apr/build-1,' -e 's,^\(top_build.*=\).*$,\1/usr/local/apr/build-1,' < build/apr_rules.mk > build/apr_rules.out
make[1]: Leaving directory '/root/apr-1.7.0'
[root@mr apr-1.7.0]# make install
......
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config
[root@mr apr-1.7.0]# cd ../apr-util-1.6.1
[root@mr apr-util-1.6.1]# ls
aprutil.dep     apu-config.in     CHANGES         dbd                include         LICENSE       NWGNUmakefile    strmatch
aprutil.dsp     buckets           CMakeLists.txt  dbm                ldap            Makefile.in   README           test
aprutil.dsw     build             config.layout   docs               libaprutil.dep  Makefile.win  README.cmake     uri
aprutil.mak     build.conf        configure       encoding           libaprutil.dsp  memcache      README.FREETDS   xlate
apr-util.pc.in  buildconf         configure.in    export_vars.sh.in  libaprutil.mak  misc          redis            xml
apr-util.spec   build-outputs.mk  crypto          hooks              libaprutil.rc   NOTICE        renames_pending
[root@mr apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
......
config.status: creating test/Makefile
config.status: creating include/private/apu_config.h
config.status: executing default commands
[root@mr apr-util-1.6.1]# make && make install
......
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr-util/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr-util/bin/apu-1-config
[root@mr apr-util-1.6.1]# cd
[root@mr ~]# ls /usr/local/
apr  apr-util  bin  etc  games  include  lib  lib64  libexec  sbin  share  src
[root@mr ~]# 
[root@mr ~]# 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.tar.gz
[root@mr ~]# tar xf httpd-2.4.54.tar.gz 
[root@mr ~]# cd httpd-2.4.54
[root@mr httpd-2.4.54]# ls
ABOUT_APACHE     BuildBin.dsp     docs         InstallBin.dsp  modules           ROADMAP
acinclude.m4     buildconf        emacs-style  LAYOUT          NOTICE            server
Apache-apr2.dsw  CHANGES          httpd.dep    libhttpd.dep    NWGNUmakefile     srclib
Apache.dsw       changes-entries  httpd.dsp    libhttpd.dsp    os                support
apache_probes.d  CMakeLists.txt   httpd.mak    libhttpd.mak    README            test
ap.d             config.layout    httpd.spec   LICENSE         README.CHANGES    VERSIONING
build            configure        include      Makefile.in     README.cmake
BuildAll.dsp     configure.in     INSTALL      Makefile.win    README.platforms
[root@mr 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-mpm=prefork
......
config.status: executing default commands
configure: summary of build options:

    Server Version: 2.4.54
    Install prefix: /usr/local/apache
    C compiler:     gcc
    CFLAGS:          -g -O2 -pthread  
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE  
    LDFLAGS:           
    LIBS:             
    C preprocessor: gcc -E

[root@mr httpd-2.4.54]# make && make install
......
Installing build system files
mkdir /usr/local/apache/build
Installing man pages and online manual
mkdir /usr/local/apache/man
mkdir /usr/local/apache/man/man1
mkdir /usr/local/apache/man/man8
mkdir /usr/local/apache/manual
make[1]: Leaving directory '/root/httpd-2.4.54'
[root@mr httpd-2.4.54]# cd
[root@mr ~]# ls
anaconda-ks.cfg  apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.54.tar.gz
apr-1.7.0        apr-util-1.6.1    httpd-2.4.54
[root@mr ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh
[root@mr ~]# cat /etc/profile.d/httpd.sh 
export PATH=/usr/local/apache/bin:$PATH
[root@mr ~]# source /etc/profile.d/httpd.sh
[root@mr ~]# which httpd
/usr/local/apache/bin/httpd
[root@mr ~]# ls /usr/local/apache/
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
[root@mr ~]#  ln -s /usr/local/apache/include/ /usr/include/apache
[root@mr ~]# 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@mr ~]# cd /usr/lib/systemd/system
[root@mr system]# ls
 auditd.service                           runlevel0.target
 [email protected]                          runlevel1.target
 basic.target                             runlevel1.target.wants
 basic.target.wants                       runlevel2.target
......
rngd-wake-threshold.service              user-.slice.d
 rpcbind.target                           vgauthd.service
 rsyslog.service                          vmtoolsd.service
[root@mr system]# cp sshd.service httpd.service
[root@mr system]# vim httpd.service 
[Unit]
Description=web server daemon
Documentation=man:httpd(5) 
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@mr system]# cd
[root@mr ~]# systemctl daemon-reload
[root@mr ~]# systemctl status httpd
● httpd.service - web server daemon
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd(5)
[root@mr ~]# systemctl start httpd
[root@mr ~]# ss -antl
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                     [::]:*                     
[root@mr ~]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@mr ~]# systemctl status httpd
● httpd.service - web server daemon
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2022-08-02 20:12:20 CST; 53min ago
     Docs: man:httpd(5)
 Main PID: 48353 (httpd)
    Tasks: 6 (limit: 24717)
   Memory: 5.8M
   CGroup: /system.slice/httpd.service
           ├─48353 /usr/local/apache/bin/httpd -k start
           ├─48354 /usr/local/apache/bin/httpd -k start
           ├─48355 /usr/local/apache/bin/httpd -k start
           ├─48356 /usr/local/apache/bin/httpd -k start
           ├─48357 /usr/local/apache/bin/httpd -k start
           └─48358 /usr/local/apache/bin/httpd -k start

Aug 02 20:12:02 mr systemd[1]: Starting web server daemon...
Aug 02 20:12:20 mr apachectl[48350]: AH00558: httpd: Could not reliably determine the server's fully qua>
Aug 02 20:12:20 mr systemd[1]: Started web server daemon.
[root@mr ~]# 

3.2 安裝mysql

[root@mr ~]# dnf -y install ncurses-devel openssl-devel openssl cmake mariadb-devel
......
  mariadb-connector-c-devel-3.1.11-2.el8_3.x86_64                                                        
  mariadb-devel-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                                           
  ncurses-c++-libs-6.1-9.20180224.el8.x86_64                                                             
  ncurses-devel-6.1-9.20180224.el8.x86_64                                                                

Complete!
[root@mr ~]# 
[root@mr ~]# useradd -r -M -s /sbin/nologin mysql
[root@mr ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
......
HTTP request sent, awaiting response... 200 OK
Length: 674830866 (644M) [application/x-tar-gz]
Saving to: ‘mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz’

mysql-5.7.38-linux-glibc2. 100%[=====================================>] 643.57M   659KB/s    in 9m 26s  

2022-08-02 22:09:46 (1.14 MB/s) - ‘mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz’ saved [674830866/674830866]

[root@mr ~]# ls
anaconda-ks.cfg  apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.54.tar.gz
apr-1.7.0        apr-util-1.6.1    httpd-2.4.54           mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
[root@mr ~]# tar xf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@mr ~]# cd /usr/local/
[root@mr local]# ls
apache  apr-util  etc    include  lib64    mysql-5.7.38-linux-glibc2.12-x86_64  share
apr     bin       games  lib      libexec  sbin                                 src
[root@mr local]# mv mysql-5.7.38-linux-glibc2.12-x86_64 mysql
[root@mr local]# ls
apache  apr  apr-util  bin  etc  games  include  lib  lib64  libexec  mysql  sbin  share  src
[root@mr local]# chown -R mysql.mysql mysql
[root@mr local]# ll
total 0
drwxr-xr-x. 14 root  root  164 Aug  2 19:53 apache
drwxr-xr-x.  6 root  root   58 Aug  2 19:38 apr
drwxr-xr-x.  5 root  root   43 Aug  2 19:44 apr-util
drwxr-xr-x.  2 root  root    6 May 19  2020 bin
drwxr-xr-x.  2 root  root    6 May 19  2020 etc
drwxr-xr-x.  2 root  root    6 May 19  2020 games
drwxr-xr-x.  2 root  root    6 May 19  2020 include
drwxr-xr-x.  2 root  root    6 May 19  2020 lib
drwxr-xr-x.  3 root  root   17 Aug  1 15:49 lib64
drwxr-xr-x.  2 root  root    6 May 19  2020 libexec
drwxr-xr-x.  9 mysql mysql 129 Aug  2 22:11 mysql
drwxr-xr-x.  2 root  root    6 May 19  2020 sbin
drwxr-xr-x.  5 root  root   49 Aug  1 15:49 share
drwxr-xr-x.  2 root  root    6 May 19  2020 src
[root@mr local]# ls /usr/local/mysql/
bin  docs  include  lib  LICENSE  man  README  share  support-files
[root@mr local]# ln -s /usr/local/mysql/include /usr/include/mysql
[root@mr local]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@mr local]# vim /etc/man_db.conf 
MANDATORY_MANPATH                       /usr/man
MANDATORY_MANPATH                       /usr/share/man
MANDATORY_MANPATH                       /usr/local/share/man
MANDATORY_MANPATH                       /usr/local/mysql/man
[root@mr local]# cd
[root@mr ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@mr ~]# source /etc/profile.d/mysql.sh 
[root@mr ~]# which mysql
/usr/local/mysql/bin/mysql
[root@mr ~]# 
[root@mr ~]# mysqld --initialize --user mysql --datadir /opt/data
2022-08-02T14:22:01.195167Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-08-02T14:22:01.338468Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-08-02T14:22:01.364317Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-08-02T14:22:01.423393Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 799aa4e2-126e-11ed-a53b-000c29f0dfce.
2022-08-02T14:22:01.424482Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-08-02T14:22:01.621913Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-08-02T14:22:01.621947Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-08-02T14:22:01.622320Z 0 [Warning] CA certificate ca.pem is self signed.
2022-08-02T14:22:01.648745Z 1 [Note] A temporary password is generated for root@localhost: <rC:S!uXs6yk
[root@mr ~]# echo '<rC:S!uXs6yk' > pass
[root@mr ~]# rpm -qa|grep mariadb
mariadb-connector-c-config-3.1.11-2.el8_3.noarch
mariadb-connector-c-3.1.11-2.el8_3.x86_64
mariadb-connector-c-devel-3.1.11-2.el8_3.x86_64
mariadb-devel-10.3.28-1.module_el8.3.0+757+d382997d.x86_64
[root@mr ~]# dnf -y remove mariadb*
Removed:
  mariadb-connector-c-3.1.11-2.el8_3.x86_64                                                              
  mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                                       
  mariadb-connector-c-devel-3.1.11-2.el8_3.x86_64                                                        
  mariadb-devel-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64                                           

Complete!
[root@mr ~]# rpm -qa|grep mariadb
[root@mr ~]# 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@mr ~]# cd /usr/local/mysql/
[root@mr mysql]# ls
bin  docs  include  lib  LICENSE  man  README  share  support-files
[root@mr mysql]# cd support-files/
[root@mr support-files]# ls
magic  mysqld_multi.server  mysql-log-rotate  mysql.server
[root@mr support-files]# file mysql.server 
mysql.server: POSIX shell script, ASCII text executable
[root@mr support-files]# cp mysql.server /etc/init.d/mysqld
[root@mr support-files]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/opt/data
[root@mr support-files]# chmod +x /etc/init.d/mysqld 
[root@mr support-files]# cd
[root@mr ~]# service mysqld start
Starting MySQL.Logging to '/opt/data/mr.err'.
 SUCCESS! 
[root@mr ~]# ss -antl
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                     [::]:*                     
LISTEN      0           80                           *:3306                      *:*                     
[root@mr ~]# chkconfig --add mysqld
[root@mr ~]# chkconfig --list

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

mysqld         	0:off	1:off	2:on	3:on	4:on	5:on	6:off
[root@mr ~]# 
[root@mr ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@mr ~]# vim /etc/selinux/config 
SELINUX=disabled
[root@mr ~]# reboot
[root@master ~]# ss -antl
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@master ~]# 
[root@master ~]# dnf provides libncurses.so.5
Last metadata expiration check: 2:52:43 ago on Tue 02 Aug 2022 07:55:40 PM CST.
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
ncurses-compat-libs-6.1-9.20180224.el8.i686 : Ncurses compatibility libraries
Repo        : base
Matched from:
Provide    : libncurses.so.5

[root@master ~]# dnf -y install ncurses-compat-libs
[root@master ~]# cat pass
<rC:S!uXs6yk
[root@master ~]# mysql -uroot -p'<rC:S!uXs6yk'
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

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('marui');
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> exit
Bye
[root@master ~]# mysql -uroot -pmarui
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 4
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> exit
Bye
[root@master ~]# 

3.3 安裝php

[root@master ~]# wget https://www.php.net/distributions/php-7.4.30.tar.xz
......
Saving to: ‘php-7.4.30.tar.xz’

php-7.4.30.tar.xz          100%[++++++++++++++++=====================>]   9.94M  16.1KB/s    in 5m 16s  

2022-08-02 23:24:04 (18.5 KB/s) - ‘php-7.4.30.tar.xz’ saved [10419136/10419136]

[root@master ~]# sha256sum php-7.4.30.tar.xz 
ea72a34f32c67e79ac2da7dfe96177f3c451c3eefae5810ba13312ed398ba70d  php-7.4.30.tar.xz
[root@master ~]# 
[root@master ~]# dnf list all|grep php|grep mysql
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
php-mysqlnd.x86_64                                                7.2.24-1.module_el8.2.0+313+b04d0a66                   AppStream    
[root@master ~]# dnf -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
.....
 mhash-0.9.9.9-20.el8.x86_64                                                                            
  mhash-devel-0.9.9.9-20.el8.x86_64                                                                      
  openldap-devel-2.4.46-18.el8.x86_64                                                                    
  php-common-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                                 
  php-mysqlnd-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                                
  php-pdo-7.2.24-1.module_el8.2.0+313+b04d0a66.x86_64                                                    
  readline-devel-7.0-10.el8.x86_64                                                                       
  xz-devel-5.2.4-3.el8.x86_64                                                                            
  zlib-1.2.11-17.el8.i686                                                                                

Complete!
[root@master ~]# dnf -y install libsqlite3x-devel
Last metadata expiration check: 3:40:33 ago on Tue 02 Aug 2022 07:55:40 PM CST.
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Dependencies resolved.
=============================================================================================================================
 Package                             Architecture             Version                           Repository              Size
=============================================================================================================================
Installing:
 libsqlite3x-devel                   x86_64                   20071018-26.el8                   epel                   143 k
Upgrading:
 sqlite-libs                         x86_64                   3.26.0-15.el8                     base                   581 k
Installing dependencies:
 libsqlite3x                         x86_64                   20071018-26.el8                   epel                    39 k
 sqlite                              x86_64                   3.26.0-15.el8                     base                   668 k
 sqlite-devel                        x86_64                   3.26.0-15.el8                     base                   165 k

Transaction Summary
=============================================================================================================================
Install  4 Packages
Upgrade  1 Package

Total download size: 1.6 M
Downloading Packages:
(1/5): sqlite-3.26.0-15.el8.x86_64.rpm                                                       7.1 MB/s | 668 kB     00:00    
(2/5): sqlite-devel-3.26.0-15.el8.x86_64.rpm                                                 1.3 MB/s | 165 kB     00:00    
(3/5): libsqlite3x-20071018-26.el8.x86_64.rpm                                                233 kB/s |  39 kB     00:00    
(4/5): sqlite-libs-3.26.0-15.el8.x86_64.rpm                                                   12 MB/s | 581 kB     00:00    
(5/5): libsqlite3x-devel-20071018-26.el8.x86_64.rpm                                          269 kB/s | 143 kB     00:00    
-----------------------------------------------------------------------------------------------------------------------------
Total                                                                                        2.5 MB/s | 1.6 MB     00:00     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                     1/1 
  Upgrading        : sqlite-libs-3.26.0-15.el8.x86_64                                                                    1/6 
  Installing       : sqlite-3.26.0-15.el8.x86_64                                                                         2/6 
  Installing       : sqlite-devel-3.26.0-15.el8.x86_64                                                                   3/6 
  Installing       : libsqlite3x-20071018-26.el8.x86_64                                                                  4/6 
  Installing       : libsqlite3x-devel-20071018-26.el8.x86_64                                                            5/6 
  Cleanup          : sqlite-libs-3.26.0-13.el8.x86_64                                                                    6/6 
  Running scriptlet: sqlite-libs-3.26.0-13.el8.x86_64                                                                    6/6 
  Verifying        : sqlite-3.26.0-15.el8.x86_64                                                                         1/6 
  Verifying        : sqlite-devel-3.26.0-15.el8.x86_64                                                                   2/6 
  Verifying        : libsqlite3x-20071018-26.el8.x86_64                                                                  3/6 
  Verifying        : libsqlite3x-devel-20071018-26.el8.x86_64                                                            4/6 
  Verifying        : sqlite-libs-3.26.0-15.el8.x86_64                                                                    5/6 
  Verifying        : sqlite-libs-3.26.0-13.el8.x86_64                                                                    6/6 
Installed products updated.

Upgraded:
  sqlite-libs-3.26.0-15.el8.x86_64                                                                                           

Installed:
  libsqlite3x-20071018-26.el8.x86_64       libsqlite3x-devel-20071018-26.el8.x86_64       sqlite-3.26.0-15.el8.x86_64      
  sqlite-devel-3.26.0-15.el8.x86_64       

Complete!
[root@master ~]# dnf -y install http://mirror.centos.org/centos/8-stream/PowerTools/x86_64/os/Packages/oniguruma-devel-6.8.2-2.el8.x86_64.rpm
......
 Verifying        : oniguruma-6.8.2-2.el8.x86_64                                                                        1/2 
  Verifying        : oniguruma-devel-6.8.2-2.el8.x86_64                                                                  2/2 
Installed products updated.

Installed:
  oniguruma-6.8.2-2.el8.x86_64                               oniguruma-devel-6.8.2-2.el8.x86_64                              

Complete!
[root@master ~]# ls
anaconda-ks.cfg   apr-util-1.6.1         httpd-2.4.54.tar.gz                         php-7.4.30.tar.xz
apr-1.7.0         apr-util-1.6.1.tar.gz  mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
apr-1.7.0.tar.gz  httpd-2.4.54           pass
[root@master ~]# dnf -y install libzip-devel
 Verifying        : libzip-devel-1.5.1-2.module_el8.2.0+313+b04d0a66.x86_64                         2/2 
Installed products updated.

Installed:
  libzip-1.5.1-2.module_el8.2.0+313+b04d0a66.x86_64                                                      
  libzip-devel-1.5.1-2.module_el8.2.0+313+b04d0a66.x86_64                                                

Complete!
[root@master ~]# 

[root@master ~]# tar xf php-7.4.30.tar.xz 
[root@master ~]# cd php-7.4.30
[root@master 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 \
......
config.status: creating main/php_config.h
config.status: executing default commands

+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE. By continuing this installation  |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

[root@master php-7.4.30]# make
......
pharcommand.inc
invertedregexiterator.inc
directorytreeiterator.inc
directorygraphiterator.inc
phar.inc

Build complete.
Don't forget to run 'make test'.

[root@master php-7.4.30]# make install
Installing shared extensions:     /usr/local/php7/lib/php/extensions/no-debug-non-zts-20190902/
Installing PHP CLI binary:        /usr/local/php7/bin/
Installing PHP CLI man page:      /usr/local/php7/php/man/man1/
......
/root/php-7.4.30/build/shtool install -c ext/phar/phar.phar /usr/local/php7/bin/phar.phar
ln -s -f phar.phar /usr/local/php7/bin/phar
Installing PDO headers:           /usr/local/php7/include/php/ext/pdo/
[root@master php-7.4.30]# echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php7.sh
[root@master php-7.4.30]#  source /etc/profile.d/php7.sh
[root@master php-7.4.30]#  which php
/usr/local/php7/bin/php
[root@master php-7.4.30]# php -v
PHP 7.4.30 (cli) (built: Aug  3 2022 00:00:44) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
[root@master php-7.4.30]# cp php.ini-production /etc/php.ini
cp: overwrite '/etc/php.ini'? y
[root@master php-7.4.30]# cd sapi/
[root@master sapi]# ls
apache2handler  cgi  cli  embed  fpm  litespeed  phpdbg
[root@master sapi]# cd fpm/
[root@master fpm]# ls
config.m4       init.d.php-fpm.in  php-fpm.8        php-fpm.service     tests
CREDITS         LICENSE            php-fpm.8.in     php-fpm.service.in  www.conf
fpm             Makefile.frag      php-fpm.conf     status.html         www.conf.in
init.d.php-fpm  php-fpm            php-fpm.conf.in  status.html.in
[root@master fpm]# file init.d.php-fpm
init.d.php-fpm: POSIX shell script, ASCII text executable
[root@master fpm]# cp init.d.php-fpm /etc/init.d/php-fpm
[root@master fpm]# chmod +x /etc/init.d/php-fpm
[root@master fpm]# cd
[root@master ~]# service php-fpm status
php-fpm is stopped
[root@master ~]# cd /usr/local/php7/
[root@master php7]# ls
bin  etc  include  lib  php  sbin  var
[root@master php7]# cd etc/
[root@master etc]# ls
pear.conf  php-fpm.conf.default  php-fpm.d
[root@master etc]# cp php-fpm.conf.default php-fpm.conf
[root@master etc]# ls
pear.conf  php-fpm.conf  php-fpm.conf.default  php-fpm.d
[root@master etc]# cd php-fpm.d/
[root@master php-fpm.d]# ls
www.conf.default
[root@master php-fpm.d]# cp www.conf.default www.conf
[root@master php-fpm.d]# ls
www.conf  www.conf.default
[root@master php-fpm.d]# service php-fpm start
Starting php-fpm  done
[root@master php-fpm.d]# ss -antl
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                     [::]:*                     
[root@master php-fpm.d]# 
[root@master php-fpm.d]# cd
[root@master ~]# chkconfig --add php-fpm
[root@master ~]# chkconfig --list

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

      If you want to list systemd services use 'systemctl list-unit-files'.
      To see services enabled on particular target use
      'systemctl list-dependencies [target]'.

mysqld         	0:off	1:off	2:on	3:on	4:on	5:on	6:off
php-fpm        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
[root@master ~]# 

3.4 配置apache

3.4.1 啟用代理模塊

在apache httpd 2.4以后已經專門有一個模塊針對FastCGI的實作,此模塊為mod_proxy_fcgi.so,它其實是作為mod_proxy.so模塊的擴展,因此,這兩個模塊都要加載,編輯httpd.conf檔案,取消以下兩行內容的注釋:

  • LoadModule proxy_module modules/mod_proxy.so
  • LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
[root@master ~]# ss -antl
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                     [::]:*                     
[root@master ~]# cd /usr/local/apache/conf/
[root@master conf]# ls
extra  httpd.conf  magic  mime.types  original
[root@master conf]# vim httpd.conf 
loadmodule proxy_module modules/mod_proxy.so
loadmodule proxy_fcgi_module modules/mod_proxy_fcgi.so(取消這兩行注釋)

3.4.2 配置虛擬主機

在需要使用fcgi的虛擬主機中添加類似如下兩行:ProxyRequests Off //關閉正向代理
ProxyPassMatch ^/(.*.php)$ fcgi://127.0.0.1:9000/PATH/TO/DOCUMENT_ROOT/$1

[root@master conf]# ls /usr/local/apache/
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
[root@master conf]# ls /usr/local/apache/htdocs/
index.html
[root@master conf]# mkdir -p /usr/local/apache/htdocs/runtime
[root@master conf]# vim /usr/local/apache/htdocs/runtime/index.php

<?php
   phpinfo();
?>
[root@master conf]# ll /usr/local/apache/htdocs/
total 4
-rw-r--r--. 1  504 games 45 Jun 12  2007 index.html
drwxr-xr-x  2 root root  23 Aug  4 08:46 runtime
[root@master conf]# ll /usr/local/apache/htdocs/runtime/
total 4
-rw-r--r-- 1 root root 23 Aug  4 08:46 index.php
[root@master conf]#  ls
extra  httpd.conf  magic  mime.types  original
[root@master conf]# cd extra/
[root@master extra]# ls
httpd-autoindex.conf  httpd-info.conf       httpd-mpm.conf                 httpd-userdir.conf
httpd-dav.conf        httpd-languages.conf  httpd-multilang-errordoc.conf  httpd-vhosts.conf
httpd-default.conf    httpd-manual.conf     httpd-ssl.conf                 proxy-html.conf
[root@master extra]# 
[root@master extra]# vim httpd-vhosts.conf
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/htdocs/runtime"
    ServerName dummy-host.example.com
    ErrorLog "logs/runtime.example.com-error_log"
    CustomLog "logs/runtime.example.com-access_log" common
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/runtime/$1
    <Directory "/usr/local/apache/htdocs/runtime">
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>
[root@master extra]# ls
httpd-autoindex.conf  httpd-info.conf       httpd-mpm.conf                 httpd-userdir.conf
httpd-dav.conf        httpd-languages.conf  httpd-multilang-errordoc.conf  httpd-vhosts.conf
httpd-default.conf    httpd-manual.conf     httpd-ssl.conf                 proxy-html.conf
[root@master extra]# cd ..
[root@master conf]# ls
extra  httpd.conf  magic  mime.types  original
[root@master conf]# vim httpd.conf 
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php    #添加此行
AddType application/x-httpd-php-source .phps#添加此行
Include conf/extra/httpd-vhosts.conf(取消注釋)
<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>(添加index.php)
[root@master conf]# systemctl restart httpd
[root@master conf]# systemctl status httpd
● httpd.service - web server daemon
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Thu 2022-08-04 09:07:27 CST; 29s ago
     Docs: man:httpd(5)
  Process: 142048 ExecStop=/usr/local/apache/bin/apachectl stop (code=exited, status=0/SUCCESS)
  Process: 142053 ExecStart=/usr/local/apache/bin/apachectl start (code=exited, status=0/SUCCESS)
 Main PID: 142057 (httpd)
    Tasks: 6 (limit: 24717)
   Memory: 5.9M
   CGroup: /system.slice/httpd.service
           ├─142057 /usr/local/apache/bin/httpd -k start
           ├─142058 /usr/local/apache/bin/httpd -k start
           ├─142059 /usr/local/apache/bin/httpd -k start
           ├─142060 /usr/local/apache/bin/httpd -k start
           ├─142061 /usr/local/apache/bin/httpd -k start
           └─142062 /usr/local/apache/bin/httpd -k start

Aug 04 09:07:12 master systemd[1]: Starting web server daemon...
Aug 04 09:07:27 master apachectl[142053]: AH00558: httpd: Could not reliably determine the server's full>
Aug 04 09:07:27 master systemd[1]: Started web server daemon.
lines 1-20/20 (END)

以上設定表示把以.php結尾的檔案請求發送到php-fpm行程,php-fpm至少需要知道運行的目錄和URI,所以這里直接在fcgi://127.0.0.1:9000后指明了這兩個引數,其它引數的傳遞已經被mod_proxy_fcgi.so進行了封裝,不需要手動指定,
注意:
這里寫的/var/www/html/是yum源安裝方式生成的網頁存放目錄,這里必須改成你編譯安裝指定的網頁存放路徑,禁止直接復制我這里的路徑,這里的idfsoft.com是域名,你必須改成你所使用的域名,禁止直接復制此處的域名

這里的$1表示匹配所有以.php結尾的http請求

3.5 驗證

轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/500864.html

標籤:MySQL

上一篇:精心整理16條MySQL使用規范,減少80%問題,推薦分享給團隊

下一篇:基于PHP7.2+MySQL5.7的回收租憑系統

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • GPU虛擬機創建時間深度優化

    **?桔妹導讀:**GPU虛擬機實體創建速度慢是公有云面臨的普遍問題,由于通常情況下創建虛擬機屬于低頻操作而未引起業界的重視,實際生產中還是存在對GPU實體創建時間有苛刻要求的業務場景。本文將介紹滴滴云在解決該問題時的思路、方法、并展示最終的優化成果。 從公有云服務商那里購買過虛擬主機的資深用戶,一 ......

    uj5u.com 2020-09-10 06:09:13 more
  • 可編程網卡芯片在滴滴云網路的應用實踐

    **?桔妹導讀:**隨著云規模不斷擴大以及業務層面對延遲、帶寬的要求越來越高,采用DPDK 加速網路報文處理的方式在橫向縱向擴展都出現了局限性。可編程芯片成為業界熱點。本文主要講述了可編程網卡芯片在滴滴云網路中的應用實踐,遇到的問題、帶來的收益以及開源社區貢獻。 #1. 資料中心面臨的問題 隨著滴滴 ......

    uj5u.com 2020-09-10 06:10:21 more
  • 滴滴資料通道服務演進之路

    **?桔妹導讀:**滴滴資料通道引擎承載著全公司的資料同步,為下游實時和離線場景提供了必不可少的源資料。隨著任務量的不斷增加,資料通道的整體架構也隨之發生改變。本文介紹了滴滴資料通道的發展歷程,遇到的問題以及今后的規劃。 #1. 背景 資料,對于任何一家互聯網公司來說都是非常重要的資產,公司的大資料 ......

    uj5u.com 2020-09-10 06:11:05 more
  • 滴滴AI Labs斬獲國際機器翻譯大賽中譯英方向世界第三

    **桔妹導讀:**深耕人工智能領域,致力于探索AI讓出行更美好的滴滴AI Labs再次斬獲國際大獎,這次獲獎的專案是什么呢?一起來看看詳細報道吧! 近日,由國際計算語言學協會ACL(The Association for Computational Linguistics)舉辦的世界最具影響力的機器 ......

    uj5u.com 2020-09-10 06:11:29 more
  • MPP (Massively Parallel Processing)大規模并行處理

    1、什么是mpp? MPP (Massively Parallel Processing),即大規模并行處理,在資料庫非共享集群中,每個節點都有獨立的磁盤存盤系統和記憶體系統,業務資料根據資料庫模型和應用特點劃分到各個節點上,每臺資料節點通過專用網路或者商業通用網路互相連接,彼此協同計算,作為整體提供 ......

    uj5u.com 2020-09-10 06:11:41 more
  • 滴滴資料倉庫指標體系建設實踐

    **桔妹導讀:**指標體系是什么?如何使用OSM模型和AARRR模型搭建指標體系?如何統一流程、規范化、工具化管理指標體系?本文會對建設的方法論結合滴滴資料指標體系建設實踐進行解答分析。 #1. 什么是指標體系 ##1.1 指標體系定義 指標體系是將零散單點的具有相互聯系的指標,系統化的組織起來,通 ......

    uj5u.com 2020-09-10 06:12:52 more
  • 單表千萬行資料庫 LIKE 搜索優化手記

    我們經常在資料庫中使用 LIKE 運算子來完成對資料的模糊搜索,LIKE 運算子用于在 WHERE 子句中搜索列中的指定模式。 如果需要查找客戶表中所有姓氏是“張”的資料,可以使用下面的 SQL 陳述句: SELECT * FROM Customer WHERE Name LIKE '張%' 如果需要 ......

    uj5u.com 2020-09-10 06:13:25 more
  • 滴滴Ceph分布式存盤系統優化之鎖優化

    **桔妹導讀:**Ceph是國際知名的開源分布式存盤系統,在工業界和學術界都有著重要的影響。Ceph的架構和演算法設計發表在國際系統領域頂級會議OSDI、SOSP、SC等上。Ceph社區得到Red Hat、SUSE、Intel等大公司的大力支持。Ceph是國際云計算領域應用最廣泛的開源分布式存盤系統, ......

    uj5u.com 2020-09-10 06:14:51 more
  • es~通過ElasticsearchTemplate進行聚合~嵌套聚合

    之前寫過《es~通過ElasticsearchTemplate進行聚合操作》的文章,這一次主要寫一個嵌套的聚合,例如先對sex集合,再對desc聚合,最后再對age求和,共三層嵌套。 Aggregations的部分特性類似于SQL語言中的group by,avg,sum等函式,Aggregation ......

    uj5u.com 2020-09-10 06:14:59 more
  • 爬蟲日志監控 -- Elastc Stack(ELK)部署

    傻瓜式部署,只需替換IP與用戶 導讀: 現ELK四大組件分別為:Elasticsearch(核心)、logstash(處理)、filebeat(采集)、kibana(可視化) 下載均在https://www.elastic.co/cn/downloads/下tar包,各組件版本最好一致,配合fdm會 ......

    uj5u.com 2020-09-10 06:15:05 more
最新发布
  • day02-2-商鋪查詢快取

    功能02-商鋪查詢快取 3.商鋪詳情快取查詢 3.1什么是快取? 快取就是資料交換的緩沖區(稱作Cache),是存盤資料的臨時地方,一般讀寫性能較高。 快取的作用: 降低后端負載 提高讀寫效率,降低回應時間 快取的成本: 資料一致性成本 代碼維護成本 運維成本 3.2需求說明 如下,當我們點擊商店詳 ......

    uj5u.com 2023-04-20 08:33:24 more
  • MySQL中binlog備份腳本分享

    關于MySQL的二進制日志(binlog),我們都知道二進制日志(binlog)非常重要,尤其當你需要point to point災難恢復的時侯,所以我們要對其進行備份。關于二進制日志(binlog)的備份,可以基于flush logs方式先切換binlog,然后拷貝&壓縮到到遠程服務器或本地服務器 ......

    uj5u.com 2023-04-20 08:28:06 more
  • day02-短信登錄

    功能實作02 2.功能01-短信登錄 2.1基于Session實作登錄 2.1.1思路分析 2.1.2代碼實作 2.1.2.1發送短信驗證碼 發送短信驗證碼: 發送驗證碼的介面為:http://127.0.0.1:8080/api/user/code?phone=xxxxx<手機號> 請求方式:PO ......

    uj5u.com 2023-04-20 08:27:27 more
  • 快取與資料庫雙寫一致性幾種策略分析

    本文將對幾種快取與資料庫保證資料一致性的使用方式進行分析。為保證高并發性能,以下分析場景不考慮執行的原子性及加鎖等強一致性要求的場景,僅追求最終一致性。 ......

    uj5u.com 2023-04-20 08:26:48 more
  • sql陳述句優化

    問題查找及措施 問題查找 需要找到具體的代碼,對其進行一對一優化,而非一直把關注點放在服務器和sql平臺 降低簡化每個事務中處理的問題,盡量不要讓一個事務拖太長的時間 例如檔案上傳時,應將檔案上傳這一步放在事務外面 微軟建議 4.啟動sql定時執行計劃 怎么啟動sqlserver代理服務-百度經驗 ......

    uj5u.com 2023-04-20 08:26:35 more
  • 云時代,MySQL到ClickHouse資料同步產品對比推薦

    ClickHouse 在執行分析查詢時的速度優勢很好的彌補了MySQL的不足,但是對于很多開發者和DBA來說,如何將MySQL穩定、高效、簡單的同步到 ClickHouse 卻很困難。本文對比了 NineData、MaterializeMySQL(ClickHouse自帶)、Bifrost 三款產品... ......

    uj5u.com 2023-04-20 08:26:29 more
  • sql陳述句優化

    問題查找及措施 問題查找 需要找到具體的代碼,對其進行一對一優化,而非一直把關注點放在服務器和sql平臺 降低簡化每個事務中處理的問題,盡量不要讓一個事務拖太長的時間 例如檔案上傳時,應將檔案上傳這一步放在事務外面 微軟建議 4.啟動sql定時執行計劃 怎么啟動sqlserver代理服務-百度經驗 ......

    uj5u.com 2023-04-20 08:25:13 more
  • Redis 報”OutOfDirectMemoryError“(堆外記憶體溢位)

    Redis 報錯“OutOfDirectMemoryError(堆外記憶體溢位) ”問題如下: 一、報錯資訊: 使用 Redis 的業務介面 ,產生 OutOfDirectMemoryError(堆外記憶體溢位),如圖: 格式化后的報錯資訊: { "timestamp": "2023-04-17 22: ......

    uj5u.com 2023-04-20 08:24:54 more
  • day02-2-商鋪查詢快取

    功能02-商鋪查詢快取 3.商鋪詳情快取查詢 3.1什么是快取? 快取就是資料交換的緩沖區(稱作Cache),是存盤資料的臨時地方,一般讀寫性能較高。 快取的作用: 降低后端負載 提高讀寫效率,降低回應時間 快取的成本: 資料一致性成本 代碼維護成本 運維成本 3.2需求說明 如下,當我們點擊商店詳 ......

    uj5u.com 2023-04-20 08:24:03 more
  • day02-短信登錄

    功能實作02 2.功能01-短信登錄 2.1基于Session實作登錄 2.1.1思路分析 2.1.2代碼實作 2.1.2.1發送短信驗證碼 發送短信驗證碼: 發送驗證碼的介面為:http://127.0.0.1:8080/api/user/code?phone=xxxxx<手機號> 請求方式:PO ......

    uj5u.com 2023-04-20 08:23:11 more