声明:我是在Centos5.10 的系统中搭建的,如在其他系统搭建中产生报错信息,可与我联系。
一、源码搭建HTTPD
1、卸载相关rpm包
# yumremove httpd mysql mysql-server php
# rpm -qhttpd mysql mysql-server php
packagehttpd is not installed
packagemysql is not installed
package mysql-serveris not installed
packagephp is not installed
2、安装gcc开发环境
# yum -yinstall gcc*
3、安装源码APACHE
# yum -yinstall openssl-devel
# tar-zxvf httpd-2.2.25.tar.gz -C /usr/src/
# cd/usr/src/httpd-2.2.25
#./configure--prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-cgi --enable-charset-lite --enable-ssl --enable-suexec--with-suexec-caller=daemon --with-suexec-docroot=/usr/local/apache2/htdocs ;make && make install
4、添加apachectl到系统服务中
# cp/usr/local/apache2/bin/apachectl /etc/init.d/apache
# vim/etc/init.d/apache 在#!/bin/bash下面加上如下两行:
# chkconfig: 35 85 15 //数字依次为:在对应的级别启动(35),开机时的启动级别(85),关机时的启动级别(15)
#description: Apache is a World Wide Web Server
#chkconfig --add apache
#service apache start
#chkconfig apache on
#netstat -ln | grep :80
tcp 0 0 :::80 :::* LISTEN
二、源码搭建MySQL
1、创建账户
#useradd -M -u 49 -s /sbin/nologin mysql
# idmysql
uid=49(mysql)gid=49(mysql) groups=49(mysql)
2、安装配置MySQL
# rpm -q libtermcap-devel ncurses-devel
# tar-zxvf mysql-5.1.62.tar.gz -C /usr/src/
# cd/usr/src/mysql-5.1.62
#./configure --prefix=/usr/local/mysql --with-charset=utf8 --with-collation=utf8_general_ci--with-extra-charset=gbk,gb2312 ; make && make install
3、创建主配置文件
# cpsupport-files/my-medium.cnf /etc/my.cnf
4、初始化数据库(数据库的存放目录:/usr/local/mysql/var)
#/usr/local/mysql/bin/mysql_install_db --user=mysql
5、修改权限
# chown-R root.mysql /usr/local/mysql/ ; chown -R mysql /usr/local/mysql/var/
6、环境调整
# echo"/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf
#ldconfig
# echo"export PATH=$PATH:/usr/local/mysql/bin/" >> /etc/profile
# source/etc/profile
7、添加到系统服务
# cpsupport-files/mysql.server /etc/init.d/mysqld
# chmod755 /etc/init.d/mysqld
#chkconfig --add mysqld ; chkconfigmysqld on
8、启动服务
#service mysqld start
StartingMySQL. [确定]
#netstat -tulnp | grep mysqld
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 31662/mysqld
三、源码搭建PHP
1、安装PHP
# rpm -qlibxml2-devel
# tar-zxvf php-5.4.19.tar.gz -C /usr/src/
# cd /usr/src/php-5.4.19
#./configure --prefix=/usr/local/php5 --enable-mbstring --enable-sockets --with-apxs2=/usr/local/apache2/bin/apxs--with-mysql=/usr/local/mysql/ --with-config-file-path=/usr/local/php5 ; make && make install
# cpphp.ini-development /usr/local/php5/etc/php.ini
# vim/usr/local/php5/etc/php.ini
...
692 default_charset = "UTF-8" 设置字符级
# vim/usr/local/apache2/conf/httpd.conf
...
55 AddType application/x-httpd-php .php
...
169 DirectoryIndex index.php index.html
2、重启apache
#service apache stop
#service apache start
3、查看apache工作目录,并编译文件
①源码apache的工作目录:
# cd/usr/local/apache2/htdocs/
# ls
bbs index.html index.php
②编写测试文件
#vim/usr/local/apache2/htdocs/index.php
<?php
phpinfo();
?>
测试:
http://www.tarena.com/
四、PHP应用部署(Discuz)
# mysql-u root -p
mysql>create database bbsdb; //创建数据库
QueryOK, 1 row affected (0.00 sec)
mysql>GRANT all ON bbsdb.* TO 'runbbs'@'localhost' IDENTIFIED BY 'adm123';
QueryOK, 0 rows affected (0.00 sec)
mysql>quit
# cd/usr/src/
# unzipDiscuz_X3.0_SC_UTF8.zip -d Discuz
# mvDiscuz/upload/ /usr/local/apache2/htdocs/bbs
# cd/usr/local/apache2/htdocs/bbs/
# chown-R daemon config/ data/ uc_server/ template/ uc_client/
访问地址:
http://www.tarena.com/bbs/install
根据指示安装论坛
在选择存放数据的mysql数据库和在使用mysql数据库时的用户和密码时使用授权用户
五、论坛安装软件的备份
# cd/usr/local/apache2/htdocs/bbs/
# cpinstall/ install.bak20131127
# chmod600 install.bak20131127/
六、测试访问论坛
1、前台访问地址:
http://www.tarena.com/bbs/
2、后台管理地址:
http://www.tarena.com/bbs/admin.php
备注:源码包上传到了我的51CTO下载中心,可下载