在LAMP环境下部署Discuz! X论坛
前期准备
[root@server 桌面]# yum -y install openssl-devel ncurses-devel libtermcap-devel libxml2-devel
[root@server 桌面]# yum -y remove httpd mysql-server mysql php-mysql
1. 安装 httpd源码包
[root@server 桌面]# tar -zxvf httpd-2.2.25.tar.gz
[root@server 桌面]# cd httpd-2.2.25
[root@server httpd-2.2.25]# ./configure --prefix=/usr/local/httpd \
--enable-so --enable-rewrite --enable-cgi \
--enable-charset-lite --enable-ssl \
--enable-suexec --with-suexec-caller=daemon \
--with-suexec-docroot=/usr/local/httpd/htdocs
[root@server httpd-2.2.25]# make && make intsall
建立 httpd 控制脚本,添加启动参数
[root@server httpd-2.2.25]# cp -f /usr/local/httpd/bin/apachectl /etc/init.d/httpd
[root@server httpd-2.2.25]# vim /etc/init.d/httpd
#!/bin/bash
# chkconfig: 35 85 15
# description: Apache is a World Wide Web Server
......
[root@server httpd-2.2.25]# chmod +x /etc/init.d/httpd
[root@server httpd-2.2.25]# chkconfig --add httpd
2. 安装 mysql源码包
准备mysql运行账户(不创建家目录 uid为49 不能登录),安装
[root@server httpd-2.2.25]# useradd -M -u 49 -s /sbin/nologin mysql
[root@server httpd-2.2.25]# cd /root/桌面
[root@server 桌面]# tar-zxvf mysql-5.1.62.tar.gz
[root@server 桌面]# cd /usr/src/mysql-5.1.62/
[root@server mysql-5.1.62]# ./configure --prefix=/usr/local/mysql \
--with-charset=utf8 --with-collation=utf8_general_ci --with-extra-charset=gbk,gb2312
[root@server mysql-5.1.62]# make && make install
调整目录权限,建立mysql配置文件
[root@server mysql-5.1.62]#chown -R root:mysql /usr/local/mysql/
[root@server mysql-5.1.62]#chown -R mysql /usr/local/mysql/var/ #若无此目录需自行创建mkdir
[root@server mysql-5.1.62]#cp -f /usr/local/mysql/share/mysql/my-medium.cnf /etc/my.cnf
[root@server mysql-5.1.62]# vim /etc/my.cnf
[mysqld]
port = 3306
socket = /tmp/mysql.sock
#skip-locking
skip-external-locking
key_buffer_size = 16M
......
添加库链接,建立 mysqld控制脚本,添加启动参数
[root@server mysql-5.1.62]# ln -sf /usr/local/mysql/bin/* /usr/local/bin/
[root@server mysql-5.1.62]# vim /etc/ld.so.conf.d/mysql-64.conf
/usr/local/mysql/lib/mysql
[root@server mysql-5.1.62]# ldconfig
[root@server mysql-5.1.62]#cp -f /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld
[root@server mysql-5.1.62]#chmod +x /etc/init.d/mysqld
[root@server mysql-5.1.62]#chkconfig --add mysqld
[root@server mysql-5.1.62]# /usr/local/mysql/bin/mysql_install_db --user=mysql
3. 编译安装 php
[root@server mysql-5.1.62]# cd /root/桌面
[root@server 桌面]# tar -zxvf php-5.4.19.tar.gz
[root@server 桌面]# cd php-5.4.19
[root@server php-5.4.19]# ./configure --prefix=/usr/local/php \
--enable-mbstring --enable-sockets \
--with-apxs2=/usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql \
--with-config-file-path=/usr/local/php
[root@server php-5.4.19]# make && make install
启用httpd的PHP网页支持
[root@server php-5.4.19]# vim /usr/local/httpd/conf/httpd.conf
......
LoadModule php5_module modules/libphp5.so
......
ServerName localhost:80
......
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
......
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
......
启动mysql 和httpd
[root@server php-5.4.19]# service mysqld restart
[root@server php-5.4.19]# service httpd restart
修改mysql密码,创建mysql数据库
[root@server php-5.4.19]# mysql -u root
mysql> SET PASSWORD FOR 'root'@'localhost'=PASSWORD('123456');
mysql> CREATE DATABASE bbsdb;
mysql> GRANT all ON bbsdb.* TO runbbs@localhost IDENTIFIED BY 'admin123';
mysql> quit
4.安装Discuz! X 论坛程序
[root@server php-5.4.19]#cd /root/桌面
[root@server 桌面]# unzip Discuz_X3.0_SC_UTF8.zip -d luntan
[root@server 桌面]# cp -rf luntan/upload/ /usr/local/httpd/htdocs/bbs
[root@server bbs]# cd /usr/local/httpd/htdocs/bbs
[root@server bbs]# chown -R daemon template/ config/ data/ uc_server/ uc_client/
[root@server bbs]# firefox &
访问: localhost/bbs/install
......
数据库服务器:localhost
数据库用户名:root
数据库密码:123456
数据库名:bbsdb
......
善后处理
[root@server bbs]# mv install/ install.lock
[root@server bbs]# chmod 600 install.lock/
[root@server bbs]# ls -ld install.lock/
firefox访问:localhost/bbs
效果图如下: