搭建lamp

来源:https://www.cnblogs.com/tushanbu/archive/2022/08/03/16545686.html
-Advertisement-
Play Games

lamp 1. lamp簡介 lamp,其實就是由Linux+Apache+Mysql/MariaDB+Php/Perl/Python的一組動態網站或者伺服器的開源軟體 LAMP指的是Linux(操作系統)、Apache(HTTP伺服器)、MySQL(也指MariaDB,資料庫軟體)和PHP(有時也 ...


lamp


目錄

1. lamp簡介

lamp,其實就是由Linux+Apache+Mysql/MariaDB+Php/Perl/Python的一組動態網站或者伺服器的開源軟體
LAMP指的是Linux(操作系統)、Apache(HTTP伺服器)、MySQL(也指MariaDB,資料庫軟體)和PHP(有時也是指Perl或Python)的第一個字母,一般用來建立web應用平臺。

2. web伺服器工作流程

web伺服器的資源分為兩種,靜態資源和動態資源
靜態資源:當我們獲取它的時候,它裡面的源的表現形式與原文件相同不會發生什麼改變。
動態資源:程式文件,我們日常執行的命令在不同的主機裡面執行出來的結果是不一樣的

當我們在客戶端訪問web伺服器資源的時候,前端會把這個請求轉發給應用伺服器這裡,然後應用伺服器會到資料庫裡面進行查詢並反饋給前端,前端再反饋給客戶端

3. lamp平臺構建

環境說明:

系統平臺 IP 需要安裝的服務
centos8 redhat8 192.168.222.250 httpd-2.4,mysql5.7,php,phpmysql

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

註意:php要求httpd使用prefork MPM

3.1 安裝httpd

yum源的配置:
[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]#rm -rf *
[[email protected] yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
//在阿裡雲網站裡面複製的倉庫鏈接
[[email protected] yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[[email protected] yum.repos.d]# ls
CentOS-Base.repo
[[email protected] yum.repos.d]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
[[email protected] yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[[email protected] yum.repos.d]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
//安裝epel源,也是在阿裡雲網站裡面複製鏈接
[[email protected] yum.repos.d]# ls
CentOS-Base.repo   epel.repo                  epel-testing.repo
epel-modular.repo  epel-testing-modular.repo
[[email protected] yum.repos.d]# cat epel.repo //查看裡面地址是否改變
[epel]
name=Extra Packages for Enterprise Linux 8 - $basearch
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
baseurl=https://mirrors.aliyun.com/epel/8/Everything/$basearch
#metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-8&arch=$basearch&infra=$infra&content=$contentdir
enabled=1
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 8 - $basearch - Debug
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
baseurl=https://mirrors.aliyun.com/epel/8/Everything/$basearch/debug
#metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-8&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux 8 - $basearch - Source
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place it's address here.
baseurl=https://mirrors.aliyun.com/epel/8/Everything/source/tree/
#metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-8&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-8
gpgcheck=1
[[email protected] yum.repos.d]# dnf makecache //緩存一下
[[email protected] ~]# dnf groups mark install 'Development Tools'
//安裝開發工具包
Last metadata expiration check: 0:03:41 ago on Tue 02 Aug 2022 09:17:12 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 Groups:
 Development Tools                                                                

Transaction Summary
===================================================================================

Is this ok [y/N]: y
Complete!
[[email protected] ~]# useradd -r -M -s /sbin/nologin  apache
//創建用戶的時候它會創建一個和用戶名相同名字的組  
//創建apache服務的用戶和組
[[email protected] ~]# dnf -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ wget vim make
//安裝依賴包
[[email protected] ~]# 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
//在https://downloads.apache.org/官網裡面下載
[[email protected] ~]# ls
anaconda-ks.cfg  apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz  httpd-2.4.54.tar.gz
[[email protected] ~]# tar -xf apr-1.7.0.tar.gz 
[[email protected] ~]# tar -xf apr-util-1.6.1.tar.gz 
[[email protected] ~]# tar -xf httpd-2.4.54.tar.gz 
[[email protected] ~]# 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
[[email protected] ~]# cd apr-1.7.0/
[[email protected] apr-1.7.0]# ls
apr-config.in  build-outputs.mk  helpers       misc           strings
apr.dep        CHANGES           include       mmap           support
apr.dsp        CMakeLists.txt    libapr.dep    network_io     tables
apr.dsw        config.layout     libapr.dsp    NOTICE         test
apr.mak        configure         libapr.mak    NWGNUmakefile  threadproc
apr.pc.in      configure.in      libapr.rc     passwd         time
apr.spec       docs              LICENSE       poll           tools
atomic         dso               locks         random         user
build          emacs-mode        Makefile.in   README
build.conf     encoding          Makefile.win  README.cmake
buildconf      file_io           memory        shmem
[[email protected] apr-1.7.0]# vim configure
#    $RM "$cfgfile"    //刪除或者註釋掉這個
[[email protected] apr-1.7.0]# ./configure --prefix=/usr/local/apr
...
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
[[email protected] apr-1.7.0]# make
[[email protected] apr-1.7.0]# make install
[[email protected] apr-1.7.0]# cd ../apr-util-1.6.1/
[[email protected] apr-util-1.6.1]# ls
aprutil.dep       CHANGES            include         NWGNUmakefile
aprutil.dsp       CMakeLists.txt     ldap            README
aprutil.dsw       config.layout      libaprutil.dep  README.cmake
aprutil.mak       configure          libaprutil.dsp  README.FREETDS
apr-util.pc.in    configure.in       libaprutil.mak  redis
apr-util.spec     crypto             libaprutil.rc   renames_pending
apu-config.in     dbd                LICENSE         strmatch
buckets           dbm                Makefile.in     test
build             docs               Makefile.win    uri
build.conf        encoding           memcache        xlate
buildconf         export_vars.sh.in  misc            xml
build-outputs.mk  hooks              NOTICE
[[email protected] apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[[email protected] apr-util-1.6.1]# make
[[email protected] apr-util-1.6.1]# make install
[[email protected] ~]# ls /usr/local/
apr  apr-util  bin  etc  games  include  lib  lib64  libexec  sbin  share  src
[[email protected] ~]# cd httpd-2.4.54/
[[email protected] httpd-2.4.54]# ls
ABOUT_APACHE     CHANGES          httpd.mak       Makefile.in       ROADMAP
acinclude.m4     changes-entries  httpd.spec      Makefile.win      server
Apache-apr2.dsw  CMakeLists.txt   include         modules           srclib
Apache.dsw       config.layout    INSTALL         NOTICE            support
apache_probes.d  configure        InstallBin.dsp  NWGNUmakefile     test
ap.d             configure.in     LAYOUT          os                VERSIONING
build            docs             libhttpd.dep    README
BuildAll.dsp     emacs-style      libhttpd.dsp    README.CHANGES
BuildBin.dsp     httpd.dep        libhttpd.mak    README.cmake
buildconf        httpd.dsp        LICENSE         README.platforms
[[email protected] 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
....
 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
[[email protected] httpd-2.4.54]# make
[[email protected] httpd-2.4.54]# make install
[[email protected] httpd-2.4.54]# cd
[[email protected] ~]# 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
[[email protected] ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh   //配置環境變數
[[email protected] ~]# cat /etc/profile.d/httpd.sh 
export PATH=/usr/local/apache/bin:$PATH
[[email protected] ~]# ls /usr/local/
apache  apr-util  etc    include  lib64    sbin   src
apr     bin       games  lib      libexec  share
[[email protected] ~]# source /etc/profile.d/httpd.sh 
[[email protected] ~]# which httpd  //查看路徑
/usr/local/apache/bin/httpd
[[email protected] ~]# ls /usr/local/apache/
bin    cgi-bin  error   icons    logs  manual
build  conf     htdocs  include  man   modules
[[email protected] ~]# ln -s /usr/local/apache/include /usr/include/apache
//做一個頭文件軟鏈接
[[email protected] ~]# ll -d /usr/include/apache
lrwxrwxrwx. 1 root root 25 Aug  2 22:37 /usr/include/apache -> /usr/local/apache/include
[[email protected] ~]# 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//添加這一行
[[email protected] ~]# cd /usr/lib/systemd/system
[[email protected] system]# cp sshd.service httpd.service
[[email protected] system]# vim httpd.service 
[Unit]
Description=httpd server daemon
Documentation=man:httpd(5)
After=network.target sshd-keygen.target

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

[Install]
WantedBy=multi-user.target
[[email protected] system]# cd
[[email protected] ~]# systemctl daemon-reload 
[[email protected] ~]# systemctl enable --now httpd.service //設置開機自啟
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[[email protected] ~]# 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                [::]:*                
[[email protected] ~]# systemctl status httpd.service 
● httpd.service - httpd server daemon
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: >
   Active: active (running) since Tue 2022-08-02 22:49:17 CST; 30s ago
     Docs: man:httpd(5)
  Process: 49081 ExecStart=/usr/local/apache/bin/apachectl start (code=exited, sta>
 Main PID: 49084 (httpd)
    Tasks: 6 (limit: 12221)
   Memory: 5.7M
   CGroup: /system.slice/httpd.service
           ├─49084 /usr/local/apache/bin/httpd -k start
           ├─49085 /usr/local/apache/bin/httpd -k start
           ├─49086 /usr/local/apache/bin/httpd -k start
           ├─49087 /usr/local/apache/bin/httpd -k start
           ├─49088 /usr/local/apache/bin/httpd -k start
           └─49089 /usr/local/apache/bin/httpd -k start

Aug 02 22:49:17 lnh systemd[1]: Starting httpd server daemon...
Aug 02 22:49:17 lnh apachectl[49081]: AH00558: httpd: Could not reliably determine>
Aug 02 22:49:17 lnh systemd[1]: Started httpd server daemon.

3.2 安裝mysql

[[email protected] ~]# dnf -y install ncurses-devel openssl-devel openssl cmake mariadb-devel
//安裝依賴包
[[email protected] ~]# useradd -r -M -s /sbin/nologin mysql
//創建用戶和組
[[email protected] ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
//下載二進位格式的mysql軟體包
[[email protected] ~]# ls
anaconda-ks.cfg   apr-util-1.6.1.tar.gz
apr-1.7.0         httpd-2.4.54
apr-1.7.0.tar.gz  httpd-2.4.54.tar.gz
apr-util-1.6.1    mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
[[email protected] ~]# tar -xf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[[email protected] ~]# cd /usr/local/
[[email protected] local]# ls
apache    bin    include  libexec                              share
apr       etc    lib      mysql-5.7.38-linux-glibc2.12-x86_64  src
apr-util  games  lib64    sbin
[[email protected] local]# mv mysql-5.7.38-linux-glibc2.12-x86_64 mysql
//也可以做軟鏈接ln -sv mysql-5.7.38-linux-glibc2.12-x86_64 mysql
[[email protected] local]# ls
apache  apr-util  etc    include  lib64    mysql  share
apr     bin       games  lib      libexec  sbin   src
[[email protected] local]# chown -R mysql.mysql mysql  //修改目錄/usr/local/mysql的屬主屬組
[[email protected] local]# ll
total 0
drwxr-xr-x. 14 root  root  164 Aug  2 22:32 apache
drwxr-xr-x.  6 root  root   58 Aug  2 22:17 apr
drwxr-xr-x.  5 root  root   43 Aug  2 22:20 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 Jul 19 16:13 lib64
drwxr-xr-x.  2 root  root    6 May 19  2020 libexec
drwxr-xr-x.  9 mysql mysql 129 Aug  2 23:21 mysql
drwxr-xr-x.  2 root  root    6 May 19  2020 sbin
drwxr-xr-x.  5 root  root   49 Jul 19 16:13 share
drwxr-xr-x.  2 root  root    6 May 19  2020 src
[[email protected] local]# ln -s /usr/local/mysql/include  /usr/include/mysql
[[email protected] local]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[[email protected] 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/apache/man
MANDATORY_MANPATH                       /usr/local/mysql/man//添加這一行
[[email protected] local]# cd
[[email protected] ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
//配置環境變數
[[email protected] ~]# source /etc/profile.d/mysql.sh 
[[email protected] ~]# which mysql
/usr/local/mysql/bin/mysql
//查找mysql
[[email protected] ~]# mkdir -p /opt/data
[[email protected] ~]# chown -R mysql.mysql /opt/data/
//建立數據存放目錄
[[email protected] ~]# mysqld --initialize --user mysql --datadir /opt/data
//初始化資料庫
2022-08-02T15:38:19.770486Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-08-02T15:38:19.958740Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-08-02T15:38:19.986757Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-08-02T15:38:19.992972Z 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: 22a4ea73-1279-11ed-a567-000c2905f428.
2022-08-02T15:38:19.995310Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-08-02T15:38:20.416458Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-08-02T15:38:20.416497Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-08-02T15:38:20.417285Z 0 [Warning] CA certificate ca.pem is self signed.
2022-08-02T15:38:20.478216Z 1 [Note] A temporary password is generated for [email protected]: iBUh*ijeb45h
[[email protected] ~]# echo 'iBUh*ijeb45h' > password
[[email protected] ~]# cat password 
iBUh*ijeb45h
//將臨時密碼保存到這個文件裡面
[[email protected] ~]# 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
//查找mariadb的資料庫
[[email protected] ~]# dnf -y remove mariadb*
//要卸載掉mariadb資料庫不然到時候和mysql資料庫發生衝突
[[email protected] ~]# rpm -qa |grep mariadb
[[email protected] ~]# vim /etc/my.cnf
[ro[email protected] ~]# cat /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
[[email protected] ~]# cd /usr/local/mysql/
[[email protected] mysql]# ls
bin  docs  include  lib  LICENSE  man  README  share  support-files
[[email protected] mysql]# cd support-files/
[[email protected] support-files]# ls
magic  mysqld_multi.server  mysql-log-rotate  mysql.server
[[email protected] support-files]# file mysql.server 
mysql.server: POSIX shell script, ASCII text executable
//是一個腳本文件
[[email protected] support-files]# cp mysql.server /etc/init.d/mysqld
[[email protected] support-files]# vim /etc/init.d/mysqld 
basedir=/usr/local/mysql    //資料庫存放位置
datadir=/opt/data    //數據存放位置
[[email protected] support-files]# chmod +x /etc/init.d/mysqld 
//賦予執行許可權
[[email protected] ~]# service mysqld start   //啟動服務
Starting MySQL.Logging to '/opt/data/lnh.err'.
 SUCCESS! 
[[email protected] ~]# 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                [::]:*                
[[email protected] ~]# chkconfig --add mysqld  //設置開機自啟
[[email protected] ~]# 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
//在2,3,4,5下麵開機自啟了
[[email protected] ~]# systemctl stop firewalld.service 
[[email protected] ~]# systemctl disable firewalld.service 
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[[email protected] ~]# vim /etc/selinux/config 
SELINUX=disabled
[[email protected] ~]# setenforce 0
//關閉防火牆
[[email protected] ~]# cd /usr/lib/systemd/system
[[email protected] system]# cp sshd.service mysqld.service
[[email protected] system]# vim mysqld.service 
[Unit]
Description=mysqld server daemon
Documentation=man:sshd(8) man:sshd_config(5)
After=network.target sshd-keygen.target
Wants=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
[[email protected] system]# cd
[[email protected] ~]# systemctl daemon-reload  //重新載入
[[email protected] ~]# systemctl restart mysqld.service //重啟服務
[[email protected] ~]# 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                [::]:*       
[[email protected] ~]# cat password 
iBUh*ijeb45h
[[email protected] ~]# mysql -uroot -p'iBUh*ijeb45h'
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('lnh123'); //修改密碼
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> quit
Bye
[[email protected] ~]# mysql -uroot -p'lnh123'
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.
//密碼修改成功         

3.3 安裝php

[[email protected] ~]# wget https://www.php.net/distributions/php-7.4.30.tar.xz
//在網站php.net裡面複製網址
[[email protected] ~]# ls
anaconda-ks.cfg   apr-util-1.6.1.tar.gz                       password
apr-1.7.0         httpd-2.4.54                                php-7.4.30.tar.xz
apr-1.7.0.tar.gz  httpd-2.4.54.tar.gz
apr-util-1.6.1    mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
[[email protected] ~]# sha256sum php-7.4.30.tar.xz
ea72a34f32c67e79ac2da7dfe96177f3c451c3eefae5810ba13312ed398ba70d  php-7.4.30.tar.xz
//查看是否是要下載的包
[[email protected] ~]# dnf list |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   
//查看新的安裝包
[[email protected] ~]# 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
//安裝依賴包
[[email protected] ~]# ls
anaconda-ks.cfg   apr-util-1.6.1.tar.gz                       password
apr-1.7.0         httpd-2.4.54                                php-7.4.30.tar.xz
apr-1.7.0.tar.gz  httpd-2.4.54.tar.gz
apr-util-1.6.1    mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
[[email protected] ~]# tar -xf php-7.4.30.tar.xz 
//解壓
[[email protected] ~]#cd php-7.4.30/
[[email protected] 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
.....
+--------------------------------------------------------------------+
| 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.
//編譯測試安裝php
[[email protected] php-7.4.30]# make
//編譯
[[email protected] php-7.4.30]# make install
//安裝
[[email protected] php-7.4.30]# echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php7.sh
//配置環境變數
[[email protected] php-7.4.30]# source /etc/profile.d/php7.sh 
[[email protected] php-7.4.30]# which php    //查找php
/usr/local/php7/bin/php
[[email protected] php-7.4.30]# php -v     //查看版本號
PHP 7.4.30 (cli) (built: Aug  3 2022 01:17:12) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
[[email protected] php-7.4.30]# ls
appveyor             configure.ac     Makefile.fragments   scripts
azure                CONTRIBUTING.md  Makefile.objects     tests
azure-pipelines.yml  docs             modules              travis
build                ext              NEWS                 TSRM
buildconf            EXTENSIONS       pear                 UPGRADING
buildconf.bat        include          php.ini-development  UPGRADING.INTERNALS
CODING_STANDARDS.md  libs             php.ini-production   win32
config.log           libtool          README.md            Zend
config.nice          LICENSE          README.REDIST.BINS
config.status        main             run-tests.php
configure            Makefile         sapi
[[email protected] php-7.4.30]# cp php.ini-production /etc/php.ini 
cp: overwrite '/etc/php.ini'? y
//配置生產環境
[[email protected] php-7.4.30]# ls
appveyor             configure.ac     Makefile.fragments   scripts
azure                CONTRIBUTING.md  Makefile.objects     tests
azure-pipelines.yml  docs             modules              travis
build                ext              NEWS                 TSRM
buildconf            EXTENSIONS       pear                 UPGRADING
buildconf.bat        include          php.ini-development  UPGRADING.INTERNALS
CODING_STANDARDS.md  libs             php.ini-production   win32
config.log           libtool          README.md            Zend
config.nice          LICENSE          README.REDIST.BINS
config.status        main             run-tests.php
configure            Makefile         sapi
[[email protected] php-7.4.30]# cd sapi/
[[email protected] sapi]# ls
apache2handler  cgi  cli  embed  fpm  litespeed  phpdbg
[[email protected] sapi]# cd fpm/
[[email protected] fpm]# ls
config.m4          LICENSE        php-fpm.conf        status.html.in
CREDITS            Makefile.frag  php-fpm.conf.in     tests
fpm                php-fpm        php-fpm.service     www.conf
init.d.php-fpm     php-fpm.8      php-fpm.service.in  www.conf.in
init.d.php-fpm.in  php-fpm.8.in   status.html
[[email protected] fpm]# file init.d.php-fpm
init.d.php-fpm: POSIX shell script, ASCII text executable
[[email protected] fpm]# cp init.d.php-fpm /etc/init.d/php-fpm  //配置php-fpm
[[email protected] fpm]# chmod +x /etc/init.d/php-fpm 
//賦予執行許可權
[[email protected] ~]# service php-fpm status 
php-fpm is stopped
//此時還沒有正式啟動
[[email protected] ~]# cd /usr/local/php7/
[[email protected] php7]# ls
bin  etc  include  lib  php  sbin  var
[[email protected] php7]# cd etc/
[[email protected] etc]# ls    //查看
pear.conf  php-fpm.conf.default  php-fpm.d
[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf
[[email protected] etc]# ls   //查看複製後的文件
pear.conf  php-fpm.conf  php-fpm.conf.default  php-fpm.d
[[email protected] etc]# cd php-fpm.d/
[[email protected] php-fpm.d]# ls
www.conf.default
[[email protected] php-fpm.d]# cp www.conf.default www.conf
[[email protected] php-fpm.d]# ls   //查看複製後的文件
www.conf  www.conf.default
[[email protected] php-fpm.d]# service php-fpm start 
Starting php-fpm  done
//開啟服務
[[email protected] 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                [::]:*                
[[email protected] php-fpm.d]# cd 
[[email protected] ~]# chkconfig --add php-fpm   //設置開機自啟
[[email protected] ~]# 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]'.

php-fpm        	0:off	1:off	2:on	3:on	4:on	5:on	6:off
//可以看見2,3,4,5,是開機自啟
[[email protected] ~]# ps -ef|grep php
root      214276       1  0 01:53 ?        00:00:00 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf)
nobody    214277  214276  0 01:53 ?        00:00:00 php-fpm: pool www
nobody    214278  214276  0 01:53 ?        00:00:00 php-fpm: pool www
root      214325   51892  0 01:56 pts/0    00:00:00 grep --color=auto php
//查看進程

報錯解決

報錯1:
[[email protected] ~]# mysql -uroot -p'iBUh*ijeb45h'
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
解決:
[[email protected] ~]# dnf provides libncurses.so.5
Last metadata expiration check: 0:14:32 ago on Tue 02 Aug 2022 11:53:43 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

[[email protected] ~]# dnf -y install ncurses-compat-libs

報錯2:
configure: error: Package requirements (sqlite3 > 3.7.4) were not met:

Package 'sqlite3', required by 'virtual:world', not found
解決:
[email protected] php-7.4.30]# dnf list |grep sqlite3
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]
libsqlite3x.x86_64                                                20071018-26.el8                                        epel         
libsqlite3x-devel.x86_64                                          20071018-26.el8                                        epel         
preludedb-sqlite3.x86_64                                          5.2.0-1.el8                                            epel         
rubygem-sqlite3.x86_64                                            1.4.2-2.el8                                            epel         
rubygem-sqlite3-doc.noarch                                        1.4.2-2.el8                                            epel         
soci-sqlite3.x86_64                                               4.0.0-2.el8                                            epel         
soci-sqlite3-devel.x86_64                                         4.0.0-2.el8                                            epel         
uwsgi-plugin-sqlite3.x86_64                                       2.0.20-1.el8                                           epel         
zabbix-dbfiles-sqlite3.noarch                                     6.0.2-1.module_el8+14182+e1fc92db                      epel-modular 
zabbix-proxy-sqlite3.x86_64                                       6.0.2-1.module_el8+14182+e1fc92db                      epel-modular 
zabbix40-dbfiles-sqlite3.noarch                                   4.0.39-1.el8                                           epel         
zabbix40-proxy-sqlite3.x86_64                                     4.0.39-1.el8                                           epel         
//查找系統中的安裝包,選擇第二個
[[email protected] php-7.4.30]# dnf -y install libsqlite3x-devel

報錯3:
configure: error: Package requirements (oniguruma) were not met:

Package 'oniguruma', required by 'virtual:world', not found
解決:
[[email protected] php-7.4.30]# dnf list all|grep oniguruma
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]
oniguruma.i686                                                    6.8.2-2.el8                                            AppStream    
oniguruma.x86_64                                                  6.8.2-2.el8                                            AppStream    
//在系統中查找的不是這個安裝包
https://pkgs.org/ 在這個網站裡面查找
oniguruma-devel
[[email protected] php-7.4.30]# 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

報錯4:
configure: WARNING: unrecognized options: --with-gd, --with-jpeg-dir, --with-png-dir, --with-freetype-dir, --enable-zip
解決:
[[email protected] php-7.4.30]# ./configure --help|grep gd
  --with-gdbm[=DIR]       DBA: GDBM support
  --enable-gd (新的)            Include GD support
  --with-external-gd      Use external libgd
  --with-webp             GD: Enable WEBP support (only for bundled libgd)
  --with-jpeg             GD: Enable JPEG support (only for bundled libgd)
  --with-xpm              GD: Enable XPM support (only for bundled libgd)
                          libgd)
  --enable-gd-jis-conv    GD: Enable JIS-mapped Japanese font support (only
                          for bundled libgd)
[[email protected] php-7.4.30]# ./configure --help|grep jpeg
  --with-jpeg             GD: Enable JPEG support (only for bundled libgd)
[[email protected] php-7.4.30]# ./configure --help|grep png
[[email protected] php-7.4.30]# 
[[email protected] php-7.4.30]# ./configure --help|grep freetype
  --with-freetype         GD: Enable FreeType 2 support (only for bundled
[[email protected] php-7.4.30]# ./configure --help|grep zip
  --with-zip              Include Zip read/write support
報錯5:
configure: error: Package requirements (libzip >= 0.11 libzip != 1.3.1 libzip != 1.7.0) were not met:

Package 'libzip', required by 'virtual:world', not found
Package 'libzip', required by 'virtual:world', not found
Package 'libzip', required by 'virtual:world', not found
解決:
[[email protected] ~]# dnf list all|grep zip|grep lib //在系統中查找
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]
bzip2-libs.i686                                                   1.0.6-26.el8                                           @base        
bzip2-libs.x86_64                                                 1.0.6-26.el8                                           @anaconda    
libzip.x86_64                                                     1.5.1-2.module_el8.2.0+313+b04d0a66                    AppStream    
libzip-devel.x86_64                                               1.5.1-2.module_el8.2.0+313+b04d0a66                    AppStream    
libzip-tools.x86_64                                               1.5.1-2.module_el8.2.0+313+b04d0a66                    AppStream    
zziplib.i686                                                      0.13.68-9.el8                                          AppStream    
zziplib.x86_64                                                    0.13.68-9.el8                                          AppStream    
zziplib-utils.x86_64                                              0.13.68-9.el8                                          AppStream    
[[email protected] ~]# dnf -y install libzip-devel

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

-Advertisement-
Play Games
更多相關文章
  • 明敏 曉查 發自 凹非寺 量子位 報道 | 公眾號 QbitAI 程式 bug 也能負負得正嗎? 還真可以。 比如程式員們再熟悉不過的排序演算法,通過兩個“bug”居然能歪打正著,實在令人匪夷所思。 請看這位程式員寫的數組升序排序代碼: for i = 1 to n do for j = 1 to n ...
  • 基礎確認: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 ...
一周排行
    -Advertisement-
    Play Games
  • Github / Gitee QQ群(1群) : 813100564 / QQ群(2群) : 579033769 視頻教學 介紹 MiniWord .NET Word模板引擎,藉由Word模板和數據簡單、快速生成文件。 Getting Started 安裝 nuget link : https:// ...
  • Array.Sort Array類中相當實用的我認為是Sort方法,相比起冗長的冒泡排序,它的出現讓排序更加的簡化 結果如下: 還可以聲明一個靜態方法用來專門調用指定數組排序,從名為 array 的一維數組中 a 索引處開始,到 b 元素 從小到大排序。 註意: a + b 不能大於 array 的 ...
  • 前言 在上一篇文章CLR類型系統概述里提到,當運行時掛起時, 垃圾回收會執行堆棧遍歷器(stack walker)去拿到堆棧上值類型的大小和堆棧根。這裡我們來翻譯BotR里一篇專門介紹Stackwalking的文章,希望能加深理解。 順便說一句,StackWalker在中文里似乎還沒有統一的翻譯,J ...
  • 使用過 nginx 的小伙伴應該都知道,這個中間件是可以設置跨域的,作為今天的主角,同樣的 反向代理中間件的 YARP 毫無意外也支持了跨域請求設置。 有些小伙伴可能會問了,怎樣才算是跨域呢? 在 HTML 中,一些標簽,例如 img、a 等,還有我們非常熟悉的 Ajax,都是可以指向非本站的資源的 ...
  • 什麼是Git Git 是一個開源的分散式版本控制系統,用於敏捷高效地處理任何或小或大的項目。 Git 是 Linus Torvalds 為了幫助管理 Linux 內核開發而開發的一個開放源碼的版本控制軟體。 Git 與常用的版本控制工具 CVS, Subversion 等不同,它採用了分散式版本庫的 ...
  • 首先CR3是什麼,CR3是一個寄存器,該寄存器內保存有頁目錄表物理地址(PDBR地址),其實CR3內部存放的就是頁目錄表的記憶體基地址,運用CR3切換可實現對特定進程記憶體地址的強制讀寫操作,此類讀寫屬於有痕讀寫,多數驅動保護都會將這個地址改為無效,此時CR3讀寫就失效了,當然如果能找到CR3的正確地址... ...
  • 說明 onlyoffice為一款開源的office線上編輯組件,提供word/excel/ppt編輯保存操作 以下操作均基於centos8系統,officeonly鏡像版本7.1.2.23 鏡像下載地址:https://yunpan.360.cn/surl_y87CKKcPdY4 (提取碼:1f92 ...
  • 二叉樹查找指定的節點 前序查找的思路 1.先判斷當前節點的no是否等於要查找的 2.如果是相等,則返回當前節點 3.如果不等,則判斷當前節點的左子節點是否為空,如果不為空,則遞歸前序查找 4.如果左遞歸前序查找,找到節點,則返回,否繼續判斷,當前的節點的右子節點是否為空,如果不為空,則繼續向右遞歸前 ...
  • ##Invalid bound statement (not found)出現原因和解決方法 ###前言: 想必各位小伙伴在碼路上經常會碰到奇奇怪怪的事情,比如出現Invalid bound statement (not found),那今天我就來分析以下出現此問題的原因。 其實出現這個問題實質就是 ...
  • ###一、背景知識 爬蟲的本質就是一個socket客戶端與服務端的通信過程,如果我們有多個url待爬取,只用一個線程且採用串列的方式執行,那隻能等待爬取一個結束後才能繼續下一個,效率會非常低。 需要強調的是:對於單線程下串列N個任務,並不完全等同於低效,如果這N個任務都是純計算的任務,那麼該線程對c ...