centos8-独立加分离部署lamp架构

单机部署lamp

实验环境

关闭防火墙

  • 三台主机都需要关闭(这里只写一条)
[root@cloud1 ~]# setenforce 0
[root@cloud1 ~]# systemctl stop firewalld

实验流程

安装apache

实验思路
  1. 先安装gcc ,gcc++ 环境
  2. 安装openssl-devel pcre-devel expat-devel libtool
  3. 安装apr 和apr-utils
  4. 安装apache
  5. 编写环境变量
  6. 启动服务
  7. 关闭防火墙
实验流程
  • 第一步:安装gcc ,gcc-c++
[root@cloud1 ~]# yum install -y gcc gcc-c++
  • 第二步:安装openssl-devel pcre-devel expat-devel libtool
[root@cloud1 ~]# yum install -y openssl-devel pcre-devel expat-devel libtool
  • 第三步:安装apr和apr-utils
  • 下载地址:http://archive.apache.org/dist/apr/

image-20210424174138068

image-20210424174046306

#用xftp传到/opt
[root@cloud1 opt]# ls
apr-1.6.3.tar.gz  apr-util-1.6.1.tar.gz
[root@cloud1 opt]# tar -xf apr-1.6.3.tar.gz 
[root@cloud1 opt]# tar -xf apr-util-1.6.1.tar.gz
[root@cloud1 opt]# cd apr-1.6.3/
[root@cloud1 apr-1.6.3]# vim configure
30976    #$RM "$cfgfile"  #在30976行添加注释
[root@cloud1 apr-1.6.3]# ./configure --prefix=/usr/local/apr
[root@cloud1 apr-1.6.3]# make && make install
[root@cloud1 apr-1.6.3]# cd /opt/apr-util-1.6.1/
[root@cloud1 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@cloud1 apr-util-1.6.1]# make & make install

  • 第四步:安装apache
  • 下载地址:http://httpd.apache.org/download.cgi

image-20210424180249801

#xftp传到/opt
[root@cloud1 opt]# tar xf httpd-2.4.46.tar.gz 
[root@cloud1 opt]# cd httpd-2.4.46/
[root@cloud1 httpd-2.4.46]# ./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
[root@cloud1 httpd-2.4.46]# make && make install
  • 编写环境变量
[root@z1 yum.repos.d]# echo 'export PATH=/usr/local/apache/bin/:$PATH' > /etc/profile.d/apache.sh
[root@z1 yum.repos.d]# source /etc/profile.d/apache.sh

  • 启动服务
[root@z1 httpd-2.4.46]# apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fec4:1136. Set the 'ServerName' directive globally to suppress this message
  • 第六步:关闭防火墙和selinux
[root@cloud1 ~]# setenforce 0
[root@cloud1 ~]# systemctl stop firewalld

image-20210424191408171

安装mysql

实验思路
  1. 去官网下载安装包
  2. 用xftp传到服务器上(略)
  3. 创建用户
  4. 将二进制文件解压
  5. 修改权限
  6. 添加环境变量
  7. 建立存放数据目录
  8. 初始化数据库
  9. 生成配置文件
  10. 头文件和库文件
  11. 编写server启动方式
  12. 修改密码
  13. 修改登陆方式、
实验流程
下载安装包

image-20210502144237909

image-20210502144354354

image-20210502144441362

image-20210502144655414

image-20210502144904589

image-20210502145446332

xftp传到服务器上(略)
创建用户
[root@cloud1 ~]# useradd -rMs /sbin/nologin mysql
解压到指定文件
[root@cloud1 ~]# tar xf mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@cloud1 ~]# cd /usr/local/
[root@cloud1 local]# ls
bin  etc  games  include  lib  lib64  libexec  mysql-5.7.33-linux-glibc2.12-x86_64  sbin  share  src
[root@cloud1 local]# mv mysql-5.7.33-linux-glibc2.12-x86_64/ mysql
修改权限
[root@cloud1 local]# chown -R mysql.mysql mysql/
[root@cloud1 local]# ll | grep mysql
drwxr-xr-x  9 mysql mysql 129 May  2 03:05 mysql 
添加环境变量
[root@cloud1 local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@cloud1 local]# source /etc/profile

建立存放数据的目录
  • 数据库的数据量比较大,所以 选择一个储存大一点的地方存储
