當(dāng)前位置:首頁 > IT技術(shù) > 數(shù)據(jù)庫 > 正文

手動(dòng)編譯部署LNMP環(huán)境(CentOS7.5+Nginx-1.18.0+MySQL-5.7.30+PHP-7.4.14)
2021-09-09 09:36:54

在平時(shí)運(yùn)維工作中,經(jīng)常需要用到LNMP應(yīng)用框架。LNMP環(huán)境是指在Linux系統(tǒng)下,由Nginx + MySQL + PHP組成的網(wǎng)站服務(wù)器架構(gòu)。

可參考前面的文章:

?(1) CentOS7.5

(系統(tǒng)最小化安裝)

# 更改主機(jī)名
[root@localhost ~]# hostnamectl set-hostname --static lnmp-01 && exec bash

# 關(guān)閉SELinux
[root@lnmp-01 ~]# sed -i '7s/enforcing/disabled/' /etc/selinux/config
[root@lnmp-01 ~]# setenforce 0
[root@lnmp-01 ~]# getenforce
Permissive

# 關(guān)閉firewalld
[root@lnmp-01 ~]# systemctl stop firewalld && systemctl disable firewalld

# 查看內(nèi)核版本
[root@lnmp-01 ~]# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@lnmp-01 ~]# uname -r
3.10.0-862.el7.x86_64

# 安裝基礎(chǔ)軟件
[root@lnmp-01 ~]# yum install -y vim wget lsof net-tools tree curl lrzsz

?(2) Nginx-1.18.0??

【官方下載站點(diǎn):源碼包rpm包,版本號(hào)A.B.C,B是偶數(shù)為穩(wěn)定版;奇數(shù)則為開發(fā)版】【官方站點(diǎn):configure命令參數(shù)

# 查看是否已安裝,有則卸載
[root@lnmp-01 ~]# yum list installed | egrep nginx
[root@lnmp-01 ~]# yum remove -y nginx.x86_64 nginx-xxx

# 創(chuàng)建nginx用戶和目錄
[root@lnmp-01 ~]# useradd -M -s /sbin/nologin nginx
[root@lnmp-01 ~]# mkdir -p /data/apps/nginx

# 安裝nginx 編譯所需依賴
[root@lnmp-01 ~]# yum -y install gcc gcc-c++ make zlib-devel pcre-devel openssl-devel
[root@lnmp-01 ~]# wget http://nginx.org/download/nginx-1.18.0.tar.gz
[root@lnmp-01 ~]# tar -xf nginx-1.18.0.tar.gz
[root@lnmp-01 ~]# ls
nginx-1.18.0  nginx-1.18.0.tar.gz
[root@lnmp-01 ~]# cd nginx-1.18.0
# 選擇相應(yīng)的編譯參數(shù)【官方站點(diǎn):configure命令參數(shù)】
[root@lnmp-01 nginx-1.18.0]# ./configure --help
[root@lnmp-01 nginx-1.18.0]# ./configure --prefix=/data/apps/nginx 
--user=nginx 
--group=nginx 
--with-http_ssl_module 
--with-http_flv_module 
--with-http_stub_status_module 
--with-http_gzip_static_module

編譯參數(shù)解析
  --prefix=      安裝目錄路徑
  --user=       用戶
  --group=      組
  --with-http_ssl_module    支持HTTPS協(xié)議
  --with-http_flv_module    支持Flash視頻  
  --with-http_stub_status_module  提供訪問的狀態(tài)信息
  --with-http_gzip_static_module  支持gzip壓縮文件

[root@lnmp-01 nginx-1.18.0]# make -j 4 && make install    #make -j 4 表示開4核同時(shí)進(jìn)行編譯: cat /proc/cpuinfo| grep "processor"| wc -l

# 將nginx命令添加環(huán)境變量
[root@lnmp-01 ~]# echo "export PATH=/data/apps/nginx/sbin:$PATH" >> /etc/profile.d/nginx.sh
[root@lnmp-01 ~]# source /etc/profile.d/nginx.sh

# nginx命令語法及參數(shù)
[root@lnmp-01 ~]# nginx -h
nginx version: nginx/1.18.0
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -T            : test configuration, dump it and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /data/apps/nginx/)
  -c filename   : set configuration file (default: conf/nginx.conf)
  -g directives : set global directives out of configuration file

# 測(cè)試啟動(dòng)nginx
[root@lnmp-01 ~]# nginx
[root@lnmp-01 ~]# netstat -ntupl | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      1098/nginx: master

