部署discuz并使用redis加速
1.部署LNMP环境
1.1.准备yum环境
[root@jiangxl ~]# rm -rf /etc/yum.repos.d/* [root@jiangxl ~]# curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo ;curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
1.2.部署nginx
[root@jiangxl ~]# yum -y install nginx [root@jiangxl ~]# vim /etc/nginx/nginx.conf user nginx;
1.3.部署mysql
1.安装mysql [root@jiangxl ~]# rpm -ivh http://repo.mysql.com/yum/mysql-5.6-community/el/7/x86_64/mysql-community-release-el7-5.noarch.rpm [root@jiangxl ~]# yum -y install mysql-community-server 2.启动mysql [root@jiangxl ~]# systemctl start mysqld [root@jiangxl ~]# systemctl enable mysqld 3.修改mysql root密码 [root@jiangxl ~]# mysqladmin -uroot password '123456' 4.开启mysql远程访问 [root@jiangxl ~]# mysql -uroot -p123456 mysql> grant all privileges on *.* to 'root'@'%' identified by '123456' with grant option;
1.4.部署php
1.部署php [root@jiangxl ~]# wget http://mirror.webtatic.com/yum/el7/webtatic-release.rpm [root@jiangxl ~]# yum -y localinstall webtatic-release.rpm [root@jiangxl ~]# yum -y install php71w php71w-cli php71w-common php71w-devel php71w-embedded php71w-gd php71w-mcrypt php71w-mbstring php71w-pdo php71w-xml php71w-fpm php71w-mysqlnd php71w-opcache php71w-pecl-memcached php71w-pecl-redis php71w-pecl-mongodb 2.修改php程序属主 [root@jiangxl ~]# vim /etc/php-fpm.d/www.conf user = nginx group = nginx 3.启动 [root@jiangxl ~]# systemctl restart php-fpm [root@jiangxl ~]# systemctl enable php-fpm
1.5.测试lnmp是否可用
1.开启nginx连接php [root@jiangxl ~]# vim /etc/nginx/conf.d/discuz.conf server { listen 81; server_name jiangxl.discuz.com; root /data/discuz; index index.php index.html; location ~ \.php$ { root /data/discuz; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } 2.访问http://81.68.186.218:81/
2.部署discuz
2.1.部署discuz
下载地址 https://adaitwo.lanzous.com/i0sawfgwbrg 1.解包 [root@jiangxl ~]# unzip Discuz_X3.4_SC_GBK_20191201.zip -d /data/discuz/ 2.删除刚刚创建的测试文件 [root@jiangxl discuz]# rm -rf index.php 3.修改属主 [root@jiangxl discuz]# chown -R nginx.nginx . 4.将主源码移动到站点目录 [root@jiangxl discuz]# mv upload/* .
2.2.创建discuz数据库
mysql> create database discuz; mysql> grant all on discuz.* to discuz@'%' identified by '123456';
2.3.页面安装discuz
2.3.1.点击我同意
2.3.2.全部是ok即可点击下一步
2.3.3.选择全新安装
2.3.4.创建数据库
数据库服务器:81.68.186.218
数据库名:discuz
数据库用户名:discuz
数据库密码:123456
数据库表前缀:pre_
管理员账号:admin
管理员密码:admin
正在创建表
数据库里已经创建完表
2.3.5.安装完成
2.3.6.访问首页
3.配置redis加速
3.1.配置redis
1.安装redis [root@jiangxl discuz]# yum -y install redis [root@jiangxl discuz]# systemctl start redis [root@jiangxl discuz]# systemctl enable redis [root@jiangxl discuz]# netstat -lnpt | grep redis tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 26575/redis-server 2.配置redis [root@jiangxl discuz]# vim /etc/redis.conf requirepass 123456 [root@jiangxl discuz]# systemctl restart redis
3.2.配置discuz连接接redis
[root@jiangxl discuz]# vim config/config_global.php $_config['memory']['prefix'] = 'EtjkuH_'; $_config['memory']['redis']['server'] = '81.68.186.218'; $_config['memory']['redis']['port'] = 6379; $_config['memory']['redis']['pconnect'] = 1; $_config['memory']['redis']['timeout'] = '0'; $_config['memory']['redis']['requirepass'] = '123456'; $_config['memory']['redis']['serializer'] = 1;
3.3.页面查看是否生效
点击管理中心
点击全局—性能优化—内存优化