[root@cloud1 local]# mkdir /opt/data
[root@cloud1 local]# chown -R mysql.mysql /opt/data/ 
初始化数据库
[root@cloud1 local]#  /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
2021-05-02T07:25:16.580540Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-05-02T07:25:16.781000Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-05-02T07:25:16.803557Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-05-02T07:25:16.870950Z 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: 8af2fb35-ab17-11eb-ae11-000c29c41136.
2021-05-02T07:25:16.872109Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-05-02T07:25:17.191958Z 0 [Warning] CA certificate ca.pem is self signed.
2021-05-02T07:25:17.322977Z 1 [Note] A temporary password is generated for root@zl: sATlUgnra0-l
 
 
 #把最后一行代码存放在一个文件里 留着备用
[root@cloud1 local]# echo "sATlUgnra0-l" > ~/mysql_passwd
[root@cloud1 local]# cat ~/mysql_passwd 
sATlUgnra0-l
生成配置文件
[root@cloud1 ~]# vim /etc/my.cnf 
[mysqld]
basedir = /usr/local/mysql #指定mysql的安装目录
datadir = /opt/data        #指定数据的存放目录
socket = /tmp/mysql.sock   #指定套接字存放目录
port = 3306 			   #指定端口
pid-file = /opt/data/mysql.pid #指定pid文件存放位置
user = mysql 			  #指定MySQL以什么用户的身份提供服务
skip-name-resolve
头文件和库文件配置
[root@cloud1 ~]ln -s /usr/local/mysql/include /usr/include/mysql
[root@cloud1 ~]vim /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib
[root@cloud1 ~]ldconfig 
编写server启动方式
[root@cloud1 local]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld 
[root@cloud1 local]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql  #环境变量目录
datadir=/opt/data         #数据存储目录
[root@cloud1 local]# service mysqld start
[root@cloud1 local]# chkconfig mysqld on
[root@cloud1 local]# 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]'.

gcc-toolset-10-stap-server	0:off	1:off	2:off	3:off	4:off	5:off	6:off
gcc-toolset-10-systemtap	0:off	1:off	2:on	3:on	4:on	5:on	6:off
gcc-toolset-9-stap-server	0:off	1:off	2:off	3:off	4:off	5:off	6:off
gcc-toolset-9-systemtap	0:off	1:off	2:on	3:on	4:on	5:on	6:off
mysqld         	0:off	1:off	2:on	3:on	4:on	5:on	6:off

修改密码
//修改密码
//使用临时密码登录
[root@z2 ~]# yum install -y ncurses-compat-libs
[root@zl ~]# /usr/local/mysql/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.22

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

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

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

mysql> 

