wjh0077

导航

 

LAMP 架构介绍及环境搭建

LAMP动态网站架构

LAMP是指一组通常一起使用来运行动态网站或者服务器的自由软件名称首字母缩写。

1、LAMP分别代表什么?

  • L代表服务器操作系统使用Linux

  • A代表网站服务使用的是Apache软件基金会中的httpd软件

  • M代表网站后台使用的数据库是MySQL数据库

  • P代表网站是使用PHP/Perl/Python等语言开发

    image.png

    image.png

2、Apache/MySQL/PHP各自有什么作用?

2.1 Apache(httpd)-----像极了饭店前台

  • 作用:提供web服务,接受用户的连接请求

    http

    http

  • 注意:Apache或Nginx都只支持静态页面的解析

当客户端请求的是静态资源时,web服务(httpd程序),会直接返回静态资源给客户端

①静态网页

  • 静态网页指使用HTML(超文本标记语言)编写,一般后缀为.htm,.html等;网页文件中没有程序代码。
  • 静态页面,用户双击打开,看到的效果与web服务器是相同的,因为网页的内容在用户访问之前就已经确定。

②动态网页

  • 动态网页指网站使用特定的编程语言编写,网页文件中除了HTML标记以外,还包括一些实现特定功能的程序代码。
  • 服务端可以根据客户端的不同请求动态产生网页内容。
  • 动态网页后缀一般为.php .asp .aspx .cgi .perl .jsp等
  • 常见的留言板,论坛,注册,发帖都是用动态网页实现的。

③小结提问
1)什么是web服务?
答:提供网页浏览功能的服务。
即安装并启用web服务软件如:httpd/nginx等软件。客户端可以通过浏览器访问网站。

2)什么是web服务器?
答:简单来理解就是安装web服务软件,并能够提供web服务的机器。

3)Web一般是分为客户端与服务器端,两者是如何交互的?
答:通过HTTP协议。例如:http://www.hanzz.red

4)Aapche(httpd)能不能解析动态网页?
答:不能,Apache负责静态页面的解析。

2.2 PHP - 像极了服务生

  • 作用:PHP主要负责PHP脚本程序的解析以及实现与MySQL数据库的交互工作,动态页面中的注册/登陆/下单/支付等大多数功能都是基于PHP+MySQL进行实现。PHP是一种通用开源脚本语言。

    php

    php

1、当客户端请求的是动态资源时,apache(httpd程序)会调用libphpX.so模块进行相应的解析
2、如果解析处理需要用到后台数据库相关数据,此时php程序也会连接后台数据库
3、最终php程序将解析后的结果返回给apache(httpd程序),让apache返回给客户端

2.3 MySQL数据库 - 像极了厨师

  • 作用:MySQL是一个关系型数据库管理系统,由瑞典MySQL AB公司开发,目前属于Oracle旗下产品。其主要作用用于

    永久的存储数据

    mysql

    mysql

3、LAMP架构是什么?- 像极了饭店

lamp-example

lamp-example

image.pngimage.png

任务背景
小韩经过一段时间学习,慢慢了解到公司的一些业务架构,发现好几个项目不是LAMP架构就是Nginx+Tomcat。于是小韩决定,慢慢的吃透这些架构,先学习LAMP架构,再研究Nginx+Tomcat架构。所以,小韩就给自己定一个任务,在自己的虚拟机环境下,构建LAMP环境。由于自己所维护的业务正好是一个电商平台,决定上线一个电商项目。

任务需求

3.1任务具体要求

  • 使用yum(dnf)工具一键部署LAMP环境
  • 发布电商项目上线
    • 能够实现web界面注册会员账号
    • 能够实现web界面进行后台商品及会员的管理

3.2架构分析

网上商城主要基于PHP+MySQL进行设计。
页面编写语言:PHP语言 -(服务生)负责解析动态页面,同时实现数据库的交互工作
数据库系统:MySQL -(厨师)负责存储数据,并提供用户请求的数据
web服务:Apache(httpd)-(前台)负责与客户端建立连接,使客户端能够访问网页。

//首先配置yum源
[root@centos8 ~]# cd /etc/yum.repos.d/
[root@centos8 yum.repos.d]# rm -rf *
[root@centos8 yum.repos.d]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
[root@centos8 yum.repos.d]# yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpm
[root@centos8 yum.repos.d]# sed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*[root@centos8 yum.repos.d]# sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel*
[root@centos8 yum.repos.d]# ls
CentOS-Base.repo   epel.repo                  epel-testing.repo
epel-modular.repo  epel-testing-modular.repo
[root@centos8 yum.repos.d]# cd
[root@centos8 ~]# 
[root@centos8 ~]# dnf clean all
[root@centos8 ~]# dnf makecache 

//安装开发工具包
[root@centos8 ~]# yum groups mark install 'Development Tools'

 //创建apache用户和组
[root@centos8 ~]# groupadd -r apache
[root@centos8 ~]# useradd -r -M -s /sbin/nologin -g apache apache

//安装依赖包
[root@centos8 ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make vim wget --allowerasing
//下载和安装apr以及apr-util
[root@centos8 ~]# wget https://downloads.apache.org/apr/apr-1.7.0.tar.gz
[root@centos8 ~]# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz

[root@centos8 ~]# tar xf apr-1.7.0.tar.gz 
[root@centos8 ~]# tar xf apr-util-1.6.1.tar.gz 
[root@centos8 ~]# 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
[root@centos8 ~]# cd apr-1.7.0/
[root@centos8 apr-1.7.0]# vi configure
 cfgfile=${ofile}T
    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
    #$RM "$cfgfile"            //删除这行或者注释掉

[root@centos8 apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@centos8 apr-1.7.0]# make && make install
[root@centos8 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@centos8 apr-util-1.6.1]# make
[root@centos8 apr-util-1.6.1]# make install
[root@centos8 apr-util-1.6.1]# ls /usr/local/
apr       bin  games    lib    libexec  share
apr-util  etc  include  lib64  sbin     src

​```text
//编译安装httpd
[root@centos8 ~]# wget https://downloads.apache.org/httpd/httpd-2.4.54.tar.gz

[root@centos8 src]# tar xf httpd-2.4.54.tar.gz
[root@centos8 src]# cd httpd-2.4.54/
[root@centos8 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

//编译安装
[root@centos8 httpd-2.4.54]# make && make install

//配置httpd
[root@centos8 ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh
[root@centos8 ~]# source /etc/profile.d/httpd.sh 
[root@centos8 ~]# ln -s /usr/local/apache/include/ /usr/include/httpd
[root@centos8 ~]# echo 'MANPATH /usr/local/apache/man' >> /etc/man.config
//配置开机自启
[root@centos8 ~]# cd /usr/lib/systemd/system

[root@centos8 system]# cp sshd.service httpd.service
[root@centos8 system]# vim httpd.service 
[root@centos8 system]# cat httpd.service 
[Unit]
Description=web server daemoni
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@centos8 ~]# systemctl daemon-reload
[root@centos8 ~]# systemctl restart httpd.service 
[root@centos8 ~]# systemctl enable httpd.service 
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@centos8 ~]# systemctl status httpd.service 
● httpd.service - web server daemoni
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor >
   Active: active (running) since Tue 2022-08-02 20:21:00 CST; 18s ago
     Docs: man:httpd
 Main PID: 49180 (httpd)
    Tasks: 6 (limit: 11175)
   Memory: 4.3M
   CGroup: /system.slice/httpd.service
           ├─49180 /usr/local/apache/bin/httpd -k start
           ├─49201 /usr/local/apache/bin/httpd -k start
           ├─49202 /usr/local/apache/bin/httpd -k start
           ├─49203 /usr/local/apache/bin/httpd -k start
           ├─49204 /usr/local/apache/bin/httpd -k start
           └─49205 /usr/local/apache/bin/httpd -k start
###  安装mysql

​```text
//安装依赖包
[root@centos8 ~]# -y install ncurses-devel openssl-devel openssl cmake mariadb-devel

//创建用户
[root@centos8 ~]# groupadd -r -g 306 mysql
[root@centos8 ~]# useradd -r -M -s /sbin/nologin -g 306 -u 306 mysql

//下载MySQL软件包(由于我提前下好了就不演示了)

//解压软件至/usr/local/
[root@centos8 src]# tar xf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
[root@centos8 src]# cd /usr/local/
[root@centos8 local]# 
[root@centos8 local]# ln -sv mysql-5.7.38-linux-glibc2.12-x86_64/ mysql
'mysql' -> 'mysql-5.7.38-linux-glibc2.12-x86_64/

//修改目录/usr/local/mysql的属主属组
[root@centos8 ~]# chown -R mysql.mysql /usr/local/mysql
[root@centos8 ~]# ll /usr/local/mysql -d
lrwxrwxrwx. 1 mysql mysql 36 Aug  2 20:33 /usr/local/mysql -> mysql-5.7.38-linux-glibc2.12-x86_64/

//添加环境变量
[root@centos8 ~]# ls /usr/local/mysql
bin  docs  include  lib  LICENSE  man  README  share  support-files
[root@centos8 ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@centos8 ~]# . /etc/profile.d/mysql.sh
[root@centos8 ~]# echo $PATH
/usr/local/mysql/bin:/usr/local/apache/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

//建立数据存放目录
[root@centos8 ~]# mkdir /opt/data
[root@centos8 ~]# chown -R mysql.mysql /opt/data/
[root@centos8 ~]# ll /opt/
total 0
drwxr-xr-x. 2 mysql mysql 6 Aug  2 20:36 data
[root@centos8 ~]# 
//初始化数据库
[root@centos8 ~]# /usr/local/mysql/bin/mysqld --initialize --user=mysql --datadir=/opt/data/
2022-08-02T12:37:38.118341Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-08-02T12:37:38.316308Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-08-02T12:37:38.389194Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-08-02T12:37:38.457415Z 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: e495e040-125f-11ed-8af1-000c29205929.
2022-08-02T12:37:38.458556Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-08-02T12:37:38.736534Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-08-02T12:37:38.736570Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-08-02T12:37:38.736911Z 0 [Warning] CA certificate ca.pem is self signed.
2022-08-02T12:37:38.796007Z 1 [Note] A temporary password is generated for root@localhost: /jHakWcwW9up

//请注意,这个命令的最后会生成一个临时密码,此处密码是/jHakWcwW9up
//再次注意,这个密码是随机的,你的不会跟我一样,一定要记住这个密码,因为一会登录时会用到


//配置mysql
[root@centos8 ~]# ln -sv /usr/local/mysql/include/ /usr/local/include/mysql'/usr/local/include/mysql' -> '/usr/local/mysql/include/'
[root@centos8 ~]# echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
[root@centos8 ~]# ldconfig

//生成配置文件
[root@centos8 ~]# vim /etc/my.cnf
[root@centos8 ~]# 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@centos8 ~]# cp -a /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@centos8 ~]# sed -ri 's#^(basedir=).*#\1/usr/local/mysql#g' /etc/init.d/mysqld
[root@centos8 ~]# sed -ri 's#^(datadir=).*#\1/opt/data#g' /etc/init.d/mysqld

//启动mysql
[root@centos8 ~]# service mysqld start 
Starting MySQL.Logging to '/opt/data/centos8.err'.
 SUCCESS! 
[root@centos8 ~]# ps -ef|grep mysql
root       51882       1  0 20:44 pts/0    00:00:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/opt/data --pid-file=/opt/data/mysql.pid
mysql      52070   51882  1 20:44 pts/0    00:00:00 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/opt/data --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=centos8.err --pid-file=/opt/data/mysql.pid --socket=/tmp/mysql.sock --port=3306
root       52102    1661  0 20:44 pts/0    00:00:00 grep --color=auto mysq

//修改密码
//使用临时密码登录
[root@centos8 ~]# mysql -uroot -p/jHakWcwW9up
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.38

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

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

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

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


安装php

//下载php
[root@centos8 ~]# wget https://www.php.net/distributions/php-8.0.21.tar.xz

//下载依赖包
[root@centos8 ~]# 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 php-mysqlnd

//编译安装php
[root@centos8 ~]# tar xf php-8.0.21.tar.xz 
[root@centos8 src]# cd php-8.0.21/

[root@centos8 php-8.0.21]#./configure --prefix=/usr/local/php7  \
--with-config-file-path=/etc \
--enable-fpm \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-openssl \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--enable-exif  \
--enable-ftp \
--enable-gd \
--with-jpeg  \
--with-zlib-dir \
--with-freetype \
--with-gettext \
--enable-json \
--enable-mbstring \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-readline \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--with-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-pcntl \
--enable-posix
[root@localhost php-8.0.21]# make -j $(cat /proc/cpuinfo |grep processor|wc -l)
[root@centos8 php-8.0.21]# make install

//安装后配置
[root@centos8 php-8.0.21]# echo 'export PATH=/usr/local/php7/bin:$PATH' > /etc/profile.d/php7.sh
[root@centos8 php-8.0.21]# source /etc/profile.d/php7.sh
[root@centos8 php-8.0.21]# which php
/usr/local/php7/bin/php
[root@centos8 php-8.0.21]# php -v
PHP 8.0.21 (cli) (built: Aug  2 2022 22:08:07) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.21, Copyright (c) Zend Technologies

//配置php-fpm
[root@centos8 php-8.0.21]# cp php.ini-production /etc/php.ini
cp: overwrite '/etc/php.ini'? yes
[root@centos8 php-8.0.21]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@centos8 php-8.0.21]# chmod +x /etc/rc.d/init.d/php-fpm
[root@centos8 php-8.0.21]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
[root@centos8 php-8.0.21]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf

//编辑php-fpm的配置文件(/usr/local/php7/etc/php-fpm.conf):
//配置fpm的相关选项为你所需要的值:
[root@localhost ~]# vim /usr/local/php7/etc/php-fpm.conf
.....
.....
pm.max_children = 50    ;最多同时提供50个进程提供50个并发服务
pm.start_servers = 5    ;启动时启动5个进程
pm.min_spare_servers = 2    ;最小空闲进程数
pm.max_spare_servers = 8    ;最大空闲进程数

[root@centos8 ~]# tail /usr/local/php7/etc/php-fpm.conf
; used in logs and stats. There is no limitation on the number of pools which
; FPM can handle. Your system will tell you anyway :)

; Include one or more files. If glob(3) exists, it is used to include a bunch of
; files from a glob(3) pattern. This directive can be used everywhere in the
; file.
; 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@centos8 ~]# service php-fpm start 
Starting php-fpm  done
[root@centos8 ~]# ss -anlt
State   Recv-Q   Send-Q     Local Address:Port     Peer Address:Port  Process  
LISTEN  0        128              0.0.0.0:22            0.0.0.0:*              
LISTEN  0        128            127.0.0.1:9000          0.0.0.0:*              
LISTEN  0        128                 [::]:22               [::]:*              
LISTEN  0        80                     *:3306                *:*              
LISTEN  0        128                    *:80                  *:*              
[root@centos8 ~]# 