# 訪問nginx測(cè)試頁面
[root@lnmp-01 ~]# curl 127.0.0.1
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>    
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>    # 安裝正常會(huì)顯示如下內(nèi)容
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a >nginx.org</a>.<br/>
Commercial support is available at
<a >nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

[root@lnmp-01 ~]# nginx -s stop

# 添加systemd管理
[root@lnmp-01 ~]# vim /usr/lib/systemd/system/nginx.service
# 添加以下內(nèi)容
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network-online.target remote-fs.target nss-lookup.target
Wants=network-online.target

[Service]
Type=forking
PIDFile=/data/apps/nginx/logs/nginx.pid    # 自定義項(xiàng)
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /data/apps/nginx/logs/nginx.pid    # 自定義項(xiàng)
ExecStartPre=/data/apps/nginx/sbin/nginx -t -c /data/apps/nginx/conf/nginx.conf    # 自定義項(xiàng)
ExecStart=/data/apps/nginx/sbin/nginx    # 自定義項(xiàng)
ExecReload=/data/apps/nginx/sbin/nginx -s reload    # 自定義項(xiàng)
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true

[Install]
WantedBy=multi-user.target

# 啟動(dòng)nginx
[root@lnmp-01 ~]# systemctl daemon-reload
[root@lnmp-01 ~]# systemctl start|stop|restart|reload nginx
[root@lnmp-01 ~]# netstat -nutpl | grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      9714/nginx: master
[root@lnmp-01 ~]# ps -ef |grep nginx
root       9714      1  0 11:46 ?        00:00:00 nginx: master process /data/apps/nginx/sbin/nginx
nginx      9715   9714  0 11:46 ?        00:00:00 nginx: worker process

# 設(shè)置開機(jī)自啟動(dòng)
[root@lnmp-01 ~]# systemctl enable nginx
[root@lnmp-01 ~]# systemctl list-unit-files | grep nginx
nginx.service                                 enabled

?(3) MySQL-5.7.30

【官方下載站點(diǎn):源碼/rpm包】【下載站點(diǎn):boost_1_59_0】【官方站點(diǎn):cmake選項(xiàng)參數(shù)

# 查看是否已安裝mariadb或mysql,有則卸載
[root@lnmp-01 ~]# yum list installed | egrep 'mariadb|mysql'
mariadb-libs.x86_64                  1:5.5.56-2.el7                    @anaconda
[root@lnmp-01 ~]# yum remove -y mariadb-libs.x86_64

# 安裝mysql編譯所需依賴
[root@lnmp-01 ~]# yum install -y cmake make gcc gcc-c++ bison ncurses ncurses-devel