//设置新密码
mysql> set password = password('123.com.');
Query OK, 0 rows affected, 1 warning (0.00 sec)
修改mysql登陆方式
[root@cloud1 ~]# vim ~/.my.cnf
[client]
user=root
password=123.com
[root@cloud1 ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.33 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> 

C3安装php

  • 安装php
[root@z3 ~]# yum install -y php* #centos8可安装php
  • 启动php
[root@z3 ~]# systemctl start php-fpm.service 
[root@z3 ~]# ss -antl
State  Recv-Q Send-Q Local Address:Port Peer Address:Port Process 
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             [::]:22           [::]:*            
LISTEN 0      5              [::1]:631          [::]:*            
[root@z3 ~]# ps -aux | grep php
root        3818  0.1  2.8 549564 37932 ?        Ss   05:59   0:00 php-fpm: master process (/etc/php-fpm.conf)
apache      3819  0.0  1.6 565900 21704 ?        S    05:59   0:00 php-fpm: pool www
apache      3820  0.0  1.6 565900 21708 ?        S    05:59   0:00 php-fpm: pool www
apache      3821  0.0  1.6 565900 21708 ?        S    05:59   0:00 php-fpm: pool www
apache      3822  0.0  1.6 565900 21708 ?        S    05:59   0:00 php-fpm: pool www
apache      3823  0.0  1.6 565900 21708 ?        S    05:59   0:00 php-fpm: pool www
root        3830  0.0  0.0  12112  1040 pts/1    S+   05:59   0:00 grep --color=auto php
#有php的进程但是没有php的端口

php配置

[root@z3 ~]# vim /etc/php-fpm.d/www.conf
 38  listen = /run/php-fpm/www.sock 	#取消注释
 39  listen = 0.0.0.0:9000          	#添加此行
 64 ;listen.allowed_clients = 127.0.0.1 #添加注释
[root@z3 ~]# mkdir -p /data/php
[root@z3 ~]# vim /data/php/index.php
<?php
        phpinfo();
?>
[root@z3 ~]# chown -R apache.apache /data/
[root@z3 ~]# systemctl restart php-fpm.service
[root@z3 ~]# ss -antl
State  Recv-Q Send-Q Local Address:Port Peer Address:Port Process 
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	  128     			 *:80              *:*    
LISTEN 0      5          127.0.0.1:631       0.0.0.0:*            
LISTEN 0      128          0.0.0.0:9000      0.0.0.0:*            
LISTEN 0      128             [::]:111          [::]:*            
LISTEN 0      128             [::]:22           [::]:*            
LISTEN 0      5              [::1]:631          [::]:*  

apache配置

[root@z1 ~]# vim /etc/httpd24/httpd.conf
120 LoadModule proxy_module modules/mod_proxy.so 			#120行取消注释
124 LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.	#124行取消注释
203 ServerName 0.0.0.0.com:80								#这一条修改成这样
261     DirectoryIndex  index.php index.html				#再中间插入index.php
397     AddType application/x-compress .Z
398     AddType application/x-gzip .gz .tgz
399     AddType application/x-httpd-php .php        		#添加此行
400     AddType application/x-httpd-php-source .phps		#添加此行
488 #Include /etc/httpd24/extra/httpd-vhosts.conf
489 Include /etc/httpd24/extra/vhosts.conf                  #添加此条

#末尾加入下列信息
<VirtualHost *:80>
    DocumentRoot "/data/php/" #文件存放路径
    ServerName www.zhanglei.com
    DirectoryIndex index.php
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/data/php/$1
    <Directory "/data/php/">
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>
[root@z1 ~]# mkdir -p /data/php
[root@z1 ~]# useradd apache
[root@z1 ~]# chown apache.apache -R /data        
[root@z1 ~]# [root@z3 ~]# vim /data/php/index.php
<?php
        phpinfo();
?>
[root@z1 ~]# apachectl restart

多机部署lamp

实验环境

系统版本ip搭建服务主机名
centos 8192.168.80.21apachec1
centos 8192.168.80.22mysqlc2
centos 8192.168.80.23phpc3

关闭防火墙

  • 三台主机都需要关闭(这里只写一条)
[root@cloud1 ~]# setenforce 0
[root@cloud1 ~]# systemctl stop firewalld

实验流程

c1安装apache

实验思路
  1. 先安装gcc ,gcc++ 环境
  2. 安装openssl-devel pcre-devel expat-devel libtool
  3. 安装apr 和apr-utils
  4. 安装apache
  5. 编写环境变量
  6. 启动服务
  7. 关闭防火墙
实验流程
  • 第一步:安装gcc ,gcc-c++
[root@cloud1 ~]# yum install -y gcc gcc-c++
  • 第二步:安装openssl-devel pcre-devel expat-devel libtool
[root@cloud1 ~]# yum install -y openssl-devel pcre-devel expat-devel libtool
  • 第三步:安装apr和apr-utils
  • 下载地址:http://archive.apache.org/dist/apr/

image-20210424174138068

image-20210424174046306

#用xftp传到/opt
[root@cloud1 opt]# ls
apr-1.6.3.tar.gz  apr-util-1.6.1.tar.gz
[root@cloud1 opt]# tar -xf apr-1.6.3.tar.gz 
[root@cloud1 opt]# tar -xf apr-util-1.6.1.tar.gz
[root@cloud1 opt]# cd apr-1.6.3/
[root@cloud1 apr-1.6.3]# vim configure
30976    #$RM "$cfgfile"  #在30976行添加注释
[root@cloud1 apr-1.6.3]# ./configure --prefix=/usr/local/apr
[root@cloud1 apr-1.6.3]# make && make install
[root@cloud1 apr-1.6.3]# cd /opt/apr-util-1.6.1/
[root@cloud1 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@cloud1 apr-util-1.6.1]# make & make install

  • 第四步:安装apache
  • 下载地址:http://httpd.apache.org/download.cgi

image-20210424180249801

#xftp传到/opt
[root@cloud1 opt]# tar xf httpd-2.4.46.tar.gz 
[root@cloud1 opt]# cd httpd-2.4.46/
[root@cloud1 httpd-2.4.46]# ./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
[root@cloud1 httpd-2.4.46]# make && make install
  • 编写环境变量
[root@z1 yum.repos.d]# echo 'export PATH=/usr/local/apache/bin/:$PATH' > /etc/profile.d/apache.sh
[root@z1 yum.repos.d]# source /etc/profile.d/apache.sh

  • 启动服务
[root@z1 httpd-2.4.46]# apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fec4:1136. Set the 'ServerName' directive globally to suppress this message
  • 第六步:关闭防火墙和selinux
[root@cloud1 ~]# setenforce 0
[root@cloud1 ~]# systemctl stop firewalld

image-20210424191408171

c2安装mysql

实验思路
  1. 去官网下载安装包
  2. 用xftp传到服务器上(略)
  3. 创建用户
  4. 将二进制文件解压
  5. 修改权限
  6. 添加环境变量
  7. 建立存放数据目录
  8. 初始化数据库
  9. 生成配置文件
  10. 头文件和库文件
  11. 编写server启动方式
  12. 修改密码
  13. 修改登陆方式、
实验流程
下载安装包

image-20210502144237909

image-20210502144354354

image-20210502144441362

image-20210502144655414

image-20210502144904589

image-20210502145446332

xftp传到服务器上(略)
创建用户
[root@cloud1 ~]# useradd -rMs /sbin/nologin mysql
解压到指定文件
[root@cloud1 ~]# tar xf mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@cloud1 ~]# cd /usr/local/
[root@cloud1 local]# ls
bin  etc  games  include  lib  lib64  libexec  mysql-5.7.33-linux-glibc2.12-x86_64  sbin  share  src
[root@cloud1 local]# mv mysql-5.7.33-linux-glibc2.12-x86_64/ mysql
修改权限
[root@cloud1 local]# chown -R mysql.mysql mysql/
[root@cloud1 local]# ll | grep mysql
drwxr-xr-x  9 mysql mysql 129 May  2 03:05 mysql 
添加环境变量
[root@cloud1 local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@cloud1 local]# source /etc/profile

建立存放数据的目录
  • 数据库的数据量比较大,所以 选择一个储存大一点的地方存储
[root@cloud1 local]# mkdir /opt/data
[root@cloud1 local]# chown -R mysql.mysql /opt/data/ 
初始化数据库
[root@cloud1 local]#  /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
2021-05-02T07:25:16.580540Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-05-02T07:25:16.781000Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-05-02T07:25:16.803557Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-05-02T07:25:16.870950Z 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: 8af2fb35-ab17-11eb-ae11-000c29c41136.
2021-05-02T07:25:16.872109Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-05-02T07:25:17.191958Z 0 [Warning] CA certificate ca.pem is self signed.
2021-05-02T07:25:17.322977Z 1 [Note] A temporary password is generated for root@zl: sATlUgnra0-l
 
 
 #把最后一行代码存放在一个文件里 留着备用
[root@cloud1 local]# echo "sATlUgnra0-l" > ~/mysql_passwd
[root@cloud1 local]# cat ~/mysql_passwd 
sATlUgnra0-l
生成配置文件
[root@cloud1 ~]# vim /etc/my.cnf 
[mysqld]
basedir = /usr/local/mysql #指定mysql的安装目录
datadir = /opt/data        #指定数据的存放目录
socket = /tmp/mysql.sock   #指定套接字存放目录
port = 3306 			   #指定端口
pid-file = /opt/data/mysql.pid #指定pid文件存放位置
user = mysql 			  #指定MySQL以什么用户的身份提供服务
skip-name-resolve
头文件和库文件配置
[root@cloud1 ~]ln -s /usr/local/mysql/include /usr/include/mysql
[root@cloud1 ~]vim /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib
[root@cloud1 ~]ldconfig 
编写server启动方式
[root@cloud1 local]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld 
[root@cloud1 local]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql  #环境变量目录
datadir=/opt/data         #数据存储目录
[root@cloud1 local]# service mysqld start
[root@cloud1 local]# chkconfig mysqld on
[root@cloud1 local]# 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]'.

gcc-toolset-10-stap-server	0:off	1:off	2:off	3:off	4:off	5:off	6:off
gcc-toolset-10-systemtap	0:off	1:off	2:on	3:on	4:on	5:on	6:off
gcc-toolset-9-stap-server	0:off	1:off	2:off	3:off	4:off	5:off	6:off
gcc-toolset-9-systemtap	0:off	1:off	2:on	3:on	4:on	5:on	6:off
mysqld         	0:off	1:off	2:on	3:on	4:on	5:on	6:off

修改密码
//修改密码
//使用临时密码登录
[root@z2 ~]# yum install -y ncurses-compat-libs
[root@zl ~]# /usr/local/mysql/bin/mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.22

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

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

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

mysql> 

//设置新密码
mysql> set password = password('123.com.');
Query OK, 0 rows affected, 1 warning (0.00 sec)
修改mysql登陆方式
[root@cloud1 ~]# vim ~/.my.cnf
[client]
user=root
password=123.com
[root@cloud1 ~]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.33 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> 

C3安装php

  • 安装php
[root@z3 ~]# yum install -y php* #centos8可安装php
  • 启动php
[root@z3 ~]# systemctl start php-fpm.service 
[root@z3 ~]# ss -antl
State  Recv-Q Send-Q Local Address:Port Peer Address:Port Process 
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             [::]:22           [::]:*            
LISTEN 0      5              [::1]:631          [::]:*            
[root@z3 ~]# ps -aux | grep php
root        3818  0.1  2.8 549564 37932 ?        Ss   05:59   0:00 php-fpm: master process (/etc/php-fpm.conf)
apache      3819  0.0  1.6 565900 21704 ?        S    05:59   0:00 php-fpm: pool www
apache      3820  0.0  1.6 565900 21708 ?        S    05:59   0:00 php-fpm: pool www
apache      3821  0.0  1.6 565900 21708 ?        S    05:59   0:00 php-fpm: pool www
apache      3822  0.0  1.6 565900 21708 ?        S    05:59   0:00 php-fpm: pool www
apache      3823  0.0  1.6 565900 21708 ?        S    05:59   0:00 php-fpm: pool www
root        3830  0.0  0.0  12112  1040 pts/1    S+   05:59   0:00 grep --color=auto php
#有php的进程但是没有php的端口

php配置

[root@z3 ~]# vim /etc/php-fpm.d/www.conf
 38  listen = /run/php-fpm/www.sock 	#取消注释
 39  listen = 0.0.0.0:9000          	#添加此行
 64 ;listen.allowed_clients = 127.0.0.1 #添加注释
[root@z3 ~]# mkdir -p /data/php
[root@z3 ~]# vim /data/php/index.php
<?php
        phpinfo();
?>
[root@z3 ~]# chown -R apache.apache /data/
[root@z3 ~]# systemctl restart php-fpm.service
[root@z3 ~]# ss -antl
State  Recv-Q Send-Q Local Address:Port Peer Address:Port Process 
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          0.0.0.0:9000      0.0.0.0:*            
LISTEN 0      128             [::]:111          [::]:*            
LISTEN 0      128             [::]:22           [::]:*            
LISTEN 0      5              [::1]:631          [::]:*  

apache配置

[root@z1 ~]# vim /etc/httpd24/httpd.conf
120 LoadModule proxy_module modules/mod_proxy.so 			#120行取消注释
124 LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.	#124行取消注释
203 ServerName 0.0.0.0.com:80								#这一条修改成这样
261     DirectoryIndex  index.php index.html				#再中间插入index.php
397     AddType application/x-compress .Z
398     AddType application/x-gzip .gz .tgz
399     AddType application/x-httpd-php .php        		#添加此行
400     AddType application/x-httpd-php-source .phps		#添加此行
488 #Include /etc/httpd24/extra/httpd-vhosts.conf
489 Include /etc/httpd24/extra/vhosts.conf                  #添加此条

#末尾加入下列信息
<VirtualHost *:80>
    DocumentRoot "/data/php/" #文件存放路径
    ServerName www.zhanglei.com
    DirectoryIndex index.php
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://192.168.80.23:9000/data/php/$1
    <Directory "/data/php/">
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>
[root@z1 ~]# mkdir -p /data/php
[root@z1 ~]# useradd apache
[root@z1 ~]# chown apache.apache -R /data
root@z1 ~]# ls /data/php        #此目录为空,没有任何东西(证明调用的是php那台主机的index.php文件)
[root@z1 ~]# 

image-20210513012956349

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值