lamp架构的部署

lamp架构的部署

文章目录

    • lamp架构的部署
    • @[toc]
      • lamp简介
      • web服务器工作流程
      • lamp平台构建
      • apache配置
      • mysql配置
      • php配置
      • 错误解决建议

lamp简介

有了前面学习的知识的铺垫,今天可以来学习下第一个常用的web架构了。

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

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

web服务器工作流程

在说lamp架构平台的搭建前,我们先来了解下什么是CGI,什么是FastCGI,什么是…

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

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

lamp平台构建

lamp平台软件安装次序:

 httpd --> mysql --> php

环境说明:

系统平台 IP 需要安装的服务
centos7 redhat7 172.16.12.128 httpd-2.4 mysql-5.7 php php-mysql

apache配置

#先配置样本源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# rm -rf *
[root@localhost yum.repos.d]# ls
[root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@localhost yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*
[root@localhost yum.repos.d]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
[root@localhost yum.repos.d]# ls
CentOS-Base.repo   epel-testing-modular.repo  epel.repo
epel-modular.repo  epel-testing.repo
[root@localhost yum.repos.d]# cat epel.repo 
baseurl=https://mirrors.aliyun.com/epel/8/Everything/$basearch	//看见是阿里云就成功了。
#清除缓存
[root@localhost ~]# dnf clean all
Failed to set locale, defaulting to C.UTF-8
55 files removed
[root@localhost ~]# dnf makecache
#安装依赖包
[root@localhost ~]# dnf -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make vim wget --allowerasing
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:02:47 ago on Tue Aug  2 07:34:13 2022.
Dependencies resolved.
==========================================================================
 Package                Arch   Version                   Repository  Size
==========================================================================
Installing:
 expat-devel            x86_64 2.2.5-4.el8               base        55 k
 gcc                    x86_64 8.5.0-4.el8_5             AppStream   23 M
 gcc-c++                x86_64 8.5.0-4.el8_5             AppStream   12 M
 libtool                x86_64 2.4.6-25.el8              AppStream  709 k
 make                   x86_64 1:4.2.1-10.el8            base       498 k
 openssl-devel          x86_64 1:1.1.1k-5.el8_5          base       2.3 M
...
Verifying        : perl-libnet-3.11-3.el8.noarch                100/105 
  Verifying        : vim-common-2:8.0.1763-16.el8.x86_64          101/105 
  Verifying        : vim-enhanced-2:8.0.1763-16.el8.x86_64        102/105 
  Verifying        : vim-filesystem-2:8.0.1763-16.el8.noarch      103/105 
  Verifying        : wget-1.19.5-10.el8.x86_64                    104/105 
  Verifying        : glibc-gconv-extra-2.28-189.el8.x86_64        105/105 
Removed:
  glibc-gconv-extra-2.28-189.el8.x86_64                                   

Complete!
[root@localhost ~]# 

#创建用户和组,下载各种依赖安装包
[root@localhost ~]# useradd -r -M -s /sbin/nologin apache
[root@localhost ~]# 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
apr-1.7.0.tar.gz   100%[==============>]   1.04M  36.1KB/s    in 44sapr-util-1.6.1.tar 100%[==============>] 541.31K  29.5KB/s    in 17s   
httpd-2.4.54.tar.g 100%[==============>]   9.29M  16.4KB/s    in 7m 2s
#解压依赖包
[root@localhost ~]# ls
anaconda-ks.cfg   apr-util-1.6.1.tar.gz
apr-1.7.0.tar.gz  httpd-2.4.54.tar.gz
[root@localhost ~]# tar xf apr-1.7.0.tar.gz 
[root@localhost ~]# tar xf apr-util-1.6.1.tar.gz 
[root@localhost ~]# ls
anaconda-ks.cfg  apr-1.7.0.tar.gz  apr-util-1.6.1.tar.gz
apr-1.7.0        apr-util-1.6.1    httpd-2.4.54.tar.gz
[root@localhost ~]# cd apr-1.7.0
[root@localhost apr-1.7.0]# ls
CHANGES         apr.dsp           configure     libapr.mak  strings
[root@localhost apr-1.7.0]# vim configure
cfgfile="${ofile}T"
    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
    # $RM "$cfgfile"        //将此行加上注释,或者删除此行

#开始编译
[root@localhost 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
config.status: creating test/internal/Makefile
config.status: creating include/arch/unix/apr_private.h
config.status: executing libtool commands
config.status: executing default commands
[root@localhost apr-1.7.0]# make
make[1]: Leaving directory '/root/apr-1.7.0'
[root@localhost apr-1.7.0]# 
[root@localhost apr-1.7.0]# make install
make[1]: Entering directory '/root/apr-1.7.0'
make[1]: Nothing to be done for 'local-all'.
make[1]: Leaving directory '/root/apr-1.7.0'
usr/bin/install -c -m 644 build/apr_rules.out /usr/local/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config
[root@localhost apr-1.7.0]# 

[root@localhost ~]# cd 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
...
config.status: creating include/private/apu_select_dbm.h
config.status: creating include/apr_ldap.h
config.status: creating include/apu.h
config.status: creating include/apu_want.h
config.status: creating test/Makefile
config.status: creating include/private/apu_config.h
config.status: executing default commands
[root@localhost apr-util-1.6.1]# make
gcc -E -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    export_vars.c | sed -e 's/^\#[^!]*//' | sed -e '/^$/d' >> aprutil.exp
sed 's,^\(location=\).*$,\1installed,' < apu-1-config > apu-config.out
make[1]: Leaving directory '/root/apr-util-1.6.1'
[root@localhost apr-util-1.6.1]# 
[root@localhost apr-util-1.6.1]# make install
----------------------------------------------------------------------
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr-util/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr-util/bin/apu-1-config
[root@localhost apr-util-1.6.1]# 
[root@localhost ~]# ls /usr/local/
apr       bin  games    lib    libexec  share
apr-util  etc  include  lib64  sbin     src
[root@localhost ~]# 

[root@localhost ~]# tar xf httpd-2.4.54.tar.gz 
[root@localhost ~]# cd httpd-2.4.54

[root@localhost httpd-2.4.54]# ./configure --prefix=/usr/local/apache \
--sysconfdir=/etc/httpd24 \	#不要这一行
> --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
configure: summary of build options:

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

[root@localhost httpd-2.4.54]# make
make[4]: Leaving directory '/root/httpd-2.4.54/modules/mappers'
make[3]: Leaving directory '/root/httpd-2.4.54/modules/mappers'
make[2]: Leaving directory '/root/httpd-2.4.54/modules'
make[2]: Entering directory '/root/httpd-2.4.54/support'
make[2]: Leaving directory '/root/httpd-2.4.54/support'

make[1]: Leaving directory '/root/httpd-2.4.54'
[root@localhost httpd-2.4.54]#  make install
mkdir /usr/local/apache/man
mkdir /usr/local/apache/man/man1
mkdir /usr/local/apache/man/man8
mkdir /usr/local/apache/manual
make[1]: Leaving directory '/root/httpd-2.4.54'
[root@localhost httpd-2.4.54]# 

[root@localhost ~]# ls /usr/local/apache/
bin    cgi-bin  error   icons    logs  manual
build  conf     htdocs  include  man   modules
[root@localhost ~]# ln -s /usr/local/apache/include /usr/include/apache
[root@localhost ~]# vi /etc/man_db.conf 

#MANDATORY_MANPATH                      /usr/src/pvm3/man
#
MANDATORY_MANPATH                       /usr/man
MANDATORY_MANPATH                       /usr/share/man
MANDATORY_MANPATH                       /usr/local/share/man
MANDATORY_MANPATH                       /usr/local/apache/man	#添加这一行

#配置service的启动方式设置开机自启
cd进入usr/lib/systemd/system目录下。
[root@localhost system]# cp sshd.service httpd.service
[root@localhost system]# vi httpd.service 
[root@localhost system]# cat 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@localhost system]# 
[root@localhost system]# systemctl daemon-reload
[root@localhost system]# systemctl status httpd
● httpd.service - web server daemon
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendo>
   Active: inactive (dead)
     Docs: man:httpd(5)
[root@localhost system]# systemctl start httpd
[root@localhost system]# 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@localhost system]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost system]# systemctl status httpd
● httpd.service - web server daemon
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor>
   Active: active (running) since Tue 2022-08-02 08:26:40 EDT; 51s ago
     Docs: man:httpd(5)
 Main PID: 222186 (httpd)
    Tasks: 6 (limit: 23460)
   Memory: 4.2M
   CGroup: /system.slice/httpd.service
           ├─222186 /usr/local/apache/bin/httpd -k start
           ├─222187 /usr/local/apache/bin/httpd -k start
           ├─222188 /usr/local/apache/bin/httpd -k start
           ├─222189 /usr/local/apache/bin/httpd -k start
           ├─222190 /usr/local/apache/bin/httpd -k start
           └─222191 /usr/local/apache/bin/httpd -k start

Aug 02 08:26:40 localhost.localdomain systemd[1]: Starting web server dae>
Aug 02 08:26:40 localhost.localdomain apachectl[222185]: AH00558: httpd: >
Aug 02 08:26:40 localhost.localdomain systemd[1]: Started web server daem>
lines 1-18/18 (END)
apache源码安装到这里就结束了。

mysql配置

#下载依赖包
[root@localhost ~]# 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:40:28 ago on Tue Aug  2 07:51:13 2022.
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.
....
mariadb-devel-3:10.3.28-1.module_el8.3.0+757+d382997d.x86_64            
  ncurses-c++-libs-6.1-9.20180224.el8.x86_64                              
  ncurses-devel-6.1-9.20180224.el8.x86_64                                 

Complete!
[root@localhost ~]# 
#创建用户和组
[root@localhost ~]# useradd -r -M -s /sbin/nologin mysql
#下载mysql压缩包
[root@localhost ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
--2022-08-02 08:35:02--  https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# 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.34-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# 
[root@localhost ~]# tar xf mysql-5.7.34-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@localhost ~]# cd /usr/local
[root@localhost local]# mv mysql-5.7.34-linux-glibc2.12-x86_64/ mysql
[root@localhost local]# ls
apache  apr-util  etc    include  lib64    mysql  share
apr     bin       games  lib      libexec  sbin   src
[root@localhost local]# chown -R mysql.mysql mysql
[root@localhost local]# ll
total 0
drwxr-xr-x. 14 root  root  164 Aug  2 08:14 apache
drwxr-xr-x.  6 root  root   58 Aug  2 08:02 apr
drwxr-xr-x.  5 root  root   43 Aug  2 08:06 apr-util
drwxr-xr-x.  2 root  root    6 Jun 22  2021 bin
drwxr-xr-x.  2 root  root    6 Jun 22  2021 etc
drwxr-xr-x.  2 root  root    6 Jun 22  2021 games
drwxr-xr-x.  2 root  root    6 Jun 22  2021 include
drwxr-xr-x.  2 root  root    6 Jun 22  2021 lib
drwxr-xr-x.  3 root  root   17 Jul 28 04:58 lib64
drwxr-xr-x.  2 root  root    6 Jun 22  2021 libexec
drwxr-xr-x.  9 mysql mysql 129 Aug  2 08:50 mysql
drwxr-xr-x.  2 root  root    6 Jun 22  2021 sbin
drwxr-xr-x.  5 root  root   49 Jul 28 04:58 share
drwxr-xr-x.  2 root  root    6 Jun 22  2021 src
[root@localhost local]# 
[root@localhost local]# ln -s /usr/local/mysql/include /usr/include/mysql
[root@localhost local]# echo '/usr/local/mysql/lib/' > /etc/ld.so.conf.d/mysql.conf
[root@localhost local]# vi /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@localhost ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@localhost ~]# source /etc/profile.d/mysql.sh 
[root@localhost ~]# which mysql
/usr/local/mysql/bin/mysql
[root@localhost ~]# 
#最后初始话
[root@localhost ~]# mkdir -p /opt/data
[root@localhost ~]# chown -R mysql.mysql /opt/data/
[root@localhost ~]# mysqld --initialize --user mysql --datadir /opt/data/
2022-08-02T13:01:20.697662Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server opt
...
root@localhost: 3imrtCsoXY-p
#结尾是随机生成的密码
[root@localhost ~]# echo '3imrtCsoXY-p' >pass
#删除系统存留的mariadb包
[root@localhost ~]# rpm -qa|grep mariadb
mariadb-connector-c-devel-3.1.11-2.el8_3.x86_64
mariadb-connector-c-config-3.1.11-2.el8_3.noarch
mariadb-devel-10.3.28-1.module_el8.3.0+757+d382997d.x86_64
mariadb-connector-c-3.1.11-2.el8_3.x86_64
[root@localhost ~]# yum -y remove mariadb*
Complete!
[root@localhost ~]# 
#添加配置文件
[root@localhost ~]# 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 ~]# 
#用脚本启动
[root@localhost ~]# cd /usr/local/mysql/
[root@localhost mysql]# ls
LICENSE  README  bin  docs  include  lib  man  share  support-files
[root@localhost mysql]# cd support-files/
[root@localhost support-files]# file mysql.server 
mysql.server: POSIX shell script, ASCII text executable
[root@localhost support-files]# ls
magic  mysql-log-rotate  mysql.server  mysqld_multi.server
[root@localhost support-files]# cp mysql.server /etc/init.d/mysqld
[root@localhost 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
Starting MySQL.Logging to '/opt/data/localhost.localdomain.err'.
 SUCCESS! 
[root@localhost ~]# 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             [::]:*             #centos5和6的开机自启方式 
[root@localhost ~]# chkconfig --add mysqld
[root@localhost ~]# chkconfig --list

[root@localhost ~]# 
[root@localhost ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost ~]# vim /etc/selinux/config 
[root@localhost ~]# 

[root@localhost ~]# reboot	//重启一下机器检验服务是否开机自启

连接断开
连接成功
Last login: Tue Aug  2 09:13:44 2022 from 192.168.171.1
[root@localhost ~]# 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               [::]:22             [::]:*              
LISTEN  0       80                   *:3306              *:*              
LISTEN  0       128                  *:80                *:*              
[root@localhost ~]# 
[root@localhost ~]# mysql -uroot -p123
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.34 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, 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安装结束

php配置

#下载网络上的php安装包
[root@localhost ~]# wget https://www.php.net/distributions/php-7.4.30.tar.xz
[root@localhost ~]# sha256sum php-7.4.30.tar.xz 
ea72a34f32c67e79ac2da7dfe96177f3c451c3eefae5810ba13312ed398ba70d  php-7.4.30.tar.xz
[root@localhost ~]# 
[root@localhost ~]# dnf -y install 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 --allowerasing
  readline-devel-7.0-10.el8.x86_64                                        
  xz-devel-5.2.4-3.el8.x86_64                                             

Complete!
[root@localhost ~]# 
#开始编译
[root@localhost php-7.2.8]# ./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.

configure: WARNING: unrecognized options: --with-gd, --with-jpeg-dir, --with-png-dir, --with-freetype-dir, --enable-zip		//#出现了一个警告
[root@localhost php-7.4.30]# ./configure --help|grep gd
-enable-gd             Include GD support
这样一个一个的修改编译文件
[root@localhost php-7.4.30]# 
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE. By continuing this installation  |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

[root@localhost php-7.4.30]# 
#开始编译
[root@localhost php-7.4.30]# make
/ext/mbstring/libmbfl -I/root/php-7.4.30/ext/mbstring/libmbfl/mbfl -I/root/php-7.4.30/TSRM -I/root/php-7.4.30/Zend    -I/usr/include -g -O2 -fvisibility=hidden -Wall -Wno-strict-aliasing -DZEND_SIGNALS    -c /root/php-7.4.30/ext/opcache/Optimizer/zend_inference.c -o ext/opcache/Optimizer/zend_inference.lo 
phar.inc

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

[root@localhost php-7.4.30]# make install
ln -s -f phar.phar /usr/local/php7/bin/phar
Installing PDO headers:           /usr/local/php7/include/php/ext/pdo/
[root@localhost php-7.4.30]# 
[root@localhost php-7.4.30]# echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php7.sh
[root@localhost php-7.4.30]# source /etc/profile.d/php7.sh
[root@localhost php-7.4.30]# which php
/usr/local/php7/bin/php
[root@localhost php-7.4.30]# 
[root@localhost php-7.4.30]# php -v
PHP 7.4.30 (cli) (built: Aug  2 2022 10:26:38) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
[root@localhost php-7.4.30]# 
[root@localhost php-7.4.30]# cp php.ini-production /etc/php.ini 
cp: overwrite '/etc/php.ini'? y
[root@localhost php-7.4.30]#
[root@localhost php-7.4.30]# cd sapi/
[root@localhost sapi]# cd fpm/
[root@localhost fpm]# ls
CREDITS        init.d.php-fpm     php-fpm.conf        status.html.in
LICENSE        init.d.php-fpm.in  php-fpm.conf.in     tests
Makefile.frag  php-fpm            php-fpm.service     www.conf
config.m4      php-fpm.8          php-fpm.service.in  www.conf.in
fpm            php-fpm.8.in       status.html
[root@localhost fpm]# file init.d.php-fpm 
init.d.php-fpm: POSIX shell script, ASCII text executable
[root@localhost fpm]# cp init.d.php-fpm /etc/init.d/php-fpm 
cp: overwrite '/etc/init.d/php-fpm'? y
[root@localhost fpm]# chmod +x /etc/init.d/php-fpm 
[root@localhost fpm]# cd
[root@localhost ~]# service php-fpm status 
php-fpm is stopped
[root@localhost ~]# cd /usr/local/php7/
[root@localhost php7]# ls
bin  etc  include  lib  php  sbin  var
[root@localhost php7]# cd etc/
[root@localhost etc]# ls
pear.conf  php-fpm.conf.default  php-fpm.d
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# ls
pear.conf  php-fpm.conf  php-fpm.conf.default  php-fpm.d
[root@localhost etc]# cd php-fpm.d/
[root@localhost php-fpm.d]# ls
www.conf.default
[root@localhost php-fpm.d]# cp www.conf.default www.conf 
[root@localhost php-fpm.d]# ls
www.conf  www.conf.default
[root@localhost php-fpm.d]# service php-fpm start
Starting php-fpm  done
[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       128               [::]:22             [::]:*              
LISTEN  0       80                   *:3306              *:*              
LISTEN  0       128                  *:80                *:*              
[root@localhost php-fpm.d]# cd 
[root@localhost ~]# chkconfig --add php-fpm
[root@localhost ~]# chkconfig --list

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

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

mysqld          0:off   1:off   2:on    3:on    4:on    5:on    6:off
php-fpm         0:off   1:off   2:on    3:on    4:on    5:on    6:off
[root@localhost ~]# 
#重启看服务是否开机自启。
[root@localhost ~]# reboot

连接断开
连接成功
Last login: Tue Aug  2 09:41:09 2022 from 192.168.171.1
[root@localhost ~]# 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       128               [::]:22             [::]:*             
LISTEN  0       80                   *:3306              *:*             
LISTEN  0       128                  *:80                *:*             
[root@localhost ~]# 

错误解决建议

#如果安装依赖包报以下这种错误,可以尝试在命令行输入:--allowerasing
Error: 
 Problem: package gcc-8.5.0-4.el8_5.x86_64 requires glibc-devel >= 2.2.90-12, but none of the providers can be installed
  - package glibc-devel-2.28-164.el8.i686 requires libpthread.so.0, but none of the providers can be installed
  - package glibc-devel-2.28-164.el8.i686 requires libdl.so.2, but none of
  ...
(try to add '--allowerasing' to command line to replace conflicting packages or '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

#如果报数据库无法启动这种错用一下解决方法试试
[root@localhost ~]# mysql -uroot -p3imrtCsoXY-p
mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory
[root@localhost ~]# yum provides libncurses.so.5
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 1:27:45 ago on Tue Aug  2 07:51:13 2022.
ncurses-compat-libs-6.1-9.20180224.el8.i686 : Ncurses compatibility
                                            : libraries
Repo        : base
Matched from:
Provide    : libncurses.so.5

[root@localhost ~]# yum -y install ncurses-compat-libs
#当报这个错时,用grep过滤一下需要什么包
Package 'sqlite3', required by 'virtual:world', not found
[root@localhost ~]# dnf list all|grep sqlite3
Failed to set locale, defaulting to C.UTF-8
libsqlite3x.x86_64                                                20071018-26.el8                                        epel         
libsqlite3x-devel.x86_64  //下载这个包就解决了                                        20071018
[root@localhost ~]# dnf -y install libsqlite3x-devel
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 2:02:18 ago on Tue Aug  2 07:51:13 2022.

#当出现这个错误时
Package 'oniguruma', required by 'virtual:world', not found
#下载这个包可以解决
[root@localhost ~]# 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

#当出现这个错误时
Package 'libzip', required by 'virtual:world', not found
Package 'libzip', required by 'virtual:world', not found
Package 'libzip', required by 'virtual:world', not found
#下载这个包
[root@localhost ~]# dnf -y install libzip-devel

你可能感兴趣的:(奋斗,架构,linux,apache)