lamp.

lamp

lamp简介

所谓lamp,其实就是由Linux+Apache+Mysql/MariaDB+Php/Perl/Python的一组动态网站或者服务器的开源软件,除Linux外其它各部件本身都是各自独立的程序,但是因为经常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。

LAMP指的是Linux(操作系统)、Apache(HTTP服务器)、MySQL(也指MariaDB,数据库软件)和PHP(有时也是指Perl或Python)的第一个字母,一般用来建立web应用平台。

web服务器工作流程

web服务器的资源分为两种,静态资源和动态资源

  • 静态资源就是指静态内容,客户端从服务器获得的资源的表现形式与原文件相同。可以简单的理解为就是直接存储于文件系统中的资源
  • 动态资源则通常是程序文件,需要在服务器执行之后,将执行的结果返回给客户端

那么web服务器如何执行程序并将结果返回给客户端呢?下面通过一张图来说明一下web服务器如何处理客户端的请求
在这里插入图片描述
如上图所示

阶段①显示的是httpd服务器(即apache)和php服务器通过FastCGI协议进行通信,且php作为独立的服务进程运行

阶段②显示的是php程序和mysql数据库间通过mysql协议进行通信。php与mysql本没有什么联系,但是由Php语言写成的程序可以与mysql进行数据交互。同理perl和python写的程序也可以与mysql数据库进行交互

cgi与fastcgi

上图阶段①中提到了FastCGI,下面我们来了解下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上下文切换而导致耗时

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方式来加载动态资源

web工作流程
  • 客户端通过http协议请求web服务器资源
  • web服务器收到请求后判断客户端请求的资源是静态资源或是动态资源
    • 若是静态资源则直接从本地文件系统取之返回给客户端。
    • 否则若为动态资源则通过FastCGI协议与php服务器联系,通过CGI程序的master进程调度worker进程来执行程序以获得客户端请求的动态资源,并将执行的结果通过FastCGI协议返回给httpd服务器,httpd服务器收到php的执行结果后将其封装为http响应报文响应给客户端。在执行程序获取动态资源时若需要获得数据库中的资源时,由Php服务器通过mysql协议与MySQL/MariaDB服务器交互,取之而后返回给httpd,httpd将从php服务器收到的执行结果封装成http响应报文响应给客户端。

lamp平台构建

环境说明:

系统平台IP需要安装的服务
centos7 redhat7172.16.12.128httpd-2.4 mysql-5.7 php php-mysql

lamp平台软件安装次序:

    httpd --> mysql --> php

注意:php要求httpd使用prefork MPM

安装httpd
[root@localhost ~]# systemctl status firewalld.service //关闭防火墙
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Wed 2022-08-03 08:46:59 CST; 19s ago
     Docs: man:firewalld(1)
  Process: 980 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCC>
 Main PID: 980 (code=exited, status=0/SUCCESS)

Aug 03 08:45:18 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon...
Aug 03 08:45:18 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon.
Aug 03 08:45:19 localhost.localdomain firewalld[980]: WARNING: AllowZoneDrifting is enabled. This is cons>
Aug 03 08:46:58 localhost.localdomain systemd[1]: Stopping firewalld - dynamic firewall daemon...
Aug 03 08:46:59 localhost.localdomain systemd[1]: firewalld.service: Succeeded.
Aug 03 08:46:59 localhost.localdomain systemd[1]: Stopped firewalld - dynamic firewall daemon.
[root@localhost ~]# getenforce //关闭selinux
Disabled
//配置yum源
[root@localhost ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@localhost ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@localhost ~]# dnf -y install epel-release
Repository extras is listed more than once in the configuration
CentOS-8.5.2111 - Base - mirrors.aliyun.com                               281 kB/s | 4.6 MB     00:16    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com                              29 kB/s |  10 kB     00:00    

//创建apache服务用户与组
[root@localhost ~]# useradd -Mrs /sbin/nologin apache
[root@localhost ~]# id apache
uid=995(apache) gid=992(apache) groups=992(apache)
//安装开发工具包依赖包
[root@localhost ~]# dnf -y install epel-release
Repository extras is listed more than once in the configuration
CentOS-8.5.2111 - Base - mirrors.aliyun.com                               281 kB/s | 4.6 MB     00:16    
CentOS-8.5.2111 - Extras - mirrors.aliyun.com                              29 kB/s |  10 kB     00:00    
CentOS-8.5.2111 - AppStream - mirrors.aliyun.com                          190 kB/s | 8.4 MB     00:45    
CentOS Stream 8 - AppStream                                               6.2 kB/s | 4.4 kB     00:00    
CentOS Stream 8 - AppStream                                               8.8 MB/s |  24 MB     00:02    
CentOS Stream 8 - BaseOS                                                  5.6 kB/s | 3.9 kB     00:00    
CentOS Stream 8 - BaseOS                                                   20 MB/s |  25 MB     00:01    
Dependencies resolved.
==========================================================================================================
 Package                         Architecture         Version                  Repository            Size
