环境说明:
lamp平台软件安装次序:
httpd --> mysql --> php安装httpd
[root@localhost yum.repos.d]# rm -rf * [root@localhost yum.repos.d]# ls [root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo --2022-04-21 16:19:34-- https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo 正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 119.36.224.206, 119.36.224.211, 119.36.224.207, ... 正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|119.36.224.206|:443... 已连接。 已发出 HTTP 请求,正在等待回应... 200 OK
[root@localhost yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo [root@localhost yum.repos.d]# cd [root@localhost ~]# dnf clean all Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 17 文件已删除
[root@localhost ~]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 上次元数据过期检查:0:04:12 前,执行于 2022年04月21日 星期四 16时22分04秒。 epel-release-latest-8.noarch.rp 107 kB/s | 23 kB 00:00 依赖关系解决。 ================================================================ 软件包 架构 版本 仓库 大小
[root@localhost ~]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel* [root@localhost ~]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel* [root@localhost ~]# dnf clean all Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 17 文件已删除 [root@localhost ~]# dnf makecache timer Updating Subscription Management repositories. Unable to read consumer identity
安装 vim
[root@localhost ~]# dnf -y install wget vim
[root@localhost ~]# yum groups mark install 'Development Tools'
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元数据过期检查:0:02:33 前,执行于 2022年04月21日 星期四 16时28分44秒。
依赖关系解决。
================================================================
软件包 架构 版本 仓库 大小
================================================================
安装组:
Development Tools
事务概要
================================================================
确定吗?[y/N]: y
完毕!
[root@localhost ~]# useradd -r -M -s /sbin/nologin apache
[root@localhost ~]# dnf -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
[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.53.tar.gz
```sql [root@localhost ~]# ls 公共 文档 anaconda-ks.cfg initial-setup-ks.cfg 模板 下载 apr-1.7.0.tar.gz 视频 音乐 apr-util-1.6.1.tar.gz 图片 桌面 httpd-2.4.53.tar.gz [root@localhost ~]# tar xf apr-1.7.0.tar.gz [root@localhost ~]# cd apr-1.7.0/ [root@localhost apr-1.7.0]# ls apr-config.in CMakeLists.txt libapr.mak poll apr.dep config.layout libapr.rc random apr.dsp configure LICENSE README apr.dsw configure.in locks README.cmake apr.mak docs Makefile.in shmem apr.pc.in dso Makefile.win strings apr.spec emacs-mode memory support atomic encoding misc tables build file_io mmap test build.conf helpers network_io threadproc buildconf include NOTICE time build-outputs.mk libapr.dep NWGNUmakefile tools CHANGES libapr.dsp passwd user [root@localhost apr-1.7.0]# vim configure [root@localhost apr-1.7.0]# ./configure --prefix=/usr/local/apr checking build system type... x86_64-pc-linux-gnu
```sql [root@localhost apr-1.7.0]# make make[1]: 进入目录“/root/apr-1.7.0” [root@localhost apr-1.7.0]# make install make[1]: 进入目录“/root/apr-1.7.0”
[root@localhost ~]# tar xf apr-util-1.6.1.tar.gz [root@localhost ~]# ls 公共 文档 anaconda-ks.cfg apr-util-1.6.1.tar.gz 模板 下载 apr-1.7.0 httpd-2.4.53.tar.gz 视频 音乐 apr-1.7.0.tar.gz initial-setup-ks.cfg 图片 桌面 apr-util-1.6.1 [root@localhost ~]# cd apr-util-1.6.1/
[root@localhost apr-util-1.6.1]# vim configure [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
[root@localhost ~]# ls 公共 文档 anaconda-ks.cfg apr-util-1.6.1.tar.gz 模板 下载 apr-1.7.0 httpd-2.4.53.tar.gz 视频 音乐 apr-1.7.0.tar.gz initial-setup-ks.cfg 图片 桌面 apr-util-1.6.1 [root@localhost ~]# tar xf httpd-2.4.53.tar.gz [root@localhost ~]# cd httpd-2.4.53/ [root@localhost httpd-2.4.53]# ls
[root@localhost httpd-2.4.53]# ./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
[root@localhost httpd-2.4.53]# make Making all in srclib make[1]: 进入目录“/root/httpd-2.4.53/srclib” make[1]: 离开目录“/root/httpd-2.4.53/srclib” Making all in os Making install in srclib [root@localhost httpd-2.4.53]# make inatall make[1]: 进入目录“/root/httpd-2.4.53/srclib” m
[root@localhost ~]# ls /usr/local/apache/
bin cgi-bin error icons logs manual
build conf htdocs include man modules
[root@localhost ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' >/etc/profile.d/httpd.sh
[root@localhost ~]# source /etc/profile.d/httpd.sh
[root@localhost ~]# which httpd.sh
/usr/bin/which: no httpd.sh in (/usr/local/apache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
[root@localhost ~]# which httpd
/usr/local/apache/bin/httpd
[root@localhost ~]# ln -s /usr/local/apache/include /usr/include/apache
[root@localhost ~]# vi /etc/man_db.conf
[root@localhost ~]# cd /usr/lib/systemd/system
[root@localhost system]# cp ssh.d.service httpd.service
cp: 无法获取'ssh.d.service' 的文件状态(stat): 没有那个文件或目录
[root@localhost system]# cp sshd.service httpd.service
[root@localhost system]# vi httpd.service
[root@localhost system]# systemctl daemon-reload
[root@localhost system]# cd
[root@localhost ~]# systemctl status httpd
● httpd.service - httpd server daemon
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disab>
Active: inactive (dead)
[root@localhost ~]# systemctl status httpd
● httpd.service - httpd server daemon
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disab>
Active: inactive (dead)
[root@localhost ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@localhost ~]# systemctl status httpd
● httpd.service - httpd server daemon
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabl>
Active: active (running) since Thu 2022-04-21 20:45:51 CST; >
Process: 177968 ExecStart=/usr/local/apache/bin/apachectl sta>
Main PID: 177971 (httpd)
Tasks: 6 (limit: 11160)
Memory: 5.5M
CGroup: /system.slice/httpd.service
├─177971 /usr/local/apache/bin/httpd -k start
├─177972 /usr/local/apache/bin/httpd -k start
├─177973 /usr/local/apache/bin/httpd -k start
├─177974 /usr/local/apache/bin/httpd -k start
├─177975 /usr/local/apache/bin/httpd -k start
└─177976 /usr/local/apache/bin/httpd -k start
[root@localhost ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:111 0.0.0.0:*
LISTEN 0 32 192.168.122.1:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 5 127.0.0.1:631 0.0.0.0:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 5 [::1]:631 [::]:*
[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 ~]# setenforce 0
[root@localhost ~]# cd /usr/lib/systemd/system
[root@localhost system]# vi httpd.service
[root@localhost system]# vim /usr/local/apache/conf/httpd.conf ServerName www.example.com:80 //取消#
[root@localhost system]# systemctl restart httpd
[root@localhost system]# systemctl status httpd
● httpd.service - httpd server daemon
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabl>
Active: active (running) since Thu 2022-04-21 21:41:14 CST; >
Process: 300350 ExecStop=/usr/local/apache/bin/apachectl stop>
Process: 300367 ExecStart=/usr/local/apache/bin/apachectl sta>
Main PID: 300371 (httpd)
Tasks: 6 (limit: 11160)
Memory: 5.4M
CGroup: /system.slice/httpd.service
├─300371 /usr/local/apache/bin/httpd -k start
├─300372 /usr/local/apache/bin/httpd -k start
├─300373 /usr/local/apache/bin/httpd -k start
├─300374 /usr/local/apache/bin/httpd -k start
├─300375 /usr/local/apache/bin/httpd -k start
└─300376 /usr/local/apache/bin/httpd -k start
lines 1-15
安装mysql
yum 部署
[root@localhost ~]# wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm --2022-04-21 22:07:03-- http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm 正在解析主机 dev.mysql.com (dev.mysql.com)... 137.254.60.11 正在连接 dev.mysql.com (dev.mysql.com)|137.254.60.11|:80... 已连接。
[root@localhost ~]# rpm -ivh mysql57-community-release-el7-10.noarch.rpm 警告:mysql57-community-release-el7-10.noarch.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
[root@localhost ~]# wget https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.37-1.el7.x86_64.rpm https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.37-1.el7.x86_64.rpm https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-devel-5.7.37-1.el7.x86_64.rpm https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-5.7.37-1.el7.x86_64.rpm https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-server-5.7.37-1.el7.x86_64.rpm --2022-04-21 22:12:37-- https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.37-1.el7.x86_64.rpm 正在解析主机 repo.mysql.com (repo.mysql.com)... 23.215.180.253 正在连接 repo.mysql.com (repo.mysql.com)|23.215.180.253|:443...
[root@localhost ~]# dnf -y install *.rpm
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
MySQL Connectors Community 53 kB/s | 133 kB 00:02
MySQL Tools Community 270 kB/s | 832 kB 00:03
MySQL 5.7 Community Server 724 kB/s | 2.5 MB 00:03
上次元数据过期检查:0:00:01 前,执行于 2022年04月21日 星期四 22时15分40秒。
软件包 mysql57-community-release-el7-10.noarch 已安装。
依赖关系解决。
================================================================
软件包 架构 版本 仓库 大小
================================================================
安装:
mysql-community-client x86_64 5.7.37-1.el7 @commandline 25 M
mysql-community-common x86_64 5.7.37-1.el7 @commandline 311 k
mysql-community-devel x86_64 5.7.37-1.el7 @commandline 3.9 M
mysql-community-libs x86_64 5.7.37-1.el7 @commandline 2.4 M
mysql-community-server x86_64 5.7.37-1.el7 @commandline 174 M
升级:
ncurses x86_64 6.1-9.20180224.el8
base 387 k
ncurses-base noarch 6.1-9.20180224.el8
base 81 k
ncurses-libs x86_64 6.1-9.20180224.el8
base 334 k
安装依赖关系:
ncurses-compat-libs x86_64 6.1-9.20180224.el8
base 328 k
事务概要
================================================================
安装 6 软件包
升级 3 软件包
总计:207 M
总下载:1.1 M
下载软件包:
(1/4): ncurses-compat-libs-6.1- 1.3 MB/s | 328 kB 00:00
(2/4): ncurses-6.1-9.20180224.e 1.5 MB/s | 387 kB 00:00
(3/4): ncurses-libs-6.1-9.20180 4.6 MB/s | 334 kB 00:00
(4/4): ncurses-base-6.1-9.20180 115 kB/s | 81 kB 00:00
----------------------------------------------------------------
总计 1.6 MB/s | 1.1 MB 00:00
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
升级 : ncurses-base-6.1-9.20180224.el8.noarch 1/12
安装 : mysql-community-common-5.7.37-1.el7.x86_64 2/12
安装 : mysql-community-libs-5.7.37-1.el7.x86_64 3/12
运行脚本: mysql-community-libs-5.7.37-1.el7.x86_64 3/12
安装 : ncurses-compat-libs-6.1-9.20180224.el8.x86_ 4/12
安装 : mysql-community-client-5.7.37-1.el7.x86_64 5/12
升级 : ncurses-libs-6.1-9.20180224.el8.x86_64 6/12
升级 : ncurses-6.1-9.20180224.el8.x86_64 7/12
运行脚本: mysql-community-server-5.7.37-1.el7.x86_64 8/12
安装 : mysql-community-server-5.7.37-1.el7.x86_64 8/12
运行脚本: mysql-community-server-5.7.37-1.el7.x86_64 8/12
安装 : mysql-community-devel-5.7.37-1.el7.x86_64 9/12
清理 : ncurses-6.1-7.20180224.el8.x86_64 10/12
清理 : ncurses-libs-6.1-7.20180224.el8.x86_64 11/12
清理 : ncurses-base-6.1-7.20180224.el8.noarch 12/12
运行脚本: ncurses-base-6.1-7.20180224.el8.noarch 12/12
验证 : ncurses-compat-libs-6.1-9.20180224.el8.x86_ 1/12
验证 : mysql-community-client-5.7.37-1.el7.x86_64 2/12
验证 : mysql-community-common-5.7.37-1.el7.x86_64 3/12
验证 : mysql-community-devel-5.7.37-1.el7.x86_64 4/12
验证 : mysql-community-libs-5.7.37-1.el7.x86_64 5/12
验证 : mysql-community-server-5.7.37-1.el7.x86_64 6/12
验证 : ncurses-6.1-9.20180224.el8.x86_64 7/12
验证 : ncurses-6.1-7.20180224.el8.x86_64 8/12
验证 : ncurses-base-6.1-9.20180224.el8.noarch 9/12
验证 : ncurses-base-6.1-7.20180224.el8.noarch 10/12
验证 : ncurses-libs-6.1-9.20180224.el8.x86_64 11/12
验证 : ncurses-libs-6.1-7.20180224.el8.x86_64 12/12
Installed products updated.
已升级:
ncurses-6.1-9.20180224.el8.x86_64
ncurses-base-6.1-9.20180224.el8.noarch
ncurses-libs-6.1-9.20180224.el8.x86_64
已安装:
mysql-community-client-5.7.37-1.el7.x86_64
mysql-community-common-5.7.37-1.el7.x86_64
mysql-community-devel-5.7.37-1.el7.x86_64
mysql-community-libs-5.7.37-1.el7.x86_64
mysql-community-server-5.7.37-1.el7.x86_64
ncurses-compat-libs-6.1-9.20180224.el8.x86_64
完毕!
[root@localhost ~]# systemctl enable --now mysqld
[root@localhost ~]# systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enab>
Active: active (running) since Thu 2022-04-21 22:17:20 CST; >
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 380783 ExecStart=/usr/sbin/mysqld --daemonize --pid->
Process: 380515 ExecStartPre=/usr/bin/mysqld_pre_systemd (cod>
Main PID: 380785 (mysqld)
Tasks: 27 (limit: 11160)
Memory: 378.8M
CGroup: /system.slice/mysqld.service
└─380785 /usr/sbin/mysqld --daemonize --pid-file=/va>
4月 21 22:17:14 localhost.localdomain systemd[1]: Starting MySQ>
4月 21 22:17:20 localhost.localdomain systemd[1]: Started MySQL>
lines 1-15/15 (END)
[root@localhost ~]# rpm -e mysql57-community-release-el7-10.noarch
[root@localhost ~]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@localhost ~]# mysql -uroot -p'Qzl123456!';
mysql> GRANT all ON *.* TO'root'@'192.168.70.%' IDENTIFIED BY 'Qzl123456!';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> GRANT all ON *.* TO'root'@'%' IDENTIFIED BY 'Qzl123456!';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
[root@localhost ~]# systemctl disable --now firewalld.serice
Failed to disable unit: Unit file firewalld.serice.service does not exist.
[root@localhost ~]# wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
--2022-04-21 23:00:22-- http://rpms.remirepo.net/enterprise/remi-release-7.rpm
正在解析主机 rpms.remirepo.net (rpms.remirepo.net)... 109.238.14.107, 2a00:c70:1:109:238:14:107:1
正在连接 rpms.remirepo.net (rpms.remirepo.net)|109.238.14.107|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:23688 (23K) [application/x-rpm]
正在保存至: “remi-release-7.rpm”
remi-release-7. 100%[=======>] 23.13K 54.2KB/s 用时 0.4s
2022-04-21 23:00:23 (54.2 KB/s) - 已保存 “remi-release-7.rpm” [23688/23688])
[root@localhost ~]#
- 安装php
解决依赖关系
[root@localhost ~]# rpm -Uvh remi-release-7.rpm
警告:remi-release-7.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 00f97f56: NOKEY
错误:依赖检测失败:
epel-release = 7 被 remi-release-7.9-3.el7.remi.noarch 需要
[root@localhost ~]# rpm -Uvh remi-release-7.rpm --force --nodeps
警告:remi-release-7.rpm: 头V4 DSA/SHA1 Signature, 密钥 ID 00f97f56: NOKEY
Verifying... ################################# [100%]
准备中... ################################# [100%]
正在升级/安装...
1:remi-release-7.9-3.el7.remi ################################# [100%]
[root@localhost ~]#
[root@localhost ~]# yum makecache --enablerepo=remi-php74 Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. CentOS-8.5.2111 - Base - mirror 9.4 kB/s | 3.9 kB 00:00 CentOS-8.5.2111 - Extras - mirr 12 kB/s | 1.5 kB 00:00 CentOS-8.5.2111 - AppStream - m 13 kB/s | 4.3 kB 00:00 Extra Packages for Enterprise L 6.6 kB/s | 3.0 kB 00:00 Extra Packages for Enterprise L 9.1 kB/s | 4.7 kB 00:00 Remi's PHP 7.4 RPM repository f 4.1 kB/s | 243 kB 00:59 Safe Remi's RPM repository for 94 kB/s | 2.7 MB 00:29 元数据缓存已建立。 [root@localhost ~]#
//安装依赖包
[root@localhost ~]# yum -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 php72-php-mysqlnd
下载php
[root@localhost ~]# cd /usr/src/ [root@localhost src]# wget http://cn.php.net/distributions/php-7.2.8.tar.xz --2022-04-21 23:12:07-- http://cn.php.net/distributions/php-7.2.8.tar.xz 正在解析主机 cn.php.net (cn.php.net)... 185.85.0.29, 2a02:cb40:200::1ad 正在连接 cn.php.net (cn.php.net)|185.85.0.29|:80... 已连接。 已发出 HTTP 请求,正在等待回应... 301 Moved Permanently
编译安装php
[root@localhost src]# tar xf php-7.2.8.tar.xz [root@localhost src]# cd php-7.2.8 [root@localhost php-7.2.8]# ./configure --prefix=/usr/local/ apache/ bin/ include/ libexec/ src/ apr/ etc/ lib/ sbin/ apr-util/ games/ lib64/ share/ [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 > --with-gd > --with-jpeg-dir > --with-png-dir > --with-zlib-dir > --with-freetype-dir > --with-gettext > --enable-json > --enable-mbstring > --enable-pdo > --with-mysqli=mysqlnd > --with-pdo-mysql=mysqlnd > --with-readline > --enable-shmop > --enable-simplexml > --enable-sockets > --enable-zip > --enable-mysqlnd-compression-support > --with-pear > --enable-pcntl > --enable-posix
编译过程略
[root@localhost php-7.2.8]# make -j $(cat /proc/cpuinfo |grep processor|wc -l)
安装过程略
[root@localhost php-7.2.8]# make install Installing shared extensions: /usr/local/php7/lib/php/extensions/no-debug-non-zts-20170718/ Installing PHP CLI binary: /usr/local/php7/bin/ Installing PHP CLI man page: /usr/local/php7/php/man/man1/
安装后配置
[root@localhost php-7.2.8]# echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php7.sh [root@localhost php-7.2.8]# which php /usr/bin/which: no php in (/usr/local/apache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin) [root@localhost php-7.2.8]# php -v PHP 7.2.8 (cli) (built: Apr 21 2022 23:26:21) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
配置php-fpm
[root@localhost php-7.2.8]# cp php.ini-production /etc/php.ini [root@localhost php-7.2.8]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm [root@localhost php-7.2.8]# chmod +x /etc/rc.d/init.d/php-fpm [root@localhost php-7.2.8]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf [root@localhost php-7.2.8]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf [root@localhost php-7.2.8]#
编辑php-fpm的配置文件(/usr/local/php7/etc/php-fpm.conf):
配置fpm的相关选项为你所需要的值
[root@localhost ~]# vim /usr/local/php7/etc/php-fpm.conf [root@localhost ~]# tail /usr/local/php7/etc/php-fpm.conf ; Relative path can also be used. They will be prefixed by: ; - the global prefix if it's been set (-p argument) ; - /usr/local/php7 otherwise include=/usr/local/php7/etc/php-fpm.d/*.conf pm.max_children = 50 pm.start_servers = 5 pm.min_spare_servers = 2 pm.max_spare_servers = 8 [root@localhost ~]#
启动php-fpm
[root@localhost ~]# service php-fpm start Starting php-fpm done
默认情况下,fpm监听在127.0.0.1的9000端口,也可以使用如下命令验证其是否已经监听在相应的套接字
[root@localhost ~]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 127.0.0.1:9000 0.0.0.0:* LISTEN 0 128 0.0.0.0:111 0.0.0.0:* LISTEN 0 32 192.168.122.1:53 0.0.0.0:* LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 5 127.0.0.1:631 0.0.0.0:* LISTEN 0 80 *:3306 *:* LISTEN 0 128 [::]:111 [::]:* LISTEN 0 128 *:80 *:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 5 [::1]:631 [::]:* [root@localhost ~]# ps -ef|grep php root 784948 1 0 23:46 ? 00:00:00 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf) nobody 784949 784948 0 23:46 ? 00:00:00 php-fpm: pool www nobody 784950 784948 0 23:46 ? 00:00:00 php-fpm: pool www nobody 784951 784948 0 23:46 ? 00:00:00 php-fpm: pool www nobody 784952 784948 0 23:46 ? 00:00:00 php-fpm: pool www nobody 784953 784948 0 23:46 ? 00:00:00 php-fpm: pool www root 789884 2277 0 23:47 pts/0 00:00:00 grep --color=auto php配置apache 启用代理模块
启用httpd的相关模块
[root@localhost ~]# sed -i '/proxy_module/s/#//g' /usr/local/apache/conf/httpd.conf [root@localhost ~]# sed -i '/proxy_fcgi_module/s/#//g' /usr/local/apache/conf/httpd.conf [root@localhost ~]#配置虚拟主机
在需要使用fcgi的虚拟主机中添加类似如下两行
[root@localhost ~]# mkdir /usr/local/apache/htdocs/wanqqing.com [root@localhost ~]# cat > /usr/local/apache/htdocs/wanqqing.com/index.php <phpinfo(); > ?> > EOF [root@localhost ~]# chown -R apache.apache /usr/local/apache/htdocs/ [root@localhost ~]# ll /usr/local/apache/htdocs/ -d drwxr-xr-x. 3 apache apache 44 4月 22 14:32 /usr/local/apache/htdocs/ [root@localhost ~]# vim /usr/local/apache/conf/httpd.conf [root@localhost ~]# sed -i '/ DirectoryIndex/s/index.html/index.php index.html/g' /usr/local/apache/conf/httpd.conf [root@localhost htdocs]# apachectl stop httpd (no pid file) not running [root@localhost htdocs]# apachectl start [root@localhost htdocs]# ss -antl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 127.0.0.1:9000 0.0.0.0:* LISTEN 0 128 0.0.0.0:111 0.0.0.0:* LISTEN 0 32 192.168.122.1:53 0.0.0.0:* LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 5 127.0.0.1:631 0.0.0.0:* LISTEN 0 80 *:3306 *:* LISTEN 0 128 [::]:111 [::]:* LISTEN 0 128 *:80 *:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 5 [::1]:631 [::]:
- 验证
1.修改/etc/hosts文件,添加域名与IP的映射
2.在浏览器上使用域名访问,若看到以下界面则表示lamp架构搭建成功,否则请检查你的操作



