DISCUZ!建站总结

centos 7.5 dixcuz 3.4安装:
数据库 mariadb:
找到不错的连接:https://www.jianshu.com/p/02aefc2798c4
title: CentOS7安装配置MariaDB
categories: 数据库
tags:

  • MariaDB
  • MySQL
    timezone: Asia/Shanghai
    date: 2019-01-06

环境
[root@localhost mysql]# cat /etc/centos-release
CentOS Linux release 7.5.1804 (Core)

[root@localhost mysql]# mysql -V
mysql Ver 15.1 Distrib 5.5.60-MariaDB, for Linux (x86_64) using readline 5.1
(一).安装mysql
yum install mariadb mariadb-server mariadb-libs mariadb-devel -y

检查安装结果
rpm -qa |grep mariadb
[root@localhost ~]# rpm -qa |grep mariadb
mariadb-5.5.60-1.el7_5.x86_64
mariadb-server-5.5.60-1.el7_5.x86_64
mariadb-libs-5.5.60-1.el7_5.x86_64
mariadb-devel-5.5.60-1.el7_5.x86_64

启动并设置开机自动启动

systemctl start mariadb
systemctl status mariadb
systemctl enable mariadb
(二).初始化数据库设置
输入root密码,没有密码直接回车

[root@localhost ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we’ll need the current
password for the root user. If you’ve just installed MariaDB, and
you haven’t set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on…
提示设置root user密码,Y

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables…
… Success!
删除系统创建的默认匿名用户:Y

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
… Success!
禁止root用户远程登录:Y

Normally, root should only be allowed to connect from ‘localhost’. This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
… Success!
是否删除系统创建的test数据库,生产环境建议删除

By default, MariaDB comes with a database named ‘test’ that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] n
… skipping.
重载权限表:Y

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

完成

Cleaning up…

All done! If you’ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
(三).mariadb的简单应用
mariadb命令后边一定要加;结尾

登录mariadb
mysql -u root -p
查看都有哪些数据库表
MariaDB [(none)]> show databases;
±-------------------+
| Database |
±-------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
±-------------------+
4 rows in set (0.00 sec)
mysql的密码都在mysql这个库里面,有一张表叫user,这里管理了可以登陆数据库的用户

常用命令及示例!
use mysql; ##切换到mysql数据库
show tables; ##显示本数据库有哪些表
SELECT User,Host,Password FROM mysql.user; ##查询mysql数据库的user表
desc mysql.user; ##查询user表结构
flush privileges; ##刷新数据库
创建一个新的数据库并对这个表做相应操作
以下操作包含了:创建一个数据库、切换到某数据库、创建一个表、插入表的两种方法、更新一行数据、删除一行数据

create database test;
use test;
create table linux(username varchar(15) not null,password varchar(15) not null);
insert into linux values (‘XiaoMing’, ‘xiaoliu’);
insert into linux values (‘XiaoHong’, ‘12346’), (‘HongHong’, ‘12346’);
update linux set password = ‘112233’ where username = ‘honghong’
delete from linux where password=‘112233’
高级命令,慎用@@@@
#删除数据库
drop database <数据库名>;
#删除表
DROP TABLE 表名;
安装命令自动补全工具 MYCLI
yum -y install epel-release python-pip python-devel
yum clean all
pip install mycli

命令使用:
mycli #连接本机可以直接输入命令后回车
mycli -h localhost -u root
mycli -h 192.168.0.61 -u root
开启服务器的远程访问
这里改的密码跟本地登录的密码不是一个,虽然是一个账户

允许所有IP使用root用户远程登录,并将密码改为my-new-password

GRANT ALL PRIVILEGES ON . TO ‘root’@’%’ IDENTIFIED BY ‘my-new-password’ WITH GRANT OPTION;
只允许192.168.0.*段的IP地址使用root用户远程登录,并将密码改为my-new-password

GRANT ALL PRIVILEGES ON . TO ‘root’@‘192.168.0.%’ IDENTIFIED BY ‘my-new-password’ WITH GRANT OPTION;
使用脚本备份 数据库,将以下部分存为.sh并+x权限执行即可
#!/bin/bash

mysql用户名

db_user=“root”

mysql密码

db_passwd=“xiaoliu”

要备份的数据库名称

db_name=“test”

备份位置

