welcome to xlongwei.com

欢迎大家一起学习、交流、分享


QQ:9167702333 邮箱:admin@xlongwei.com

Discuz安装配置笔记


分类 Linux   关键字 分享   标签 linux   discuz   发布 hongwei  1433928964330
注意 转载须保留原文链接,译文链接,作者译者等信息。  
Discuz是php语言开发的论坛系统,在搭建php运行环境时遇到了不少波折,这里记录一下安装配置过程以备忘。

下载Discuz最新版+下载php及依赖,http://www.discuz.net/thread-3570835-1-1.html
# wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip
# wget http://tool.xlongwei.com/discuz/lnmp.list
# wget -i lnmp.list #下载lnmp.list记录的url列表

安装基础依赖,参考文章http://www.discuz.net/thread-1833489-1-1.html
# 安装基础依赖库,否则可能报错:XML configuration could not be found,Please reinstall the libcurl distribution等各种缺包错误
# yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel

# yum list | grep installed #查看已安装模块

# 约定源码包tar.gz全部解压至/usr/local/src目录再编译安装
# mkdir /usr/local/src
# cd /usr/local/src

安装Mysql,这里仅贴出操作步骤,参考文章Linux Mysql 数据库主从配置
# cd /usr/local/src
# tar zxvf mysql-5.0.86-linux-i686-icc-glibc23.tar.gz
# mv mysql-5.0.86-linux-i686-icc-glibc23 /usr/local/
# ln -s /usr/local/mysql-5.0.86-linux-i686-icc-glibc23/ /usr/local/mysql
# groupadd mysql
# useradd -g mysql mysql -d /home/mysql -s /sbin/nologin
# chown -R mysql:mysql /usr/local/mysql
# chown -R mysql:mysql /usr/local/mysql-5.0.86-linux-i686-icc-glibc23/
# cd /usr/local/mysql
# ./scripts/mysql_install_db --user=mysql
# cp ./support-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod 755 /etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig --level 3 mysqld on
# cp ./support-files/my-huge.cnf /etc/my.cnf
# mv /usr/local/mysql/data /var/lib/mysql
# chown -R mysql:mysql /var/lib/mysql
# vi /etc/my.cnf
[mysqld]
datadir = /var/lib/mysql
skip-innodb
wait-timeout = 10
max_connections = 512
max_connect_errors = 10000000
[mysqld]
max_allowed_packet = 16M
thread_cache_size = 8

安装Nginx,本机已安装Tengine,
# cd /usr/local/src/
# tar zxvf nginx-0.7.65.tar.gz
# cd nginx-0.7.65
# ./configure --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --with-http_realip_module --with-http_addition_module --with-http_gzip_static_module --with-http_random_index_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module
# make
# make install clean
# cp /usr/local/src/nginx /etc/init.d/nginx
# chmod 755 /etc/init.d/nginx
# chkconfig --add nginx
# chkconfig nginx on

安装Libiconv
# cd /usr/local/src/
# tar zxvf libiconv-1.13.1.tar.gz
# cd libiconv-1.13.1/
# ./configure --prefix=/usr/local
# make; make install

安装Libmcrypt
# tar zxvf libmcrypt-2.5.8.tar.gz
# cd libmcrypt-2.5.8
# ./configure
# make
# make install
# /sbin/ldconfig
# cd libltdl/
# ./configure --enable-ltdl-install
# make
# make install
# cd /usr/local/src/

安装Mhash
# tar zxvf mhash-0.9.9.9.tar.gz
# cd mhash-0.9.9.9/
# ./configure
# make
# make install
# cd ..
# ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
$ ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
$ ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
$ ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
# ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
# ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
# ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
# ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
# ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
$ ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
# tar zxvf mcrypt-2.6.8.tar.gz
# cd mcrypt-2.6.8
# /sbin/ldconfig
# ./configure
# make
# make instal

