目录
lamp简介
所谓lamp,其实就是由Linux+Apache+Mysql/MariaDB+Php/Perl/Python的一组动态网站或者服务器的开源软件,除Linux外其它各部件本身都是各自独立的程序,但是因为经常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web应用程序平台。
LAMP指的是Linux(操作系统)、Apache(HTTP服务器)、MySQL(也指MariaDB,数据库软件)和PHP(有时也是指Perl或Python)的第一个字母,一般用来建立web应用平台。
web服务器工作流程
web服务器的资源分为两种,静态资源和动态资源
静态资源就是指静态内容,客户端从服务器获得的资源的表现形式与原文件相同。可以简单的理解为就是直接存储于文件系统中的资源
动态资源则通常是程序文件,需要在服务器执行之后,将执行的结果返回给客户端
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方式来加载动态资源
lamp平台构建
lamp平台软件安装次序:
httpd --> mysql --> php
注意:php要求httpd使用prefork MPM
安装httpd
[root@zzh ~]# cd /etc/yum.repos.d/
[root@zzh yum.repos.d]# ls
CentOS-Stream-AppStream.repo CentOS-Stream-Debuginfo.repo CentOS-Stream-HighAvailability.repo CentOS-Stream-PowerTools.repo
CentOS-Stream-BaseOS.repo CentOS-Stream-Extras.repo CentOS-Stream-Media.repo CentOS-Stream-RealTime.repo
[root@zzh yum.repos.d]# rm -rf *
[root@zzh yum.repos.d]# ls
[root@zzh 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 10942 0 --:--:-- --:--:-- --:--:-- 10942
[root@zzh yum.repos.d]# ls
CentOS-Base.repo
[root@zzh yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@zzh yum.repos.d]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm //下载新repo 到/etc/yum.repos.d/
Failed to set locale, defaulting to C.UTF-8
CentOS-8.5.2111 - Base - mirrors.aliyun.com 288 kB/s | 4.6 MB 00:16
CentOS-8.5.2111 - Extras - mirrors.aliyun.com 34 kB/s | 10 kB 00:00
Installed:
epel-release-8-16.el8.noarch
Complete!
[root@zzh yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@zzh yum.repos.d]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
[root@zzh yum.repos.d]# ls
CentOS-Base.repo epel-modular.repo epel-testing-modular.repo epel-testing.repo epel.repo
[root@zzh yum.repos.d]# dnf clean all //清理缓存
Failed to set locale, defaulting to C.UTF-8
37 files removed
[root@zzh yum.repos.d]# dnf makecache
Failed to set locale, defaulting to C.UTF-8
CentOS-8.5.2111 - Base - mirrors.aliyun.com 290 kB/s | 4.6 MB 00:16
CentOS-8.5.2111 - Extras - mirrors.aliyun.com 61 kB/s | 10 kB 00:00
Module yaml error: Unexpected key in data: static_context [line 9 col 3]
Metadata cache created.
[root@zzh ~]# yum groups mark install 'Development Tools' //安装开发工具包
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:04:09 ago on Tue Aug 2 20:18:29 2022.
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!
[root@zzh ~]# useradd -r -M -s /sbin/nologin apache //创建apache服务的用户和组
[root@zzh ~]# dnf -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make vim wget //安装依赖包
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:05:22 ago on Tue Aug 2 20:18:29 2022.
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:
expat-devel x86_64 2.2.5-4.el8 base 55 k
Complete!
[root@zzh ~]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
--2022-08-02 20:29:39-- https://downloads.apache.org/apr/apr-1.7.0.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: 1093896 (1.0M) [application/x-gzip]
Saving to: 'apr-1.7.0.tar.gz'
apr-1.7.0.tar.gz 100%[=======================================================================================================>] 1.04M 544KB/s in 2.0s
2022-08-02 20:29:43 (544 KB/s) - 'apr-1.7.0.tar.gz' saved [1093896/1093896]
--2022-08-02 20:29:43-- https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz
Reusing existing connection to downloads.apache.org:443.
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 1.93MB/s in 0.3s
2022-08-02 20:29:43 (1.93 MB/s) - 'apr-util-1.6.1.tar.gz' saved [554301/554301]
FINISHED --2022-08-02 20:29:43--
Total wall clock time: 3.9s
Downloaded: 2 files, 1.6M in 2.2s (719 KB/s)
[root@zzh ~]# ls
anaconda-ks.cfg apr-1.7.0.tar.gz apr-util-1.6.1.tar.gz
[root@zzh ~]# tar xf apr-1.7.0.tar.gz
[root@zzh ~]# tar xf apr-util-1.6.1.tar.gz
[root@zzh ~]# 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
[root@zzh ~]# cd apr-1.7.0
[root@zzh apr-1.7.0]# ls
CHANGES Makefile.win README.cmake apr.dsw atomic buildconf docs file_io libapr.dsp memory passwd strings threadproc
CMakeLists.txt NOTICE apr-config.in apr.mak build config.layout dso helpers libapr.mak misc poll support time
LICENSE NWGNUmakefile apr.dep apr.pc.in build-outputs.mk configure emacs-mode include libapr.rc mmap random tables tools
Makefile.in README apr.dsp apr.spec build.conf configure.in encoding libapr.dep locks network_io shmem test user
[root@zzh apr-1.7.0]# vim configure
31880 # $RM "$cfgfile" //将此行加上注释或者删除
[root@zzh apr-1.7.0]# ./configure --prefix=/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
Configuring APR library
Platform: x86_64-pc-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.7.0
checking for chosen layout... apr
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
[root@zzh apr-1.7.0]# make && make install
make[1]: Entering directory '/root/apr-1.7.0'
/bin/sh /root/apr-1.7.0/libtool --silent --mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I./include -I/root/apr-1.7.0/include/arch/unix -I./include/arch/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 -o encoding/apr_encode.lo -c encoding/apr_encode.c && touch encoding/apr_encode.lo
[root@zzh apr-1.7.0]# cd ../apr-util-1.6.1
[root@zzh apr-util-1.6.1]# ls
CHANGES Makefile.win README.FREETDS aprutil.dep apu-config.in build.conf configure.in docs include libaprutil.mak redis uri
CMakeLists.txt NOTICE README.cmake aprutil.dsp buckets buildconf crypto encoding ldap libaprutil.rc renames_pending xlate
LICENSE NWGNUmakefile apr-util.pc.in aprutil.dsw build config.layout dbd export_vars.sh.in libaprutil.dep memcache strmatch xml
Makefile.in README apr-util.spec aprutil.mak build-outputs.mk configure dbm hooks libaprutil.dsp misc test
[root@zzh 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
[root@zzh apr-util-1.6.1]# make && make install
make[1]: Entering directory '/root/apr-util-1.6.1'
/bin/sh /usr/local/apr/build-1/libtool --silent --mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX -D_REENTRANT -D_GNU_SOURCE -I/root/apr-util-1.6.1/include -I/root/apr-util-1.6.1/include/private -I/usr/local/apr/include/apr-1 -o buckets/apr_brigade.lo -c buckets/apr_brigade.c && touch buckets/apr_brigade.lo
[root@zzh ~]# wget https://downloads.apache.org/httpd/httpd-2.4.54.tar.gz //编译安装httpd
--2022-08-02 20:42:11-- 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... failed: Connection refused.
Connecting to downloads.apache.org (downloads.apache.org)|135.181.214.104|: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 67.0KB/s in 74s
2022-08-02 20:43:47 (128 KB/s) - 'httpd-2.4.54.tar.gz' saved [9743277/9743277]
[root@zzh ~]# 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@zzh ~]# tar xf httpd-2.4.54.tar.gz
[root@zzh ~]# cd httpd-2.4.54
[root@zzh 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
checking 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
[root@zzh httpd-2.4.54]# make && make install
Making all in srclib
make[1]: Entering directory '/root/httpd-2.4.54/srclib'
make[1]: Leaving directory '/root/httpd-2.4.54/srclib'
Making all in os
make[1]: Entering directory '/root/httpd-2.4.54/os'
Making all in unix
make[2]: Entering directory '/root/httpd-2.4.54/os/unix'
[root@zzh ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh //安装后配置
[root@zzh ~]# ls /usr/local/
apache apr apr-util bin etc games include lib lib64 libexec sbin share src
[root@zzh ~]# source /etc/profile.d/httpd.sh
[root@zzh ~]# which httpd
/usr/local/apache/bin/httpd
[root@zzh ~]# ls /usr/local/apache/
bin build cgi-bin conf error htdocs icons include logs man manual modules
[root@zzh ~]# ln -s /usr/local/apache/include /usr/include/apache
[root@zzh ~]# 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 //添加此行
//写service文件方式启动apache
[root@zzh ~]# cd /usr/lib/systemd/system
[root@zzh system]# cp sshd.service httpd.service
[root@zzh 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@zzh system]# cd
[root@zzh ~]# systemctl daemon-reload //重新加载
[root@zzh ~]# 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@zzh ~]# systemctl start httpd
[root@zzh ~]# 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@zzh ~]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@zzh ~]# 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:55:26 EDT; 20s ago
Docs: man:httpd(5)
Main PID: 124025 (httpd)
Tasks: 6 (limit: 54222)
Memory: 5.6M
CGroup: /system.slice/httpd.service
├─124025 /usr/local/apache/bin/httpd -k start
├─124026 /usr/local/apache/bin/httpd -k start
├─124027 /usr/local/apache/bin/httpd -k start
├─124028 /usr/local/apache/bin/httpd -k start
├─124029 /usr/local/apache/bin/httpd -k start
└─124030 /usr/local/apache/bin/httpd -k start
Aug 02 20:55:26 zzh systemd[1]: Starting web server daemon...
Aug 02 20:55:26 zzh apachectl[124022]: AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::e2c4:3bc8:ed3a:ecac%ens33. Set the 'ServerName' direct>
Aug 02 20:55:26 zzh systemd[1]: Started web server daemon.
安装mysql
[root@zzh ~]# cd /usr/src/
[root@zzh src]# dnf -y install ncurses-devel openssl-devel openssl cmake mariadb-devel //安装依赖包
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:39:27 ago on Tue Aug 2 20:18:29 2022.
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]
Package openssl-devel-1:1.1.1k-5.el8_5.x86_64 is already installed.
Package openssl-1:1.1.1k-5.el8_5.x86_64 is already installed.
Dependencies resolved.
=================================================================================================================================================================================================
Package Architecture Version Repository Size
=================================================================================================================================================================================================
Installing:
cmake x86_64 3.20.2-4.el8 AppStream 12 M
mariadb-devel x86_64 3:10.3.28-1.module_el8.3.0+757+d382997d AppStream 1.1 M
Complete!
[root@zzh src]# useradd -r -M -s /sbin/nologin mysql //创建用户和组
[root@zzh src]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz //下载二进制格式的mysql软件包
--2022-08-02 21:01:47-- https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
Resolving downloads.mysql.com (downloads.mysql.com)... 23.41.76.226, 2600:1417:a000:691::2e31, 2600:1417:a000:6b5::2e31
Connecting to downloads.mysql.com (downloads.mysql.com)|23.41.76.226|:443... connected.
HTTP request sent, awaiting response... 302 Moved Temporarily
Location: https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz [following]
--2022-08-02 21:01:49-- https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
Resolving cdn.mysql.com (cdn.mysql.com)... 23.194.211.12
Connecting to cdn.mysql.com (cdn.mysql.com)|23.194.211.12|:443... connected.
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.12-x86_64.tar.gz 100%[=======================================================================================================>] 643.57M 11.4MB/s in 44s
2022-08-02 21:02:33 (14.7 MB/s) - 'mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz' saved [674830866/674830866]
[root@zzh src]# ls
debug kernels mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
[root@zzh src]# tar xf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz -C /usr/local
[root@zzh src]# cd /usr/local/
[root@zzh local]# ln -sv mysql-5.7.22-linux-glibc2.12-x86_64/ mysql
'mysql' -> 'mysql-5.7.22-linux-glibc2.12-x86_64/'
[root@zzh local]# ll
total 0
drwxr-xr-x. 14 root root 164 Aug 2 20:48 apache
drwxr-xr-x. 6 root root 58 Aug 2 20:38 apr
drwxr-xr-x. 5 root root 43 Aug 2 20:40 apr-util
drwxr-xr-x. 2 root root 6 May 18 2020 bin
drwxr-xr-x. 2 root root 6 May 18 2020 etc
drwxr-xr-x. 2 root root 6 May 18 2020 games
drwxr-xr-x. 2 root root 6 May 18 2020 include
drwxr-xr-x. 2 root root 6 May 18 2020 lib
drwxr-xr-x. 3 root root 17 Jul 4 01:38 lib64
drwxr-xr-x. 2 root root 6 May 18 2020 libexec
lrwxrwxrwx. 1 root root 36 Aug 2 21:03 mysql -> mysql-5.7.22-linux-glibc2.12-x86_64/
drwxr-xr-x. 9 root root 129 Aug 2 21:03 mysql-5.7.38-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root 6 May 18 2020 sbin
drwxr-xr-x. 5 root root 49 Jul 4 01:38 share
drwxr-xr-x. 2 root root 6 May 18 2020 src
[root@zzh local]# chown -R mysql.mysql mysql //修改目录/usr/local/mysql的属主属组
[root@zzh local]# ll
total 0
drwxr-xr-x. 14 root root 164 Aug 2 20:48 apache
drwxr-xr-x. 6 root root 58 Aug 2 20:38 apr
drwxr-xr-x. 5 root root 43 Aug 2 20:40 apr-util
drwxr-xr-x. 2 root root 6 May 18 2020 bin
drwxr-xr-x. 2 root root 6 May 18 2020 etc
drwxr-xr-x. 2 root root 6 May 18 2020 games
drwxr-xr-x. 2 root root 6 May 18 2020 include
drwxr-xr-x. 2 root root 6 May 18 2020 lib
drwxr-xr-x. 3 root root 17 Jul 4 01:38 lib64
drwxr-xr-x. 2 root root 6 May 18 2020 libexec
lrwxrwxrwx. 1 mysql mysql 36 Aug 2 21:03 mysql -> mysql-5.7.22-linux-glibc2.12-x86_64/
drwxr-xr-x. 9 root root 129 Aug 2 21:03 mysql-5.7.38-linux-glibc2.12-x86_64
drwxr-xr-x. 2 root root 6 May 18 2020 sbin
drwxr-xr-x. 5 root root 49 Jul 4 01:38 share
[root@zzh local]# ln -s /usr/local/mysql/include/ /usr/include/mysql/
[root@zzh local]# echo '/usr/local/mysql/lib/' > /etc/ld.so.conf.d/mysql.conf
[root@zzh 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
[root@zzh ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh //添加环境变量
[root@zzh ~]# source /etc/profile.d/mysql.sh
[root@zzh ~]# which mysql
/usr/local/mysql/bin/mysql
[root@zzh ~]# mkdir -p /opt/data //建立数据存放目录
[root@zzh ~]# chown -R mysql.mysql /opt/data
[root@zzh ~]# ll /opt/
total 0
drwxr-xr-x. 2 mysql mysql 6 Aug 2 21:23 data
[root@zzh ~]# mysqld --initialize --user=mysql --datadir=/opt/data/
2022-08-03T15:26:36.094822Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-08-03T15:26:36.232475Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-08-03T15:26:36.253937Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-08-03T15:26:36.307525Z 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: 59e9d26f-125e-11ed-8c19-000c296afe0a.
2022-08-03T15:26:36.308174Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-08-03T15:26:36.558632Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-08-03T15:26:36.558644Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-08-03T15:26:36.558920Z 0 [Warning] CA certificate ca.pem is self signed.
2022-08-03T15:26:36.651796Z 1 [Note] A temporary password is generated for root@localhost: ltOuw=1ywN0A
[root@zzh ~]# 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@zzh ~]# cd /usr/local/mysql/ //配置服务启动脚本
[root@zzh mysql]# ls
LICENSE bin include man support-files
README docs lib share
[root@zzh mysql]# cd support-files/
[root@zzh support-files]# ls
magic mysql-log-rotate mysql.server mysqld_multi.server
[root@zzh support-files]# cp mysql.server /etc/init.d/mysqld
[root@zzh support-files]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql //添加
datadir=/opt/data
[root@localhost support-files]# chmod +x /etc/init.d/mysqld
[root@localhost ~]# service mysqld start //启动mysql
Starting MySQL.Logging to '/opt/data/localhost.localdomain.err'.
SUCCESS!
[root@zzh ~]# chkconfig --add mysqld
[root@zzh ~]# chkconfig --list //开机自启
[root@zzh ~]# mysql -uroot -p
Enter password:
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>
mysql> set password = password('zhaozihao');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
安装php
[root@zzh ~]# wget https://www.php.net/distributions/php-7.4.30.tar.xz //下载php
--2022-08-02 21:30:42-- https://www.php.net/distributions/php-7.4.30.tar.xz
Resolving www.php.net (www.php.net)... 185.85.0.29, 2a02:cb40:200::1ad
Connecting to www.php.net (www.php.net)|185.85.0.29|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10419136 (9.9M) [application/octet-stream]
Saving to: 'php-7.4.30.tar.xz'
php-7.4.30.tar.xz 100%[=======================================================================================================>] 9.94M 546KB/s in 24s
2022-08-02 21:31:08 (430 KB/s) - 'php-7.4.30.tar.xz' saved [10419136/10419136]
[root@zzh ~]# 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 //安装依赖包
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 1:13:16 ago on Tue Aug 2 20:18:29 2022.
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]
Package libxml2-2.9.7-9.el8.x86_64 is already installed.
[root@zzh ~]# 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 httpd-2.4.54.tar.gz php-7.4.30.tar.xz
[root@zzh ~]# tar xf php-7.4.30.tar.xz
[root@zzh ~]# cd php-7.4.30
[root@zzh 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 //编译安装php
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking build system type... x86_64-pc-linux-gnu
[root@zzh php-7.4.30]# make
PEAR package PHP_Archive not installed: generated phar will require PHP's phar extension be enabled.
clicommand.inc
pharcommand.inc
invertedregexiterator.inc
[root@zzh 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/
Installing PHP FPM binary: /usr/local/php7/sbin/
Installing PHP FPM defconfig: /usr/local/php7/etc/
Installing PHP FPM man page: /usr/local/php7/php/man/man8/
Installing PHP FPM status page: /usr/local/php7/php/php/fpm/
Installing phpdbg binary: /usr/local/php7/bin/
Installing phpdbg man page: /usr/local/php7/php/man/man1/
Installing PHP CGI binary: /usr/local/php7/bin/
[root@zzh php-7.4.30]# echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php7.sh
[root@zzh php-7.4.30]# source /etc/profile.d/php7.sh
[root@zzh php-7.4.30]# which php
/usr/local/php7/bin/php
[root@zzh php-7.4.30]# php -v
PHP 7.4.30 (cli) (built: Aug 2 2022 21:34:57) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
//配置php-fpm
[root@zzh php-7.4.30]# cp php.ini-production /etc/php.ini
cp: overwrite '/etc/php.ini'? y
[root@zzh php-7.4.30]# cd sapi/
[root@zzh sapi]# ls
apache2handler cgi cli embed fpm litespeed phpdbg
[root@zzh sapi]# cd fpm/
[root@zzh fpm]# ls
CREDITS php-fpm status.html
LICENSE php-fpm.8 status.html.in
Makefile.frag php-fpm.8.in tests
config.m4 php-fpm.conf www.conf
fpm php-fpm.conf.in www.conf.in
init.d.php-fpm php-fpm.service
init.d.php-fpm.in php-fpm.service.in
[root@zzh fpm]# cp init.d.php-fpm /etc/init.d/php-fpm
[root@zzh fpm]# chmod +x /etc/init.d/php-fpm
[root@zzh ~]# cd /usr/local/php7/
[root@zzh php7]# ls
bin etc include lib php sbin var
[root@zzh php7]# cd etc
[root@zzh etc]# ls
pear.conf php-fpm.conf.default php-fpm.d
[root@zzh etc]# cp php-fpm.conf.default php-fpm.conf
[root@zzh etc]# ls
pear.conf php-fpm.conf php-fpm.conf.default php-fpm.d
[root@zzh etc]# cd php-fpm.d/
[root@zzh php-fpm.d]# ls
www.conf.default
[root@zzh php-fpm.d]# cp www.conf.default www.conf
[root@zzh php-fpm.d]# ls
www.conf www.conf.default
[root@zzh php-fpm.d]# service php-fpm start //启动php-fpm
Starting php-fpm done
[root@zzh 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@zzh ~]# chkconfig --add php-fpm //设置开机自启
[root@zzh ~]# chkconfig --list