==========================================================================================================
Installing:
 epel-release                    noarch               8-11.el8                 extras                24 k
Installing weak dependencies:
 epel-next-release               noarch               8-11.el8                 extr
 [root@localhost ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++
Repository extras is listed more than once in the configuration
Last metadata expiration check: 0:00:24 ago on Wed 03 Aug 2022 08:51:18 AM CST.
Dependencies resolved.
==========================================================================================================
 Package                     Arch        Version                                     Repository      Size
==========================================================================================================
Installing:
 expat-devel                 x86_64      2.2.5-9.el8                                 baseos          57 k
 gcc                         x86_64      8.5.0-15.el8                                appstream       23 M
 gcc-c++                     x86_64      8.5.0-15.el8                                appstream       12 M
 libtool                     x86_64      2.4.6-25.el8                                AppStream      709 k
 openssl-devel               x86_64      1:1.1.1k-6.el8                              baseos         2.3 M
 pcre-devel                  x86_64      8.42-6.el8                                  base           551 k
Upgrading:
 expat                       x86_64      2.2.5-9.el8                                 baseos         113 k
 libgcc                      x86_64      8.5.0-15.el8                                baseos          81 k
 libgomp                     x86_64      8.5.0-15.el8                                baseos         207 k
 libstdc++                   x86_64      8.5.0-15.el8                                baseos         454 k
 openssl                     x86_64      1:1.1.1k-6.el8                              baseos         709 k
 openssl-libs                x86_64      1:1.1.1k-6.el8                              baseos         1.5 M
Installing dependencies:
 autoconf                    noarch      2.69-29.el8                                 AppStream      710 k
 automake                    noarch      1.16.1-7.el8                                AppStream      713 k
 binutils                    x86_64      2.30-117.el8                                baseos         5.8 M
 cpp                         x86_64      8.5.0-15.el8                                appstream       10 M
//下载安装apr和apr-util以及httpd
[root@localhost ~]# wget https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz
--2022-08-03 08:56:25--  https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 43.224.184.227, 45.253.17.226, 43.224.184.229, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|43.224.184.227|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1093896 (1.0M) [application/octet-stream]
Saving to: ‘apr-1.7.0.tar.gz’

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

2022-08-03 08:56:34 (136 KB/s) - ‘apr-1.7.0.tar.gz’ saved [1093896/1093896]

[root@localhost ~]# wget https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz
--2022-08-03 08:57:02--  https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 43.224.184.225, 45.253.17.226, 45.253.17.216, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|43.224.184.225|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 554301 (541K) [application/octet-stream]
Saving to: ‘apr-util-1.6.1.tar.gz’

apr-util-1.6.1.tar.gz      100%[======================================>] 541.31K   136KB/s    in 4.0s    

2022-08-03 08:57:09 (135 KB/s) - ‘apr-util-1.6.1.tar.gz’ saved [554301/554301]
[root@localhost ~]# wget https://mirrors.aliyun.com/apache/httpd/httpd-2.4.54.tar.gz
--2022-08-03 08:57:23--  https://mirrors.aliyun.com/apache/httpd/httpd-2.4.54.tar.gz
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 45.253.17.213, 45.253.17.214, 45.253.17.217, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|45.253.17.213|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 9743277 (9.3M) [application/octet-stream]
Saving to: ‘httpd-2.4.54.tar.gz’

httpd-2.4.54.tar.gz        100%[======================================>]   9.29M   135KB/s    in 71s     

2022-08-03 08:58:35 (133 KB/s) - ‘httpd-2.4.54.tar.gz’ saved [9743277/9743277]
//源码包移至/usr/local/src位置下解压
[root@localhost ~]# mv apr* /usr/local/src/
[root@localhost ~]# mv httpd-2.4.54.tar.gz /usr/local/src/
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# tar -xf apr-1.7.0.tar.gz
[root@localhost src]# tar -xf apr-util-1.6.1.tar.gz
[root@localhost src]# tar -xf httpd-2.4.54.tar.gz
//编译安装apr和apr-util
[root@localhost src]# cd apr-1.7.0/
[root@localhost apr-1.7.0]# vi configure
#    $RM "$cfgfile"  //给此行加上注释

[root@localhost apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.7.0]# make && make install
[root@localhost apr-1.7.0]# cd /usr/local/src/apr-util-1.6.1/
[root@localhost 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
checking for a BSD-compatible install... /usr/bin/install -c
checking for working mkdir -p... yes
APR-util Version: 1.6.1
checking for chosen layout... apr-util
checking for gcc... gcc
[root@localhost apr-util-1.6.1]# make && make install
//编译安装httpd
[root@localhost apr-util-1.6.1]# cd /usr/local/src/httpd-2.4.54
[root@localhost httpd-2.4.54]# ./configure --prefix=/usr/local/apache --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
/126130746checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
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
configure: 
configure: Configuring Apache Portable Runtime library...
[root@localhost httpd-2.4.54]# make && make install

//安装后配置。映射头文件,库文件,man手册文件
[root@localhost ~]# echo 'export PATH=$PATH:/usr/local/apache/bin/' > /etc/profile.d/httpd.sh
[root@localhost ~]# source /etc/profile.d/httpd.sh
[root@localhost ~]# ln -s /usr/local/apache/include/ /usr/include/httpd
[root@localhost ~]# echo 'MANPATH /usr/local/apache/man' >> /etc/man.config

//取消ServerName前面的注释
[root@localhost ~]# sed -i '/#ServerName/s/#//g' /usr/local/apache/conf/httpd.conf

//配置httpd开机自启的脚本
[root@localhost ~]# vim /usr/lib/systemd/system/httpd.service
[root@localhost ~]# cat /usr/lib/systemd/system/httpd.service
[Unit]
Description=httpd server daemon
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

[root@localhost system]# systemctl daemon-reload			//重载生效配置
[root@localhost system]# systemctl restart httpd.service	//开启httpd服务
[root@localhost system]# systemctl enable httpd.service	//httpd设为开机自启
//查看httpd服务的默认端口80是否开启
[root@localhost system]# ss -anlt
State       Recv-Q       Send-Q             Local Address:Port             Peer Address:Port      Process
LISTEN      0            128                      0.0.0.0:22                    0.0.0.0:*
LISTEN      0            128                            *:80                          *:*
LISTEN      0            128                         [::]:22          


安装mysql

//安装依赖包
[root@localhost ~]# dnf -y install ncurses-devel openssl-devel openssl cmake mariadb-devel

//创建mysql服务的用户与组
[root@localhost ~]# useradd -Mrs /sbin/nologin mysql
[root@localhost ~]# id mysql
uid=994(mysql) gid=991(mysql) groups=991(mysql)

//下载mysql二进制包,解压该包
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
[root@localhost src]# tar -xf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost src]# cd /usr/local/
[root@localhost local]# mv mysql-5.7.38-linux-glibc2.12-x86_64/ mysql

//修改目录的属主属组为mysql
[root@localhost local]# chown -R mysql.mysql /usr/local/mysql
[root@localhost local]# ll -d mysql/
drwxr-xr-x 9 mysql mysql 129 Aug  2 18:48 mysql/

//添加环境变量,映射头文件、库文件、man手册
[root@localhost mysql]# echo 'export PATH=$PATH:/usr/local/mysql/bin' > /etc/profile.d/mysql.sh
[root@localhost mysql]# source /etc/profile.d/mysql.sh
[root@localhost mysql]# ln -s /usr/local/mysql/include/ /usr/local/include/mysql
[root@localhost mysql]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@localhost mysql]# ldconfig
[root@localhost mysql]# echo 'MANPATH /usr/local/mysql/man' >> /etc/man.config

//创建数据存放目录,并修改属主属组为mysql
[root@localhost mysql]# mkdir /opt/data
[root@localhost mysql]# chown -R mysql.mysql /opt/data/
[root@localhost mysql]# ll -d /opt/data/
drwxr-xr-x 2 mysql mysql 6 Aug  2 18:54 /opt/data/

//初始化数据库
[root@localhost mysql]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
2022-08-02T10:54:50.460373Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-08-02T10:54:50.625962Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-08-02T10:54:50.654697Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-08-02T10:54:50.711891Z 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: 885298ff-1251-11ed-85c7-000c299ee3c1.
2022-08-02T10:54:50.713328Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-08-02T10:54:50.815484Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-08-02T10:54:50.815524Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-08-02T10:54:50.815955Z 0 [Warning] CA certificate ca.pem is self signed.
2022-08-02T10:54:50.888670Z 1 [Note] A temporary password is generated for root@localhost: H6e9f,Jt3<me
//把初始化后的临时密码保存,后面登录要用到
[root@localhost mysql]# echo 'H6e9f,Jt3<me' > /root/mysql.passwd

//添加配置文件
[root@localhost mysql]# vim /etc/my.cnf
[root@localhost mysql]# 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

//配置服务启动脚本
[root@localhost mysql]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost mysql]# sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g' /etc/init.d/mysqld
[root@localhost mysql]# sed -ri 's#^(datadir=).*#\1/opt/data#g' /etc/init.d/mysqld

