Linux+Nginx+MySQL下配置论坛程序Discuz的基本教程
CrossdayDiscuz!Board(简称Discuz!)是北京康盛新创科技有限责任公司推出的一套通用的社区论坛软件系统。自2001年6月面世以来,Discuz!已拥有14年以上的应用历史和200多万网站用户案例,是全球成熟度最高、覆盖率最大的论坛软件系统之一。目前最新版本Discuz!X3.2正式版于2015年6月9日发布,首次引入应用中心的开发模式。2010年8月23日,康盛创想与腾讯达成收购协议,成为腾讯的全资子公司。
CrossdayDiscuz!Board(以下简称Discuz!,中国国家版权局著作权登记号2006SR11895)是康盛创想(北京)科技有限公司(英文简称Comsenz)推出的一套通用的社区论坛软件系统,用户可以在不需要任何编程的基础上,通过简单的设置和安装,在互联网上搭建起具备完善功能、很强负载能力和可高度定制的论坛服务。Discuz!的基础架构采用世界上最流行的web编程组合PHP+MySQL实现,是一个经过完善设计,适用于各种服务器环境的高效论坛系统解决方案。
作为国内最大的社区软件及服务提供商,Comsenz旗下的Discuz!开发组具有丰富的web应用程序设计经验,尤其在论坛产品及相关领域,经过长期创新性开发,掌握了一整套从算法,数据结构到产品安全性方面的领先技术。使得Discuz!无论在稳定性、负载能力、安全保障等方面都居于国内外同类产品领先地位。
下面我们就来看一下LNMP环境下的Discuz安装配置过程:
1、配置nginx
vim/usr/local/nginx/etc/nginx.conf
usernginx;
worker_processes1;
#error_loglogs/error.log;
#error_loglogs/error.lognotice;
error_loglogs/error.loginfo;
events{
worker_connections1024;
}
http{
includemime.types;
server_tokensoff;
default_typeapplication/octet-stream;
log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'
'$status$body_bytes_sent"$http_referer"'
'"$http_user_agent""$http_x_forwarded_for"';
access_loglogs/access.logmain;
sendfileon;
keepalive_timeout65;
client_header_buffer_size32k;
large_client_header_buffers432k;
#客户请求头缓冲大小nginx默认会用client_header_buffer_size这个buffer来读取header值,如果header过大,它会使用large_client_header_buffers来读取如果设置过小HTTP头/Cookie过大会报400错误nginx400badrequest求行如果超过buffer,就会报HTTP414错误(URITooLong)nginx接受最长的HTTP头部大小必须比其中一个buffer大,否则就会报400的HTTP错误(BadRequest)。
client_max_body_size8m;#最大上传附件8MB
client_body_buffer_size128k;#缓冲区代理缓冲用户端请求的最大字节数
keepalive_timeout60;
tcp_nopushon;
tcp_nodelayon;
gzipon;
gzip_min_length1k;
gzip_buffers416k;
gzip_http_version1.0;
gzip_comp_level2;
includevh/bbs.yourich.com.cn.conf;
}
mkdir/usr/local/nginx/etc/vh
vim/usr/local/nginx/etc/vh/discuz.conf
upstreambbs.test.com
{
server127.0.0.1;
checkinterval=3000rise=2fall=5timeout=1000type=http;
#interval检测间隔时间,单位为毫秒
#rsie请求2次正常的话,标记此realserver的状态为up
#fall表示请求5次都失败的情况下,标记此realserver的状态为down
#timeout为超时时间,单位为毫秒
check_http_send"GET/HTTP/1.1\r\nHOST:\r\n\r\n";
check_http_expect_alivehttp_2xxhttp_3xxhttp_4xx;
}
server{
listen80;
server_namebbs.test.com;
indexindex.htmlindex.php;
root/www/discuz;
access_loglogs/bbs_access.logmain;
error_loglogs/bbs_error.log;
location~.*\.(jpg|jpeg|png|gif\js|css)${
root/www/discuz;
access_logoff;
}
location/{
try_files$uri$uri//index.php?$args;
}
location~.*\.(php)?${
expires-1s;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
try_files$uri=404;
includefastcgi_params;
fastcgi_paramSCRIPT_FILENAME/www/discuz$fastcgi_script_name;
fastcgi_paramQUERY_STRING$query_string;
fastcgi_paramREQUEST_METHOD$request_method;
fastcgi_paramCONTENT_TYPE$content_type;
fastcgi_paramCONTENT_LENGTH$content_length;
}
}
2、下载discuz
下载discuz安装包并解压将upload目录下的所有内容复制到nginx指定的网站文档跟目录下/www/discuz
设置权限
chown-Rnginx:nginx/www/discuz
3、创建数据
createdatabasediscuzdefaultcharactersetutf8; grantallprivilegesondiscuz.*todiscuz@'localhost'identifiedby'discuz'; flushprivileges;
4、安装discuz
在浏览器中输入http://ip/install根据向导进行安装