[root@centos8 ~]# ps -ef | grep php
root      230541       1  0 22:30 ?        00:00:00 php-fpm: master process (/usr/local/php7/etc/php-fpm.conf)
nobody    230542  230541  0 22:30 ?        00:00:00 php-fpm: pool www
nobody    230543  230541  0 22:30 ?        00:00:00 php-fpm: pool www
nobody    230544  230541  0 22:30 ?        00:00:00 php-fpm: pool www
nobody    230545  230541  0 22:30 ?        00:00:00 php-fpm: pool www
nobody    230546  230541  0 22:30 ?        00:00:00 php-fpm: pool www
root      230549    1661  0 22:31 pts/0    00:00:00 grep --color=auto php
[root@centos8 ~]# 

3.4 配置apache

3.4.1 启用代理模块

在apache httpd 2.4以后已经专门有一个模块针对FastCGI的实现,此模块为mod_proxy_fcgi.so,它其实是作为mod_proxy.so模块的扩展,因此,这两个模块都要加载,编辑httpd.conf文件,取消以下两行内容的注释:

  • LoadModule proxy_module modules/mod_proxy.so
  • LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
//启用httpd的相关模块
[root@localhost ~]# sed -i '/proxy_module/s/#//g' /etc/httpd24/httpd.conf
[root@localhost ~]# sed -i '/proxy_fcgi_module/s/#//g' /etc/httpd24/httpd.conf

3.4.2 配置虚拟主机

在需要使用fcgi的虚拟主机中添加类似如下两行:

ProxyRequests Off       //关闭正向代理
ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/PATH/TO/DOCUMENT_ROOT/$1

例如:

ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/var/www/html/idfsoft.com/$1

以上设置表示把以.php结尾的文件请求发送到php-fpm进程,php-fpm至少需要知道运行的目录和URI,所以这里直接在fcgi://127.0.0.1:9000后指明了这两个参数,其它参数的传递已经被mod_proxy_fcgi.so进行了封装,不需要手动指定。