backup_dir="/home/mysqlbak"

文件名设置为时间格式

time="$(date +"%Y%m%d%H%M%S")"

mysqldump -u d b u s e r − p db_user -p dbuserpdb_passwd d b n a m e > " db_name > " dbname>"backup_dir/ d b n a m e " " db_name"_" dbname""time.sql"

#备份test库
#mysqldump -uroot -pxiaoliu test > “/home/test”_"$(date +"%Y%m%d%H%M%S").sql"

#备份所有数据库
#mysqldump -uroot -pxiaoliu --opt --all-databases > “/home/mysqlbak/all-databases”_"$(date +"%Y%m%d%H%M%S").sql"

作者:小六的昵称已被使用
链接:https://www.jianshu.com/p/02aefc2798c4
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

lamp环境搭建:
安装 Apache 组件
使用 yum 安装 Apache 组件:

yum install httpd -y
安装之后,启动 httpd 进程:

service httpd start
把 httpd 也设置成开机自动启动:

chkconfig httpd on
安装 PHP
使用 yum 安装 PHP:[?]

yum install php php-fpm php-mysql -y
安装之后,启动 PHP-FPM 进程:

service php-fpm start
启动之后,可以使用下面的命令查看 PHP-FPM 进程监听哪个端口 [?]

netstat -nlpt | grep php-fpm
把 PHP-FPM 也设置成开机自动启动:

chkconfig php-fpm on

CentOS 6 默认已经安装了 PHP-FPM 及 PHP-MYSQL,下面命令执行的可能会提示已经安装。

PHP-FPM 默认监听 9000 端口

安装并配置 Discuz
任务时间:15min ~ 30min

安装 Discuz
CentOS 6 没有Discuz 的 yum 源,所以我们需要下载一个Discuz 压缩包:[?]

wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip
下载完成后,解压这个压缩包

unzip Discuz_X3.2_SC_UTF8.zip
解压完后,就能在 upload 文件夹里看到discuz的源码了

到Discuz官网找一个安装包并复制安装包下载路径,这里我们用 Discuz_X3.2_SC_UTF8.zip

配置 Discuz
由于PHP默认访问 /var/www/html/ 文件夹,所以我们需要把upload文件夹里的文件都复制到 /var/www/html/ 文件夹