安装PHP,本机已rpm方式安装Mysql,这里需要mysql相关的header头文件,解压mysql源码包至/usr/local/mysql即可
报错:Can't connect to local MySQL server through socket '/tmp/mysql.sock,解决:ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
# cd /usr/local/src
# tar zxvf php-5.2.17.tar.gz
# gzip -cd /soft/tool/discuz/php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
# cd php-5.2.17
# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/etc/cgi --with-mysql=/usr/local/src/mysql-5.0.91 --with-mysqli=/usr/local/src/mysql-5.0.91/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib --with-libxml-dir=/usr --with-xmlrpc --enable-xml --enable-mbstring --enable-ftp --with-gd --enable-magic-quotes --with-pear --enable-sockets --with-ttf --enable-gd-native-ttf --enable-sysvsem --enable-sysvshm --enable-shmop --enable-force-cgi-redirect --enable-fastcgi --enable-zip --enable-fpm --with-mhash --with-mcrypt --enable-discard-path --enable-bcmath --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --with-openssl
# make ZEND_EXTRA_LIBS='-liconv'
# make install
# mkdir -p /usr/local/etc/cgi/
# cp php.ini-dist /usr/local/etc/cgi/php.ini
# mv -f /usr/local/src/php-fpm.conf /usr/local/php/etc/php-fpm.conf
# echo 'ulimit -SHn 65535' >> /etc/rc.local
# echo '/usr/local/php/sbin/php-fpm start' >> /etc/rc.local

安装Memcache和Memcached
# cd /usr/local/src
# tar zxvf memcache-2.2.5.tgz
# cd memcache-2.2.5/
# /usr/local/php/bin/phpize
# ./configure --with-php-config=/usr/local/php/bin/php-config
# make
# make install

# vi /usr/local/etc/cgi/php.ini
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
extension = "memcache.so"
output_buffering = On

# cd /usr/local/src
#tar zxvf libevent-1.4.13-stable.tar.gz
# cd libevent-1.4.13-stable
# ./configure --prefix=/usr/lib
# make
# make install
# cd ../
# tar zxvf memcached-1.4.5.tar.gz
# cd memcached-1.4.5
# ./configure --prefix=/usr/local --with-libevent=/usr/lib/
# make
# make install
# /usr/local/bin/memcached -d -u www -m 128

安装ZendOptimizer
# cd ..
# tar zxvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
# cd ZendOptimizer-3.3.3-linux-glibc23-i386
# ./install
Please specify the location for installing
Zend Optimizer:
这里填写Zend的安装路径,按下面写即可
/usr/local/Zend
Confirm the location of your
php.ini file:
这里填写的是php.ini的路径,按下面写即可
/usr/local/etc/cgi
Are you using Apache Web server?
这里选No,使用Nginx或Tengine

运行Nginx和PHP
php-fpm运行失败:实际配置文件为/usr/local/php/etc/php-fpm.conf,打开<!-- <value name="user">nobody</value> -->以及group配置的注释,不能以root运行
# vi /usr/local/php/etc/php-fpm.conf
修改max_children=100和max_requests=100,表示运行100个php进程,每个进程完成100个请求后重启
# ulimit -SHn 65535
# /usr/local/php/sbin/php-fpm start
# service nginx start
# vi /etc/nginx/conf.d/bbs.conf #rewrite是静态化规则处理
server {
server_name bbs.itechgt.com;
access_log /var/log/nginx/bbs.access.log main;
root /soft/discuz/upload;
index index.php;
location ~ .*\.(js|css|gif|png|jpg|jpeg)$ {
root /soft/discuz; #静态资源和上传的图片
}
location / {
index forum.php index.php index.html index.htm;
rewrite ^([^\.]*)/topic-(.+)\.html$ $1/portal.php?mod=topic&topic=$2 last;
rewrite ^(.*)/article-([0-9]+)\.html$ $1/portal.php?mod=article&articleid=$2 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 ^(.*)/([a-z]+)-(.+)\.html$ $1/$2.php?rewrite=$3 last;
}
location ~ .*\.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_read_timeout 600;
include fastcgi.conf;
}
}

配置Discuz,访问http://host/bbs/install,设置数据库账户及管理员帐户,只要数据库能够访问成功就可以配置成功了。
# mysql
> create database discuz
> grant all privileges on discuz.* to 'youruser'@'localhost' identified by 'yourpassword';

# chmod -R 777 config #分配目录读写权限,config data source/plugin(便于在线安装插件) uc_client uc_server
# ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock #如果提示无法通过/tmp/mysql.sock连接数据库