注意:

这里写的/var/www/html/是yum源安装方式生成的网页存放目录,这里必须改成你编译安装指定的网页存放路径,禁止直接复制我这里的路径
这里的idfsoft.com是域名,你必须改成你所使用的域名,禁止直接复制此处的域名
这里的$1表示匹配所有以.php结尾的http请求

[root@centos8 ~]# cd /usr/local/apache/conf/
[root@centos8 conf]# vim httpd.conf              //下面两行取消注释
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

//创建虚拟主机目录并生成php测试页面
[root@centos8 ~]# cd /usr/local/apache/htdocs/
[root@centos8 htdocs]# vim /usr/local/apache/htdocs/runtime/index.php
[root@centos8 htdocs]# mkdir -p /usr/local/apache/htdocs/runtime/
[root@centos8 htdocs]# vim /usr/local/apache/htdocs/runtime/index.php

[root@centos8 htdocs]# cat /usr/local/apache/htdocs/runtime/index.php 
<?php
    phpinfo();
?>

[root@centos8 [htdocs]# chown -R apache.apache /usr/local/apache/htdocs/runtime/
us	
//在配置文件的最后加入以下内容
[root@centos8 conf]# cd extra/
[root@centos8 extra]# ls
httpd-autoindex.conf  httpd-languages.conf           httpd-ssl.conf
httpd-dav.conf        httpd-manual.conf              httpd-userdir.conf
httpd-default.conf    httpd-mpm.conf                 httpd-vhosts.conf
httpd-info.conf       httpd-multilang-errordoc.conf  proxy-html.conf
[root@centos8 extra]# vim httpd-vhosts.conf 
[root@centos8 extra]# cat httpd-vhosts.conf
<VirtualHost *:80>
    DocumentRoot "/usr/local/apache/docs/runtime"
    ServerName runtime.example.com
    ErrorLog "logs/runtime.example.com-error_log"
    CustomLog "logs/runtime.example.com-access_log" common
    ProxyRequests Off
    ProxyPassMatch ^/(.*\.php)$ fcgi://127.0.0.1:9000/usr/local/apache/htdocs/runtime/$1
    <Directory "/usr/local/apache/htdocs/runtime">
        Options none
        AllowOverride none
        Require all granted
    </Directory>
</VirtualHost>

[root@centos8 extra]# cd ..
[root@centos8 conf]# vim httpd.conf  //添加最后两行
 AddType application/x-compress .Z
 AddType application/x-gzip .gz .tgz
 AddType application/x-httpd-php .php
 AddType application/x-httpd-php-source .phps
 
//将这行取消注释
Include conf/extra/httpd-vhosts.conf

//这中间添加index.php
<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>


3.5 验证

1.修改/etc/hosts文件,添加域名与IP的映射
2.在浏览器上使用域名访问,若看到以下界面则表示lamp架构搭建成功,否则请检查你的操作

解压安装phpmyadmin

[root@centos8 runtime]# uzip phpMyAdmin-5.2.0-all-languages.zip
[root@centos8 runtime]# ls
phpMyAdmin-5.2.0-all-languages  phpMyAdmin-5.2.0-all-languages.zip
[root@centos8 runtime]# mv phpMyAdmin-5.2.0-all-languages.zip /tmp/
[root@centos8 runtime]# ls
phpMyAdmin-5.2.0-all-languages
[root@centos8 runtime]# mv phpMyAdmin-5.2.0-all-languages/ phpmyadmin
[root@centos8 runtime]# cd phpmyadmin/
[root@centos8 phpmyadmin]# ls
babel.config.json      examples     package.json            templates
ChangeLog              favicon.ico  README                  themes
composer.json          index.php    RELEASE-DATE-5.2.0      url.php
composer.lock          js           robots.txt              vendor
config.sample.inc.php  libraries    setup                   yarn.lock
CONTRIBUTING.md        LICENSE      show_config_errors.php
doc                    locale       sql
[root@centos8 phpmyadmin]# cp config.sample.inc.php config.inc.php
[root@centos8 phpmyadmin]# systemctl restat httpd.service 

演示

 )

posted on 2022-08-03 09:02  wjh0077  阅读(7)  评论(0编辑  收藏  举报