LAMP 环境搭建 yum源安装方式 (Apache 2.4.6 +mysql 8.0.28+php 8.1.3)

一、安装Apache 2.4

1.1关闭seinux

vim /etc/selinux/config

#SELINUX=enforcing      #注释掉

#SELINUXTYPE=targeted  #注释掉

SELINUX=disabled       #增加

:wq! #保存退出

getenforce         #查看SEliunx状态

1.2安装之前先检查一下系统是否有默认安装的apache,如有删除

yum update -y

 rpm -qa | grep httpd

 rpm -e  ***(包名)   #删除已有包

1.3安装必备包

yum install gcc gcc-c++ pcre pcre-devel -y

yum groupinstall "Development tools" -y

yum install  pcre-devel  expat-devel zlib zlib-devel  openssl-devel  expat-devel  -y

1.4更新源安装apache

yum install httpd -y

1.5配置ServerName

vim /etc/httpd/conf/httpd.conf 搜索

ServerName关键字 去掉开头的#号,将www.example.com替换为localhost

1.6 启动服务并设置开机自启

systemctl start httpd.service

systemctl enable httpd.service

二、安装Mysql 8.0.28

2.1  删除系统已有的数据库

rpm -qa | grep mysql

yum remove mysql-xxx-xxx-

rpm -qa | grep mariadb

rpm -e --nodeps  mariadb-libs-5.5.68-1.el7.x86_64

2.1  下载mysql 8.0 官方yum源

wget https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm

yum localinstall   mysql80-community-release-el7-5.noarch.rpm -y

2.3 更新yum源

yum clean all

yum makecache

2.4 安装mysql 并启动sql服务

yum install mysql-community-server -y

systemctl start mysqld

2.5 更改mysql默认的随机密码

查看默认密码

cat /var/log/mysqld.log | grep password

mysql -u root -p 输入随机的密码进行修改

ALTER USER 'root'@'localhost' IDENTIFIED BY 'Test@#1';

三 、安装php8.1.3

3.1 安装之前先检查一下系统是否有默认安装的php,如有删除

rpm -qa|grep php

rpm -e  ***(包名)   #删除已有包

3.2 将yum源更换为aliyun的remi

yum install epel-releas

yum -y install https://mirrors.aliyun.com/remi/enterprise/remi-release-7.rpm

yum -y install yum-utils

3.3 查询可安装的PHP包版本

yum repolist all |grep php

3.4 安装php8.1.3 并查看版本

yum-config-manager --enable remi-php81

sudo yum install -y php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-json php-redis  --skip-broken

php -v

四、配置apache 解析php

4.1 vim /etc/httpd/conf/httpd.conf (添加解析信息)

找到AddType application/x-gzip .gz .tgz 在下面添加

AddType application/x-httpd-php .php .phtml

AddType application/x-httpd-php-source .phps

找到 LoadModule 在后面追加

LoadModule rewrite_module modules/mod_rewrite.so

找到 DirectoryIndex 在中间添加

DirectoryIndex  index.php  index.html

4.2  vim测试PHP

vim /var/www/html/index.php  (添加php配置信息文档)

phpinfo();
?>

4.3  systemctl restart httpd  #重启httpd服务

4.4  systemctl restart php-fpm #重启php服务

五、安装phpMyAdmin

1、下载phpMyadmin 安装包

wget

https://files.phpmyadmin.net/phpMyAdmin/5.1.3/phpMyAdmin-5.1.3-all-languages.tar.gz

2、解压安装包

tar xf  phpMyAdmin-5.1.3-all-languages.tar.gz

3、将phpMyAdmin-5.1.3-all-languages 拷贝至Apache 网站目录

mv phpMyAdmin-5.1.3-all-languages /usr/local/apache/htdocs/phpmyadmin

4、根据需求修改配置文件

vim /usr/local/apache/htdocs/phpmyadmin/libraries/config.default.php

你可能感兴趣的:(mysql,apache,php)