# 若需下載其他版本,修改最后段版本號(hào)(30改為34)即可;推薦到官方站點(diǎn)下載
[root@lnmp-01 ~]# wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.30.tar.gz    # 地址1
[root@lnmp-01 ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.30.tar.gz  # 地址2
[root@lnmp-01 ~]# wget https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz
---------------------------------# 或下載帶boost的包 ----------------------------------------------------
[root@lnmp-01 ~]# wget https://cdn.mysql.com/archives/mysql-5.7/mysql-boost-5.7.30.tar.gz  # 地址1
[root@lnmp-01 ~]# wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.30.tar.gz  # 地址2
--------------------------------------------------------------------------------------------------------
[root@lnmp-01 ~]# tar -xf mysql-5.7.30.tar.gz
[root@lnmp-01 ~]# tar -xf boost_1_59_0.tar.gz
[root@lnmp-01 ~]# ls
boost_1_59_0  boost_1_59_0.tar.gz  mysql-5.7.30  mysql-5.7.30.tar.gz
[root@lnmp-01 ~]# cd mysql-5.7.30
# 選擇相應(yīng)的編譯參數(shù)【官方站點(diǎn):cmake選項(xiàng)參數(shù)】
[root@lnmp-01 mysql-5.7.30]# cmake --help
[root@lnmp-01 mysql-5.7.30]# cmake . 
-DCMAKE_INSTALL_PREFIX=/data/apps/mysql 
-DMYSQL_DATADIR=/data/apps/mysql/data_db 
-DSYSCONFDIR==/etc 
-DDEFAULT_CHARSET=utf8mb4 
-DWITH_SYSTEMD=bool 
-DENABLED_LOCAL_INFILE=bool 
-DWITH_BOOST=/root/boost_1_59_0 
-DWITH_EXTRA_CHARSETS=all

======= 等待幾分鐘完成編譯,末尾正常輸出以下內(nèi)容=========
......
-- INSTALL mysqlclient.pc lib/pkgconfig
-- Skipping deb packaging on unsupported platform .
-- CMAKE_BUILD_TYPE: RelWithDebInfo
-- COMPILE_DEFINITIONS: _GNU_SOURCE;_FILE_OFFSET_BITS=64;HAVE_CONFIG_H
-- CMAKE_C_FLAGS:  -Wall -Wextra -Wformat-security -Wvla -Wwrite-strings -Wdeclaration-after-statement
-- CMAKE_CXX_FLAGS:  -Wall -Wextra -Wformat-security -Wvla -Woverloaded-virtual -Wno-unused-parameter
-- CMAKE_C_LINK_FLAGS:
-- CMAKE_CXX_LINK_FLAGS:
-- CMAKE_C_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- CMAKE_CXX_FLAGS_RELWITHDEBINFO: -O3 -g -fabi-version=2 -fno-omit-frame-pointer -fno-strict-aliasing -DDBUG_OFF
-- Configuring done
-- Generating done
-- Build files have been written to: /root/mysql-5.7.30

參數(shù)說明:
  -DCMAKE_INSTALL_PREFIX:mysql安裝目錄
  -DMYSQL_DATADIR:數(shù)據(jù)存放目錄
  -DEFAULT_CHARSET:數(shù)據(jù)庫默認(rèn)字符編碼
  -DWITH_SYSTEMD:提供systemd腳本
  -DENABLED_LOCAL_INFILE:允許從本文件導(dǎo)入數(shù)據(jù)
  -DWITH_BOOST: boost源碼路徑
  -DWITH_EXTRA_CHARSETS:支持額外字符集

----------------------------------------------------------------------
# 若cmake出錯(cuò)了,需根據(jù)下面操作,然后再重新編譯安裝。
[root@wencheng mysql-5.7.30]# find / -iname CMakeCache.txt
[root@wencheng mysql-5.7.30]# make clean
[root@wencheng mysql-5.7.30]# rm -f CMakeCache.txt
----------------------------------------------------------------------

[root@lnmp-01 mysql-5.7.30]# make -j 4 && make install    # make -j 4 表示開4核同時(shí)進(jìn)行編譯: cat /proc/cpuinfo| grep "processor"| wc -l

[root@lnmp-01 ~]# /data/apps/mysql/bin/mysql -V
/data/apps/mysql/bin/mysql  Ver 14.14 Distrib 5.7.30, for Linux (x86_64) using  EditLine wrapper

# 添加環(huán)境變量
[root@lnmp-01 ~]# echo "PATH=/data/apps/mysql/bin:$PATH" >> /etc/profile.d/mysql.sh
[root@lnmp-01 ~]# source /etc/profile.d/mysql.sh

# 創(chuàng)建mysql用戶和目錄并設(shè)置權(quán)限
[root@lnmp-01 ~]# useradd -M -s /sbin/nologin mysql
[root@lnmp-01 ~]# mkdir -p /data/apps/mysql/{data_db,logs,tmp}
[root@lnmp-01 ~]# chown -R mysql:mysql /data/apps/mysql/{data_db,logs,tmp}

# 創(chuàng)建配置文件my.cnf
[root@lnmp-01 ~]# vim /etc/my.cnf
[client]
port = 3306
default-character-set = utf8mb4
socket = /data/apps/mysql/tmp/mysql.sock

[mysql]
port = 3306
default-character-set = utf8mb4
socket = /data/apps/mysql/tmp/mysql.sock

[mysqld]
port = 3306
server-id = 1
user = mysql
basedir = /data/apps/mysql
datadir = /data/apps/mysql/data_db
character_set_server = utf8mb4
collation-server = utf8mb4_general_ci
socket = /data/apps/mysql/tmp/mysql.sock

log-error = /data/apps/mysql/logs/mysql-error.log
pid-file = /data/apps/mysql/tmp/mysqld.pid

# 執(zhí)行初始化
[root@lnmp-01 ~]# /data/apps/mysql/bin/mysqld --initialize-insecure --basedir=/data/apps/mysql --datadir=/data/apps/mysql/data_db --user=mysql   #(5.7以上版本)
--------- 正常輸出以下信息 -----------
2021-06-22T11:38:05.991267Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-06-22T11:38:06.327772Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-06-22T11:38:06.367358Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-06-22T11:38:06.424912Z 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: 4fc67845-d34e-11eb-9ce0-000c29ceb2c0.
2021-06-22T11:38:06.426105Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-06-22T11:38:06.590676Z 0 [Warning] CA certificate ca.pem is self signed.
2021-06-22T11:38:06.643809Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

# 添加systemd管理
[root@lnmp-01 ~]# cp /data/apps/mysql/usr/lib/systemd/system/mysqld.service /usr/lib/systemd/system/
[root@lnmp-01 ~]# grep -Ev '^$|#' /usr/lib/systemd/system/mysqld.service
[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target
[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
Type=forking
PIDFile=/data/apps/mysql/tmp/mysqld.pid    # 自定義項(xiàng)
TimeoutSec=0
PermissionsStartOnly=true
ExecStartPre=/data/apps/mysql/bin/mysqld_pre_systemd
ExecStart=/data/apps/mysql/bin/mysqld --daemonize --pid-file=/data/apps/mysql/tmp/mysqld.pid $MYSQLD_OPTS   # 自定義項(xiàng)
EnvironmentFile=-/etc/sysconfig/mysql
LimitNOFILE = 5000
Restart=on-failure
RestartPreventExitStatus=1
PrivateTmp=false

# 啟動(dòng)mysql
[root@lnmp-01 ~]# systemctl daemon-reload
[root@lnmp-01 ~]# systemctl start|stop|restart|reload mysqld
[root@lnmp-01 ~]# netstat -nutpl | grep mysql
tcp6       0      0 :::3306                 :::*                    LISTEN      30472/mysqld
[root@lnmp-01 ~]# ps -ef |grep mysql
mysql     30472      1  0 12:33 ?        00:00:00 /data/apps/mysql/bin/mysqld --daemonize --pid-file=/data/apps/mysql/tmp/mysqld.pid

# 登錄mysql
[root@lnmp-01 ~]# mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 3
Server version: 5.7.30 Source distribution

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

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

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

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

# 設(shè)置開機(jī)自啟動(dòng)
[root@lnmp-01 ~]# systemctl enable mysqld
[root@lnmp-01 ~]# systemctl list-unit-files | grep mysql
mysqld.service                                enabled

?(4) PHP-7.4.14

【官方下載站點(diǎn):源碼包】【官方站點(diǎn):comfigure選項(xiàng)參數(shù)

# 查看是否已安裝php,有則卸載
[root@lnmp-01 ~]# yum list installed | grep php

# 安裝mysql編譯所需依賴
[root@lnmp-01 ~]# yum install -y epel-release
[root@lnmp-01 ~]# yum install -y bzip2 bzip2-devel libmcrypt-devel openssl-devel libxml2-devel sqlite-devel libcurl-devel libpng-devel libjpeg libjpeg-devel oniguruma oniguruma-devel

# 下載指定版本
[root@lnmp-01 ~]# wget https://www.php.net/distributions/php-7.4.14.tar.gz
[root@lnmp-01 ~]# tar -xf php-7.4.14.tar.gz
[root@lnmp-01 ~]# cd php-7.4.14

# 選擇相應(yīng)的編譯參數(shù)【官方站點(diǎn):cmake選項(xiàng)參數(shù)】
[root@lnmp-01 php-7.4.14]# ./configure --help
[root@lnmp-01 php-7.4.14]# ./configure --prefix=/data/apps/php 
--with-config-file-path=/etc 
--with-fpm-user=www 
--with-fpm-group=www 
--enable-fpm 
--with-openssl 
--enable-mbstring 
--enable-sockets 
--with-freetype-dir 
--with-jpeg-dir 
--with-png-dir 
--with-libxml-dir=/usr 
--enable-xml 
--with-zlib 
--with-mcrypt 
--with-bz2 
--with-mhash

======= 等待幾分鐘完成編譯,末尾正常輸出以下內(nèi)容=========
+--------------------------------------------------------------------+
| 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.

參數(shù)說明:
--prefix:安裝目錄
  --with-config-file-path:配置文件位置
  --with-fpm-user:進(jìn)程管理器進(jìn)程守護(hù)者
  --with-fpm-group:進(jìn)程管理器進(jìn)程守護(hù)者的用戶組
  --enable-fpm:進(jìn)程管理器
 ......
--------------------------------------------------
# 若configure出錯(cuò)了,需清除原編譯,然后再重新編譯安裝。
[root@lnmp-01 php-7.4.14]# make clean
--------------------------------------------------

[root@lnmp-01 php-7.4.14]# make -j 4 && make install    # make -j 4 表示開4核同時(shí)進(jìn)行編譯: cat /proc/cpuinfo| grep "processor"| wc -l

[root@lnmp-01 ~]# /data/apps/php/bin/php -v
PHP 7.4.14 (cli) (built: Sep  8 2021 09:41:51) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologi

# 添加環(huán)境變量
[root@lnmp-01 ~]# echo "PATH=/data/apps/php/bin:$PATH" >> /etc/profile.d/php.sh
[root@lnmp-01 ~]# echo "PATH=/data/apps/php/sbin:$PATH" >> /etc/profile.d/php.sh
[root@lnmp-01 ~]# source /etc/profile.d/php.sh
-----------------------------------------------------------------
# 或可創(chuàng)建軟連接
[root@lnmp-01 ~]# ln -s /data/apps/php/bin/php /usr/local/bin/php
[root@lnmp-01 ~]# ln -s /data/apps/php/sbin/php-fpm /usr/local/bin/php-fpm

# 創(chuàng)建php用戶并設(shè)置目錄權(quán)限
[root@lnmp-01 ~]# useradd -M -s /sbin/nologin www
[root@lnmp-01 ~]# chown -R www:www /data/apps/php

# 生成php服務(wù)腳本
[root@lnmp-01 ~]# cp ~/php-7.4.14/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpmd
[root@lnmp-01 ~]# chmod +x /etc/init.d/php-fpmd

# 設(shè)置php-fpm配置文件
[root@lnmp-01 ~]# cp /data/apps/php/etc/php-fpm.conf.default /data/apps/php/etc/php-fpm.conf
[root@lnmp-01 ~]# cp /data/apps/php/etc/php-fpm.d/www.conf.default /data/apps/php/etc/php-fpm.d/www.conf

# 測(cè)試php配置文件語法是否正確
[root@lnmp-01 ~]# php-fpm -t
[08-Sep-2021 10:45:52] NOTICE: configuration file /data/apps/php/etc/php-fpm.conf test is successful

# 啟動(dòng)php
[root@lnmp-01 ~]# /etc/init.d/php-fpmd start|stop|force-quit|restart|reload|status|configtest
[root@lnmp-01 ~]# netstat -nuptl | grep php
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      63705/php-fpm: mast
[root@lnmp-01 ~]# ps -ef | grep php
root      63705      1  0 10:49 ?        00:00:00 php-fpm: master process (/data/apps/php/etc/php-fpm.conf)
www       63706  63705  0 10:49 ?        00:00:00 php-fpm: pool www
www       63707  63705  0 10:49 ?        00:00:00 php-fpm: pool www

# 添加systemd管理
[root@lnmp-01 ~]# vim /usr/lib/systemd/system/php-fpm.service
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/data/apps/php/var/run/php-fpm.pid  # 自定義項(xiàng)
ExecStart=/data/apps/php/sbin/php-fpm --nodaemonize --fpm-config /data/apps/php/etc/php-fpm.conf  # 自定義項(xiàng)
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

# 設(shè)置開機(jī)自啟動(dòng)
[root@lnmp-01 ~]# systemctl enable php-fpm
[root@lnmp-01 ~]# systemctl list-unit-files | grep php
php-fpm.service                               enable

至此,手動(dòng)編譯部署LNMP環(huán)境(CentOS7.5+Nginx-1.18.0+MySQL-5.7.30+PHP-7.4.14)已完成。

 :YUM安裝php【下載rpm包

[root@lnmp-01 ~]# yum install epel-release
[root@lnmp-01 ~]# rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
# 查看php所有版本
[root@lnmp-01 ~]# ls /etc/yum.repos.d/*php*
/etc/yum.repos.d/remi-php54.repo  /etc/yum.repos.d/remi-php72.repo  /etc/yum.repos.d/remi-php80.repo
/etc/yum.repos.d/remi-php70.repo  /etc/yum.repos.d/remi-php73.repo  /etc/yum.repos.d/remi-php81.repo
/etc/yum.repos.d/remi-php71.repo  /etc/yum.repos.d/remi-php74.repo
# 選擇適合的版本,這里選擇php74
[root@lnmp-01 ~]# yum --enablerepo=remi install -y php74-php
[root@lnmp-01 ~]# yum --enablerepo=remi install php74-php php74-php-gd php74-php-xml php74-php-sockets php74-php-session php74-php-snmp php74-php-mysql
[root@lnmp-01 ~]# php74 -v
PHP 7.4.23 (cli) (built: Aug 24 2021 16:33:30) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

?

本文摘自 :https://www.cnblogs.com/

開通會(huì)員,享受整站包年服務(wù)立即開通 >