cp -r upload/* /var/www/html/
给 /var/www/html 目录及其子目录赋予权限

chmod -R 777 /var/www/html
重启 Apache

service httpd restart

DISCUZ!论坛管理员无法登录后台的各种解决方法总结
网站目录下config目录下config_global.php 中找到

  1. 取消ip认证

config_global.php 中找到

$_config[‘admincp’][‘checkip’] = 0

  1. (直接在右上角那里点登录不行的。)然后从注册那里进入已有帐号登录,登录就可以了。
  2. 我发现直接安装好。什么都不弄就安装好了。这样就可以登录了。
  3. 登录管理中心出现错误如下:
  4. 您当前的访问请求当中含有非法字符,已经被系统拒绝
  5. 用一下这个https://blog.csdn.net/lih062624/article/details/69388016
  6. 解决方案如下:

\source\class\discuz的discuz_application.php
查找

private function _xss_check() {
static KaTeX parse error: Can't use function '\'' in math mode at position 31: …"', '>', '<', '\̲'̲', '(', ')', 'C…_GET[‘formhash’]) && G E T [ ′ f o r m h a s h ′ ] ! = = f o r m h a s h ( ) ) s y s t e m e r r o r ( ′ r e q u e s t t a i n t i n g ′ ) ; i f ( _GET['formhash'] !== formhash()) { system_error('request_tainting'); } if( GET[formhash]!==formhash())systemerror(requesttainting);if(_SERVER[‘REQUEST_METHOD’] == ‘GET’ ) {
$temp = KaTeX parse error: Expected 'EOF', got '}' at position 26: …EQUEST_URI']; }̲ elseif(empty (_GET[‘formhash’])) {
$temp = $_SERVER[‘REQUEST_URI’].file_get_contents(‘php://input’);
} else {
KaTeX parse error: Expected 'EOF', got '}' at position 13: temp = ''; }̲ if(!empty(temp)) {
t e m p = s t r t o u p p e r ( u r l d e c o d e ( u r l d e c o d e ( temp = strtoupper(urldecode(urldecode( temp=strtoupper(urldecode(urldecode(temp)));
foreach ($check as KaTeX parse error: Expected '}', got 'EOF' at end of input: … if(strpos(temp, $str) !== false) {
system_error(‘request_tainting’);
}
}
}
return true;
}

替换为:

private function _xss_check() {
t e m p = s t r t o u p p e r ( u r l d e c o d e ( u r l d e c o d e ( temp = strtoupper(urldecode(urldecode( temp=strtoupper(urldecode(urldecode(_SERVER[‘REQUEST_URI’])));
if(strpos( t e m p , ′ < ′ ) ! = = f a l s e ∣ ∣ s t r p o s ( temp, '<') !== false || strpos( temp,<)!==falsestrpos(temp, ‘"’) !== false || strpos($temp, ‘CONTENT-TRANSFER-ENCODING’) !== false) {
system_error(‘request_tainting’);
}
return true;

————————————————
版权声明:本文为CSDN博主「土著人宁巴」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lih062624/article/details/69388016
9.
可以解决。Ok
10. 好像有php版本太低的问题:
10.刚升级了:https://www.cnblogs.com/ivy-zheng/p/11051574.html
Centos7 升级php版本到php7
一、首先查看是否有老版本

yum list installed | grep php

二、如果安装的有

yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64

三、老版本清理干净之后,进行升级

1、由于linux的yum源不存在php7.x,所以我们要更改yum源:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

CentOS7yum安装PHP7.2

CentOS7yum安装PHP7.2

2、查看yum源中有没有php7.x

yum search php7

看到下图,证明php已经存在yum源中

CentOS7yum安装PHP7.2

CentOS7yum安装PHP7.2

3、yum 安装php72w和各种拓展,选自己需要的即可:

yum -y install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml

CentOS7yum安装PHP7.2

安装完成

4、查看php版本

php -v

CentOS7yum安装PHP7.2

原文:https://jingyan.baidu.com/article/870c6fc3460834b03fe4be06.html

现在开始装SSL 要加对应的apache:

1.试一下这个:我用的 centos 7.5 lamp环境。
https://www.exchen.net/discuz-https.html 按照这个操作了,是可以SSL了。 htaccess那里操作了好像没有用。 全部操作一遍就可以了。

Discuz X3.4 开启全站 HTTPS
以 CentOS 6 为例,操作步骤如下:

(1) 安装 mod_ssl 和 openssl

yum install mod_ssl openssl

1
2
yum install mod_ssl openssl

(2) 上传证书

将 .crt 文件上传到 /etc/pki/tls/certs, .key 文件上传到 /etc/pki/tls/private。

(3) 修改 ssl.conf

vi /etc/httpd/conf.d/ssl.conf
SSLCertificateFile /etc/pki/tls/certs/2002348_www.xxxx.net_public.crt
SSLCertificateKeyFile /etc/pki/tls/private/2002348_www.xxxx.net.key

1
2
3
4
vi /etc/httpd/conf.d/ssl.conf
SSLCertificateFile /etc/pki/tls/certs/2002348_www.xxxx.net_public.crt
SSLCertificateKeyFile /etc/pki/tls/private/2002348_www.xxxx.net.key

(4) 修改 Discuz X3.4 源码

找到 source/class/discuz/discuz_application.php (约第187行处),原始内容是:

G [ ′ i s H T T P S ′ ] = ( _G['isHTTPS'] = ( G[isHTTPS]=(_SERVER[‘HTTPS’] && strtolower($_SERVER[‘HTTPS’]) != ‘off’) ? true : false;

1
2
G [ ′ i s H T T P S ′ ] = ( _G['isHTTPS'] = ( G[isHTTPS]=(_SERVER[‘HTTPS’] && strtolower($_SERVER[‘HTTPS’]) != ‘off’) ? true : false;

修改成以下内容:

G [ ′ i s H T T P S ′ ] = ( _G['isHTTPS'] = ( G[isHTTPS]=(_SERVER[‘SERVER_PORT’] == 443 || KaTeX parse error: Expected 'EOF', got '&' at position 18: …ERVER['HTTPS'] &̲amp;&amp; strto…_SERVER[‘HTTPS’]) != ‘off’) ? true : false;

1
2
G [ ′ i s H T T P S ′ ] = ( _G['isHTTPS'] = ( G[isHTTPS]=(_SERVER[‘SERVER_PORT’] == 443 || KaTeX parse error: Expected 'EOF', got '&' at position 18: …ERVER['HTTPS'] &̲amp;&amp; strto…_SERVER[‘HTTPS’]) != ‘off’) ? true : false;

找到 uc_server/avatar.php (约第13行处),原始内容是:

define(‘UC_API’, strtolower(( S E R V E R [ ′ H T T P S ′ ] = = ′ o n ′ ? ′ h t t p s ′ : ′ h t t p ′ ) . ′ : / / ′ . _SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'. SERVER[HTTPS]==on?https:http).://._SERVER[‘HTTP_HOST’].substr( S E R V E R [ ′ P H P S E L F ′ ] , 0 , s t r r p o s ( _SERVER['PHP_SELF'], 0, strrpos( SERVER[PHPSELF],0,strrpos(_SERVER[‘PHP_SELF’], ‘/’))));

1
2
define(‘UC_API’, strtolower(( S E R V E R [ ′ H T T P S ′ ] = = ′ o n ′ ? ′ h t t p s ′ : ′ h t t p ′ ) . ′ : / / ′ . _SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'. SERVER[HTTPS]==on?https:http).://._SERVER[‘HTTP_HOST’].substr( S E R V E R [ ′ P H P S E L F ′ ] , 0 , s t r r p o s ( _SERVER['PHP_SELF'], 0, strrpos( SERVER[PHPSELF],0,strrpos(_SERVER[‘PHP_SELF’], ‘/’))));

修改成以下内容:

define(‘UC_API’, strtolower(($_SERVER[‘SERVER_PORT’] == 443 || S E R V E R [ ′ H T T P S ′ ] = = ′ o n ′ ? ′ h t t p s ′ : ′ h t t p ′ ) . ′ : / / ′ . _SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'. SERVER[HTTPS]==on?https:http).://._SERVER[‘HTTP_HOST’].substr( S E R V E R [ ′ P H P S E L F ′ ] , 0 , s t r r p o s ( _SERVER['PHP_SELF'], 0, strrpos( SERVER[PHPSELF],0,strrpos(_SERVER[‘PHP_SELF’], ‘/’))));

1
2
define(‘UC_API’, strtolower(($_SERVER[‘SERVER_PORT’] == 443 || S E R V E R [ ′ H T T P S ′ ] = = ′ o n ′ ? ′ h t t p s ′ : ′ h t t p ′ ) . ′ : / / ′ . _SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'. SERVER[HTTPS]==on?https:http).://._SERVER[‘HTTP_HOST’].substr( S E R V E R [ ′ P H P S E L F ′ ] , 0 , s t r r p o s ( _SERVER['PHP_SELF'], 0, strrpos( SERVER[PHPSELF],0,strrpos(_SERVER[‘PHP_SELF’], ‘/’))));

找到 uc_server/admin.php (约第13行处),原始内容是:

define(‘UC_API’, strtolower((isset($_SERVER[‘HTTPS’]) && S E R V E R [ ′ H T T P S ′ ] = = ′ o n ′ ? ′ h t t p s ′ : ′ h t t p ′ ) . ′ : / / ′ . _SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'. SERVER[HTTPS]==on?https:http).://._SERVER[‘HTTP_HOST’].substr( S E R V E R [ ′ P H P S E L F ′ ] , 0 , s t r r p o s ( _SERVER['PHP_SELF'], 0, strrpos( SERVER[PHPSELF],0,strrpos(_SERVER[‘PHP_SELF’], ‘/’))));

1
2
define(‘UC_API’, strtolower((isset($_SERVER[‘HTTPS’]) && S E R V E R [ ′ H T T P S ′ ] = = ′ o n ′ ? ′ h t t p s ′ : ′ h t t p ′ ) . ′ : / / ′ . _SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'. SERVER[HTTPS]==on?https:http).://._SERVER[‘HTTP_HOST’].substr( S E R V E R [ ′ P H P S E L F ′ ] , 0 , s t r r p o s ( _SERVER['PHP_SELF'], 0, strrpos( SERVER[PHPSELF],0,strrpos(_SERVER[‘PHP_SELF’], ‘/’))));

修改成以下内容:

define(‘UC_API’, strtolower(($_SERVER[‘SERVER_PORT’] == 443 || S E R V E R [ ′ H T T P S ′ ] = = ′ o n ′ ? ′ h t t p s ′ : ′ h t t p ′ ) . ′ : / / ′ . _SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'. SERVER[HTTPS]==on?https:http).://._SERVER[‘HTTP_HOST’].substr( S E R V E R [ ′ P H P S E L F ′ ] , 0 , s t r r p o s ( _SERVER['PHP_SELF'], 0, strrpos( SERVER[PHPSELF],0,strrpos(_SERVER[‘PHP_SELF’], ‘/’))));

1
2
define(‘UC_API’, strtolower(($_SERVER[‘SERVER_PORT’] == 443 || S E R V E R [ ′ H T T P S ′ ] = = ′ o n ′ ? ′ h t t p s ′ : ′ h t t p ′ ) . ′ : / / ′ . _SERVER['HTTPS'] == 'on' ? 'https' : 'http').'://'. SERVER[HTTPS]==on?https:http).://._SERVER[‘HTTP_HOST’].substr( S E R V E R [ ′ P H P S E L F ′ ] , 0 , s t r r p o s ( _SERVER['PHP_SELF'], 0, strrpos( SERVER[PHPSELF],0,strrpos(_SERVER[‘PHP_SELF’], ‘/’))));

(5) 后台设置 HTTPS 链接

后台 -> 全局 -> 站点 URL,改为HTTPS

后台 -> 站长 -> UCenter 设置 -> UCenter 访问地址,改为HTTPS

UCenter 后台 -> 应用管理 -> 应用的主 URL,改为HTTPS

(6) HTTP 重定向到 HTTPS,主要目的是为了让 HTTP 的访问链接,重定向到 HTTPS。

修改 /etc/httpd/conf/httpd.conf,查看 mod_rewrite 是否开启

LoadModule rewrite_module modules/mod_rewrite.so

1
2
LoadModule rewrite_module modules/mod_rewrite.so

在网站根目录 /var/www/html,新建 .htaccess,添加内容如下:

1
2
3
4
5
6
7

如果 .htaccess 重定向没作用的话,打开 /etc/httpd/conf/httpd.conf,找到 Directory,将 AllowOverride None 改成 AllowOverride All,信息如下:

<Directory “/var/www/html”>

#AllowOverride None
AllowOverride All

1
2
3
4
5
6
<Directory “/var/www/html”>

#AllowOverride None
AllowOverride All

最后重启 httpd

service httpd restart

1
2
service httpd restart

转载请注明:exchen’s blog » Discuz X3.4 开启全站 HTTPS

要把这些操作全部操作完一遍才行。不然不行的。

3.所有网页重定向到https 用了这个搞定了。
https://www.jianshu.com/p/9aafe1cdd377
首先在httpd.conf中配置如下:
打开Apache重写模块(把#号去掉):

LoadModule rewrite_module modules/mod_rewrite.so
然后修改Directory里的内容,注意是修改标签包含自己项目路径的配置项

DocumentRoot “E:/wsp/www”
<Directory “E:/wsp/www”>
Options Indexes FollowSymLinks
AllowOverride All
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
Require all granted

在bin目录中打开cmd运行 httpd -t 如果语法没错就重启Apache就成功了

作者:洛阳醉长安行
链接:https://www.jianshu.com/p/9aafe1cdd377
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

锁还没有换过来
后面试了一下把discuz_application.php (/var/www/html/source/class/discuz) 这里面的:
G [ ′ i s H T T P S ′ ] = ( _G['isHTTPS'] = ( G[isHTTPS]=(_SERVER[‘SERVER_PORT’] == 443 || KaTeX parse error: Expected 'EOF', got '&' at position 18: …ERVER['HTTPS'] &̲& strtolower(_SERVER[‘HTTPS’]) != ‘true’) ? true : false;

这里面的OFF 改成了True 就没有问题了。 一切终于完美了。抓紧睡了23:42
开了25端口,不知道是不是这个原因。
后面用了这个
服务器内开启465端口需要您在服务器运行对应端口服务。

并在系统防火墙中放通465端口:
iptables -I INPUT -p tcp --dport 465 -j ACCEPT

后面邮件可以正常发送了。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值