centos7安装discuz全过程(含LAMP搭建)

一、搭建LAMP环境

1、安装MySQL

  • 关闭selinux
setenforce 0
vi /etc/selinux/config,将SELINUX的值改为"disabled"
  • 下载MySQL的RPM安装文件,地址:https://dev.mysql.com/downloads/mysql​​
    centos7安装discuz全过程(含LAMP搭建)_第1张图片
    ​​​​​​​
  • 查看是否安装mysql或者mariadb:rpm -qa | grep -i mysql (rpm -qa | grep -i mariadb),如有则执行rpm -e --nodeps 卸载在这里插入图片描述
  • 解压安装包:tar -xvf mysql-5.7.39-1.el7.x86_64.rpm-bundle.tar
  • 依次安装各个组件
rpm -ivh mysql-community-common-5.7.39-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.39-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-compat-5.7.39-1.el7.x86_64.rpm 
rpm -ivh mysql-community-client-5.7.39-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.39-1.el7.x86_64.rpm
  • 创建MySQL数据目录和日志目录等文件,配置MySQL各个参数
cd /
mkdir mysql
cd mysql
mkdir data
mkdir mysql-bin
chown -R mysql /mysql
chgrp -R mysql /mysql
  • vim /etc/my.cnf,注意文件格式,可用nodepad++使用linux字符集来编辑
[mysqld]
datadir=/mysql/data
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
log-bin=/mysql/mysql-bin/mysql-bin
server-id=1
binlog_format=ROW
max_connections=200
default-storage-engine=INNODB
character-set-server=utf8
explicit_defaults_for_timestamp=true

[mysql]
default-character-set=utf8

[client]
port=3306
default-character-set=utf8
  • MySQL命令
启动MySQL:systemctl start mysqld.service
查看MySQL:systemctl status mysqld.service
关闭MySQL:systemctl stop mysqld.service
  • 设置MySQL开机自启动
systemctl enable mysqld.service
  • 查看默认密码:grep ‘temporary password’ /var/log/mysqld.log
  • 使用密码登录:mysql -uroot -p
  • 更改密码策略
set global validate_password_policy=0; 
set global validate_password_length=6;
  • 修改默认密码
set password for root@localhost=password('hyc@2022');
  • 授予远程访问权限
grant all privileges on *.* to root@'%' identified by 'hyc@2022';
  • 刷新权限
flush privileges;

2、安装Apache

  • 安装
yum install httpd -y
  • 启动
systemctl start httpd
systemctl enable httpd.service
  • 端口暴露
firewall-cmd --permanent --zone=public --add-port=80/tcp
firewall-cmd --permanent --zone=public --add-port=80/udp
firewall-cmd --permanent --zone=public --add-port=443/tcp
firewall-cmd --permanent --zone=public --add-port=443/udp
firewall-cmd --reload
  • 测试:http://localhost/ or http://server-ip-address/centos7安装discuz全过程(含LAMP搭建)_第2张图片

3、安装PHP7.4

  • 如果遇到Another app is currently holding the yum lock; waiting for it to exit…问题,则执行rm -f /var/run/yum.pid
yum -y install epel-release
yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum -y install yum-utils
yum repolist all |grep php
yum-config-manager --enable remi-php74
yum -y install php  php-cli php-fpm php-mysql php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json php-redis
php -v
php --modules
systemctl start php-fpm.service
systemctl enable php-fpm.service
  • 测试
vi /var/www/html/testphp.php
输入如下内容
<?php 
phpinfo();
?>

浏览器访问http://ip/testphp.php
centos7安装discuz全过程(含LAMP搭建)_第3张图片

二、安装Discuz

  • 下载安装包zip文件,下载地址:https://gitee.com/3dming/DiscuzL/attach_files。参考https://blog.csdn.net/qq_62624549/article/details/124422542 https://www.dismall.com/thread-77-1-1.html
  • 解压zip文件
unzip DisXXXXXX.zip

在这里插入图片描述

  • 将upload这个目录下的所有文件上传到 /var/www/html/目录
cp -r /xxxx/upload/* /var/www/html/
  • 更改文件及文件夹权限
cd /var/www/html
chmod 757 -R data/ uc_server/ config/ uc_client/
systemctl restart httpd
  • 在浏览器中输入网址http://ip/install(LAMP服务器IP)
    centos7安装discuz全过程(含LAMP搭建)_第4张图片
    centos7安装discuz全过程(含LAMP搭建)_第5张图片centos7安装discuz全过程(含LAMP搭建)_第6张图片
    centos7安装discuz全过程(含LAMP搭建)_第7张图片
    centos7安装discuz全过程(含LAMP搭建)_第8张图片
  • 删除安装文件intall/index.php
cd install/
rm -rf index.php
  • 输入网址http://ip,即可访问论坛

你可能感兴趣的:(PHP,LAMP,linux,mysql,centos)