Linux 下Discuz論壇的搭建


Discuz論壇的搭建【基於LNMP環境搭建成功后】

##創建BBS數據庫在本地/遠程服務器

mysql -uroot -proot
create database bbs;
show databases;
grant all on bbs.*to bbs@'localhost' identified by 'root';
grant all on bbs.*to bbs@'192.168.25.%' identified by 'root';     # 遠程mysql服務器
flush privileges;
select user,host from mysql.user;
##遠程連接數據庫:
mysql -ubbs -proot -h 192.168.25.138
echo ' 192.168.25.144 www.bbs.com  bbs.com'>> /etc/hosts

 

##配置BBS和Nginx
在Nginx服務器下面配置bbs的Vhosts

vim /usr/local/nginx/conf/nginx.conf                  -->添加include
vim /usr/local/nginx/conf/extra/bbs.conf                -->配置域名
vim /etc/hosts                                        -->添加DNS解析
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx -s reload              -->重啟服務
mkdir -p /usr/local/nginx/html/bbs              -->創建虛擬路徑
cd /usr/local/nginx/html
chown -R root.root ./bbs
find ./blog/ -type f|xargs chmod 644
find ./blog/ -type d|xargs chmod 755              -->更改權限
server {
        listen       80;
        server_name  www.bbs.com;
        root   html/discuz;
        location / {
#            index  index.html index.htm;
             index  index.php index.html index.htm;
             rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/archiver/index.php?action=$2&value=$3 last;
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
if (!-e $request_filename) {
        return 404;
}
        }
        location ~.*\.(php|php5)?$ {
             fastcgi_pass  127.0.0.1:9000;
             fastcgi_index index.php;
             include  fastcgi.conf;
        }
        access_log logs/access_discuz.log main;
    }
bbs.conf

##下載&&安裝BBS

wget  http://ahdx.down.chinaz.com/201712/Discuz_X3.4_SC_UTF8_0101.zip   -->q不顯示
unzip Discuz_X3.4_SC_UTF8*.zip 
rm Discuz_X3.4_SC_UTF8*.zip -rf
cd /usr/local/nginx/html/bbs
cp -rf upload/*  ./                       -->把文件直接放在bbs的根目錄下,upload有安裝腳本
chmod 644 /usr/local/nginx/html/bbs/*
chown -R nginx.nginx bbs/ -->涉及用戶提交頭像等操作,簡單起見,先改為nginx,后進行修改

頁面顯示:

http://www.bbs.com/forum.php

檢查安裝環境

 

收回數據庫權限:

drop user bbs@'192.168.25.%';
flush privileges;
grant update,insert,delete,drop,select on bbs.*to bbs@'192.168.25.%' identified by 'root';

刪除安裝程序,防止論壇再次安裝

rm -rf /usr/local/nginx/html/bbs/install

image

用戶上傳的數據:--》將來掛在到NFS上
上傳圖片的路徑:

cd /usr/local/nginx/html/bbs/data/attachment/forum/201709/02

查看頭像文件上傳路徑

cd /usr/local/nginx/html/bbs
find ./ type f -name '*.jpg' -mmin -13 
./uc_server/data/avatar/000/00/00/01_avatar_small.jpg

---------------------------------------------------------------------------------------
#偽靜態化
1.前台
    管理 ->全局 ->SOE設置 ->勾選URL靜態化 ->提交
2.添加如下內容到/extra/bbs.conf 默認的location / 里   [可以查看discuz的規則添加即可]

rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^([^\.]*)/article-([0-9]+)-([0-9]+)\.html$ $1/portal.php?mod=view&aid=$2&page=$3 last;
rewrite ^([^\.]*)/forum-(\w+)-([0-9]+)\.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
rewrite ^([^\.]*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3D$4&page=$3 last;
rewrite ^([^\.]*)/group-([0-9]+)-([0-9]+)\.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
rewrite ^([^\.]*)/space-(username|uid)-(.+)\.html$ $1/home.php?mod=space&$2=$3 last;
rewrite ^([^\.]*)/blog-([0-9]+)-([0-9]+)\.html$ $1/home.php?mod=space&uid=$2&do=blog&id=$3 last;
rewrite ^([^\.]*)/(fid|tid)-([0-9]+)\.html$ $1/archiver/index.php?action=$2&value=$3 last;
rewrite ^([^\.]*)/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ $1/plugin.php?id=$2:$3 last;
if (!-e $request_filename) {
    return 404;
}
View Code

image

image
3.測試並且重啟服務
image


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM