您现在的位置是:首页 > cms教程 > Discuz教程Discuz教程

wordpress、Discuz产品部署示例

怜菡2025-07-21Discuz教程已有人查阅

导读Wordpress、Discuz产品部署三个产品提供挂载的目录信息创建一个博客,用wordpress数据库的设置把nginx和php加入开机自启动:首先,在数据库创建一个wordpress的数据库

Wordpress、Discuz产品部署
三个产品提供挂载的目录信息
BLOG
/data/ /blog/wp-content/uploads/ 图片和附件
BBS:
/data/ /bbs/data/attachment/image
/data/ /bbs/uc_server/data/avatar 图像目录
/data/ /bbs/data/attachment/forum/ 图片路径
WWW:
/data/ / /images/swfupload
/data/ / /uploads/allimg/
创建一个博客,用wordpress
数据库的设置
把nginx和php加入开机自启动:
[root@lnmp-1 extra]# vim /etc/rc.local
/application/nginx/sbin/nginx
/application/php/sbin/php-fpm
首先,在数据库创建一个wordpress的数据库
mysql> create database wordpress; 创建wordpress 的数据库
mysql> show databases; 查看所有的数据库
创建用户wordpress 并指定wordpress在192.168.162.135上登录,给出密码
mysql> grant all on wordpress.* to wordpress@'182.61.51.96' identified by '111111';
mysql> flush privileges;
查看wordpress的数据库
mysql> select user,host from mysql.user where user='wordpress';
查看所有的数据库
mysql> select user,host from mysql.user;
mysql> use wordpress 切换到wordpress
mysql> show tables; 查看wordpress下的所有表
mysql> select * from ol_users; 查看ol_users 的所有信息。
说明:如果创建博客站点时报错,就注意下面all那里,不要做限制。
mysql> grant all on wordpress.* to wordpress@'192.168.162.%' identified by '111111';
mysql> flush privileges;
完成后,再执行下面的命令。
mysql> grant select,insert,update,delete on wordpress.* to wordpress@'192.168.162.%' identified by '111111';
mysql> flush privileges;
安装wordpress 的博客程序
上传wordpress的包或者用下载到/application/nginx/html/blog
cd /application/nginx/html/blog
rz -y wordpress-4.2.2-zh_CN.tar.gz 上传这个包
[root@lnmp-1 blog]# tar xf wordpress-4.2.2-zh_CN.tar.gz
[root@lnmp-1 blog]# mv wordpress/* . 把wordpress里的所有文件移到当前目录
[root@lnmp-1 blog]# rm -fr wordpress/
权限管理,把所有文件设置为644,目录设置为755
[root@lnmp-1 html]# find ./blog/ -type f|xargs chmod 644
[root@lnmp-1 html]# find ./blog/ -type d|xargs chmod 755
把上传文件设置为nginx的用户和组。
[root@lnmp-1 html]# chown -R nginx.nginx blog/wp-content/uploads/
修改index.php 加入blog.conf配置文件
[root@lnmp-1 application]# cd /application/nginx/conf/extra/
[root@lnmp-1 extra]# vim blog.conf
server {
listen 80;
server_name blog.etiantian.org;
root html/blog;
location / {
root html/blog;
index index.php index.html index.htm; 把index.php的主页面加入
}
location ~.*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
配置一个连接数据库的文件:
vim /application/nginx/html/blog/wp-config.php
内容填写完连接信息后,下一步,会生成连接文件,可在页面复制。
或者修改blog/wp-config-sample.php 并保存为blog/wp-config.php
##注:创建数据库的信息一定要和这里一样,不然连接不上
// ** MySQL 设置 - 具体信息来自您正在使用的主机 ** //
/** WordPress数据库的名称 */
define('DB_NAME', 'wordpress');
/** MySQL数据库用户名 */
define('DB_USER', 'wordpress');
/** MySQL数据库密码 */
define('DB_PASSWORD', '111111');
/** MySQL主机 */
define('DB_HOST', '192.168.162.131');
* 不同的数据表前缀。前缀名只能为数字、字母加下划线。
*/
$table_prefix = 'od_';
把IP做解析:
1、在LNMP主机里在做解析(有几台Web就做几台解析)
[root@lnmp-1 blog]# vim /etc/hosts
192.168.162.135.ebingou.cn ebingou.cn bbs.ebingou.cn blog.ebingou.cn
192.168.162.131 db.mysql.sql
2、在Windows里做解析(有几台Web就做几台解析)
C:\Windows\System32\drivers\etc\hosts
192.168.162.135.ebingou.cn bbs.ebingou.cn blog.ebingou.cn ebingou.cn
192.168.162.136.ebingou.cn bbs.ebingou.cn blog.ebingou.cn ebingou.cn
3、连接数据库也可以做解析(优化)
192.168.162.131 db.mysql.sql
可以/application/nginx
添加伪静态:
在设置-->固定链接-->自定义结构(选定)/archiver/%post_id%.html
然后添加伪静态文件
[root@lnmp-1 extra]# pwd
/application/nginx/conf/extra
[root@lnmp-1 extra]# vim blog.conf
server {
listen 80;
server_name blog.etiantian.org;
root html/blog;
location / {
index index.php index.html index.htm;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
}
location ~.*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
再检查语法和启动
[root@lnmp-1 nginx]# ./sbin/nginx -t
[root@lnmp-1 nginx]# ./sbin/nginx -s reload
关于远程管理挂载的文件目录:
Wordpress产品的挂载目录为:
/application/nginx/html/blog/wp-content/uploads/
挂载:
bin/mount -t nfs -o noatime,nodiratime,nosuid,noexec,nodev, 192.168.162.130:/backup/blog/www/application/nginx/html/blog/wp-content/uploads/
说明:如果博客里面有了文件,则需要在挂载之前转移备份里面的文件:
[root@lnmp-1 uploads]# mv 2015/www/opt/
[root@lnmp-1 uploads]# rm -fr 2015/
注:此处用mv来转移文件,cp -a 会导致权限自动修改,恢复也用mv
再挂载:
/bin/mount -t nfs -o noatime,nodiratime,nosuid,noexec,nodev, 192.168.162.130:/backup/blog/www/application/nginx/html/blog/wp-content/uploads/
注:此处挂载,要注意NFS提供的权限要提供匿名用户运行(all_squash),要不然会导致无法上传文件。
NFS提供的挂载数据如下:
[root@nfs ~]# cat /etc/exports
#shared data for bbs by mobboy
/backup/blog 192.168.162.0/24(rw,sync,all_squash)
/backup/bbs 192.168.162.0/24(rw,sync,all_squash)
/backup/192.168.162.0/24(rw,sync,all_squash)
挂载目录的权限:
chown -R nfsnobody.nfsnobody /backup/*
恢复原有的数据:
[root@lnmp-1 uploads]# mv /opt/2015/ ./
OK!! 博客完成
创建BBS论坛:
在数据库里创建相应的数据库和授权连接的IP段:
数据库:
mysql> show databases;
mysql> create database bbs;
mysql> show databases;
mysql> grant select,insert,delete,update,create,drop on bbs.* to bbs@'192.168.162.%' identified by '111111';
mysql> flush privileges;
mysql> select user,host from mysql.user;
注:上面黄颜色的授权仅用于安装,或者用all替代,工作中用不create。
说明:192.168.162.% 此处是远程的IP段,如果是本机则改成 localhost
WEB端:
测试远程连接数据库:
[root@lnmp-1 ~]# mysql -ubbs -p111111 -h 192.168.162.131
cd /application/nginx/conf/extra/
vim bbs.conf
[root@lnmp-1 extra]# vim bbs.conf
access_log logs/access_bbs.log main;
server {
listen 80;
server_name bbs.etiantian.org;
root html/bbs;
location / {
index index.php index.html index.htm;
}
location ~.*\.(php|php5)?$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
../../sbin/nginx -t
../../sbin/nginx -s reload
在此可写一个phpinfo.php测试连接
[root@lnmp-1 blog]# vim phpinfo.php
<?php
phpinfo();
?>
安装BBS Discuz产品:
cd ../../html/bbs/
wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip
unzip -o Discuz_X3.2_SC_UTF8.zip
[root@lnmp-1 bbs]# ll
-rw-r--r-- 1 root root 12493463 6月 9 10:58 Discuz_X3.2_SC_UTF8.zip
-rw-r--r-- 1 root root 18 10月 5 02:18 index.html
drwxr-xr-x 2 root root 4096 6月 9 10:21 readme
drwxr-xr-x 12 root root 4096 6月 9 10:21 upload
drwxr-xr-x 4 root root 4096 6月 9 10:21 utility
[root@lnmp-1 bbs]# rm -fr readme/ utility/ index.html Discuz_X3.2_SC_UTF8.zip
[root@lnmp-1 bbs]# mv upload/* .
授权
[root@lnmp-1 bbs]# chown -R nginx.nginx config/ data/ uc_*
在windows解析
C:\Users\Administrator>ping bbs.etiantian.org
正在 Ping.etiantian.org [192.168.162.135] 具有 32 字节的数据:
来自 192.168.162.135 的回复: 字节=32 时间<1ms TTL=64
再查看一下服务器的IP和windows解析是不是一样。
浏览器安装Discuz
注:所需状态必须全绿
更改数据库权限:
管理用权限,因为上面对数据库授权太大,所以这里要更改一下数据库的用户权限。
mysql>drop user bbs@’192.168.162.%’
mysql> select user,host from mysql.user;
mysql> grant select,insert,delete,update,drop on bbs.* to bbs@'192.168.162.%' identified by '111111';
mysql> flush privileges;
mysql> select user,host from mysql.user;
BBS 上传的路径:
头像目录:/bbs/uc_server/data/avatar
图片目录:bbs/data/attachment/forum
为了防止别人来重新安装,也可以把删除:
[root@lnmp-1 bbs]# rm -fr install/
下面来添加一个模块,测试一下:
在页面选择“模块管理”进入
输入验证密码。
选择论坛
先删除默认的模块:(先删除默认版块)
添加新的分区
添加新的版块
配置伪静态
查看rewrite规则(点击进入,下翻找开Nginx Web Server)
在服务器配置伪静态
[root@lnmp-1 conf]# vim extar/bbs.conf
server {
listen 80;
server_name bbs.ebingou.cn;
root html/bbs;
location / {
index index.php index.html index.htm;
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/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;
}
}
重新启动
检查语法:
[root@lnmp-1 conf]# /application/nginx/sbin/nginx -t
优雅启动:
/application/nginx/sbin/nginx -s reload

本文标签:

很赞哦! ()

相关源码

  • (自适应)幽默笑话脑筋急转弯搞笑趣图博客pbootcms模板下载本模板基于PbootCMS系统开发,专为幽默笑话、搞笑趣图类网站设计。采用轻松活泼的布局风格,突出娱乐内容分享特色,适合各类笑话、段子、搞笑图片等内容展示。查看源码
  • (自适应响应式)高新技术科技能源pbootcms网站HTML5模板本模板基于PbootCMS内核开发,为高新技术、科技研发、能源技术等科技型企业设计。采用HTML5+CSS3前沿技术,具备完善的响应式布局,能够自动适配手机、平板和电脑等多种终端设备。模板设计风格简约大气查看源码
  • (自适应)游泳馆泳池水处理器设备pbootcms网站模板免费下载专注服务于泳池水处理设备制造商、泳池系统工程商等企业用户。模板预设设备分类体系、技术参数展示模块和解决方案呈现页面,满足行业特有展示需求。查看源码
  • (PC+WAP)绿色产品环保设备垃圾桶厂家公司网站pbootcms模板为垃圾桶生产商、环保设备企业打造的高端响应式门户模板,基于PbootCMS开源内核深度开发。采用HTML5自适应架构,无缝实现PC与手机端数据实时同步与交互优化查看源码
  • (PC+WAP)房屋建造建筑工程房地产建材行pbootcms网站模板下载本模板基于PbootCMS内核开发,为房屋建造、建筑工程及房地产建材类企业设计。通过本模板可快速搭建具有行业特色的企业官网,只需替换文字与图片内容即可适配其他行业使用。查看源码
  • (自适应响应式)HTML5建筑工程公司建筑集团网站模板下载基于PbootCMS内核开发的响应式建筑行业网站模板,为建筑工程公司、建筑集团等企业打造,通过简洁大气的设计风格展现企业专业形象。查看源码
分享笔记 (共有 篇笔记)
验证码:

本栏推荐