阿里云centOS7搭建Discuz论坛(Apache+PHP+MySQL)

连接阿里云

2021年8月初用学生身份领了阿里云免费3个月的云服务器。MacBook连接云服务器的话用ssh root@xxx.xxx.xxx.xxx(云服务器公网地址)就可以,Windows的话建议参考Xshell新手的下载及安装教程(超详细)安装Xshell进行连接。

Xshell连接步骤(Windows适用)

打开Xshell,新建会话。填写名称、主机IP地址(阿里云服务器的公网地址)。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

然后输入密码即可连接成功
在这里插入图片描述

在云主机上搭建Discuz

安装软件(Apache、PHP、MySQL)

[root@xiaoyingECS ~]# yum --disableexcludes=all install -y httpd php php-fpm php-mysql mysql
[root@xiaoyingECS ~]# rpm -Uvh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
[root@xiaoyingECS ~]# yum --disableexcludes=all install -y mysql-server

启动服务

[root@xiaoyingECS ~]# service httpd start
[root@xiaoyingECS ~]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@xiaoyingECS ~]# systemctl is-enabled httpd.service
Enabled
[root@xiaoyingECS ~]#  firewall-cmd --zone=public --add-port=80/tcp --permanent
Warning: ALREADY_ENABLED: 80:tcp
Success
[root@xiaoyingECS ~]#  firewall-cmd --reload
success
[root@xiaoyingECS ~]# systemctl restart httpd.service

[root@xiaoyingECS ~]# service php-fpm start

配置MySQL密码

[root@bogon baixiaoying]# vim /etc/my.cnf

在my.cnf的最后面添加一句 skip-grant-tables.(进入vim后按字母i进入编辑模式,然后修改文件内容。最后按Esc键退出编辑模式,输入:wq保存并退出文件回到命令行中)

[root@bogon baixiaoying]# service mysql start
Redirecting to /bin/systemctl start mysql.service
[root@xiaoyingECS ~]# mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.51 MySQL Community Server (GPL)

Copyright (c) 2000, 2021, 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> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql>  update mysql.user set password=PASSWORD('root')where User='root' ;
Query OK, 4 rows affected (0.01 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> Ctrl-C -- exit!
Aborted
[root@bogon baixiaoying]# vim /etc/my.cnf

把之前添上的 skip-grant-tables删掉

[root@bogon baixiaoying]# service mysql restart
Redirecting to /bin/systemctl start mysql.service

验证环境配置是否成功

在Apache的默认目录下新建test.php文件进行测试

[root@xiaoyingECS ~]# vim /var/www/html/test.php

在文件中写 <?php echo "<title>Test Page</title>"; phpinfo() ?>
然后浏览器中输入http://xxx.xxx.xxx.xxx/test.php(地址即写阿里云服务器公网地址)。出现以下窗口说明配置成功

在这里插入图片描述

安装Discuz

下载X3.2版本的安装包,并解压

[root@xiaoyingECS ~]# wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip
[root@xiaoyingECS ~]# unzip Discuz_X3.2_SC_UTF8.zip

把解压后的 “upload” 文件夹下的所有文件复制到 "/var/www/html/"目录下

[root@xiaoyingECS ~]# cp -r upload/* /var/www/html/

赋予该文件夹root读写权限

[root@xiaoyingECS ~]# chmod -R 777 /var/www/html

论坛环境搭建成功,开始安装

  • 在浏览器输入http://xxx.xxx.xxx.xxx(地址即写阿里云服务器公网地址)
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
  • 输入之前设置的密码root

在这里插入图片描述

  • 完成后可进入Discuz论坛界面

在这里插入图片描述

其他

关于彻底卸载httpd、PHP、MySQL

先用 yum remove [包名]进行卸载,然后用 rpm -aq | grep [包名]查看还有什么残留文件,用 rpm -e [文件名]的方式删除。直到 rpm -aq | grep [包名]后没有返回值。
其中MySQL需要这样:

[root@xiaoyingECS ~]# yum remove mysql mysql-server mysql-libs compat-mysql51 
[root@xiaoyingECS ~]# rm -rf /var/lib/mysql 
[root@xiaoyingECS ~]# rm /etc/my.cnf

然后再用 rpm -aq | grep mysql删除残留文件

关于文件“不可写”、“目录不存在”

在这里插入图片描述
这个其实是在centOS虚拟机上试搭建的时候出现的问题。跟防火墙有关

[root@bogon ~]# vim /etc/selinux/config

SELINUX=enforcing这句屏蔽掉,下面写SELINUX=disabled,然后把虚拟机重启,重新进入discuz安装界面即可

参考网址:
1 在CentOS7中—搭建Discuz 论坛
2 Centos7 下安装Apache2 + MySQL + PHP7
3 Centos6.4成功搭建LAMP+Discuz

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值