//启动mysql
[root@localhost mysql]# ss -anlt
State       Recv-Q       Send-Q             Local Address:Port             Peer Address:Port      Process
LISTEN      0            128                      0.0.0.0:22                    0.0.0.0:*
LISTEN      0            80                             *:3306                        *:*
LISTEN      0            128                         [::]:22                       [::]:*

//修改数据库密码
[root@localhost mysql]# mysql -uroot -p'H6e9f,Jt3<me'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.38

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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

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

mysql> set password = password('123456');
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye
//测试新密码是否能登录
[root@localhost mysql]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.38 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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

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

mysql> exit
Bye
[root@localhost mysql]#

安装php
//从php官网下载php7的源码包,下载后校验一下该包是否完整
[root@localhost ~]# wget https://www.php.net/distributions/php-7.4.30.tar.gz
[root@localhost ~]# sha256sum php-7.4.30.tar.gz
e37ea37e0f79109351ac615da85eb7c2c336101fc5bc802ee79a124a4310dc10  php-7.4.30.tar.gz
//把上面这一大串值跟php官网的值做对比

//安装依赖包
[root@localhost ~]# 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
.............下载安装过程略................

//解压源码包
[root@localhost ~]# mv php-7.4.30.tar.gz /usr/local/src/
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# tar -xf php-7.4.30.tar.gz

//编译安装php
[root@localhost php-7.4.30]# ./configure --prefix=/usr/local/php7  --with-config-file-path=/etc --enable-fpm --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-soap --with-openssl --enable-bcmath --with-iconv --with-bz2 --enable-calendar --with-curl --enable-exif  --enable-ftp --enable-gd --with-jpeg --with-zlib-dir --with-freetype --with-gettext --enable-json --enable-mbstring --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-readline --enable-shmop --enable-simplexml --enable-sockets --with-zip --enable-mysqlnd-compression-support --with-pear --enable-pcntl --enable-posix
..........编译过程略............
[root@localhost php-7.4.30]# make -j $(cat /proc/cpuinfo |grep processor|wc -l)	 //此方式编译速度会加快
.............编译过程略...........
[root@localhost php-7.4.30]# make install
..............安装过程略...........

//配置环境变量
[root@localhost ~]# echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php7.sh
[root@localhost ~]# source /etc/profile.d/php7.sh
[root@localhost ~]# which php		//验证php的环境变量是否配置成功
/usr/local/php7/bin/php
[root@localhost ~]# php -v			//查看php的版本信息
PHP 7.4.30 (cli) (built: Aug  2 2022 19:38:49) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

//配置php-fpm
[root@localhost ~]# cd /usr/local/src/php-7.4.30/
[root@localhost php-7.4.30]# cp php.ini-production /etc/php.ini
[root@localhost php-7.4.30]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-7.4.30]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost php-7.4.30]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
[root@localhost php-7.4.30]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf

//启动php
[root@localhost php-fpm.d]# service php-fpm start
Starting php-fpm  done
[root@localhost php-fpm.d]# service php-fpm status
php-fpm (pid 209351) is running...
[root@localhost php-fpm.d]# 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                    127.0.0.1:9000                  0.0.0.0:*
LISTEN      0            80                             *:3306                        *:*
LISTEN      0            128                            *:80                          *:*
LISTEN      0            128                         [::]:22                       [::]:*

安装phpmyadmin
//下载phpmyadmin包
[root@localhost ~]# wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.zip
//把该解压在网站的根目录
[root@localhost ~]# mv phpMyAdmin-5.2.0-all-languages.zip /usr/local/apache/htdocs/yf/
[root@localhost ~]# cd /usr/local/apache/htdocs/ray/
[root@localhost ray]# unzip phpMyAdmin-5.2.0-all-languages.zip
//把目录的名字改为phpmyadmin
[root@localhost ray]# mv phpMyAdmin-5.2.0-all-languages/ phpmyadmin
[root@localhost ray]# cd phpmyadmin/
//复制样本配置文件到config.inc.php文件
[root@localhost phpmyadmin]# cp config.sample.inc.php config.inc.php
[root@localhost phpmyadmin]# systemctl restart httpd.service


在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值