一、程序包和安装环境准备
1、程序版本:
apr-1.5.0.tar.bz2 apr-util-1.5.3.tar.bz2 httpd-2.4.10.tar.bz2 mariadb-5.5.43-linux-x86_64.tar.gz php-5.6.4.tar.xz phpMyAdmin-4.0.5-all-languages.zip Discuz_X3.2_SC_GBK.zip
2、准备安装开发环境
yum groupinstall "Server Platform Development" "Development tools" -y yum install pcre-devel -y yum install bzip2-devel libmcrypt-devel -y yum install libxml2-devel -y
二、安装LAMP架构程序
在一台主机进行安装LAMP架构,分别提供BBS论坛业务和通过浏览器来管理MySQL数据库。
1、安装httpd程序
1)安装httpd程序依赖apr程序包
tar xf apr-1.5.0.tar.bz2 cd apr-1.5.0 ./configure --prefix=/usr/local/apr make && make install
2)安装httpd程序依赖apr-util程序包
tar xf apr-util-1.5.3.tar.bz2 cdapr-util-1.5.3 ./configure --prefix=/usr/local/apr-util--with-apr=/usr/local/apr/ make&& make install
3)安装http程序包
[[email protected] httpd-2.4.10]# ./configure--prefix=/usr/local/apache-2.4.10 --sysconfdir=/etc/apache24--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --enable-so--enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre--enable-modules=most --enable-mpms-shared=all --with-mpm=prefork [[email protected] httpd-2.4.10]# make &&make install
4)创建apahce软链接
[[email protected] ~]# ln -s /usr/local/apache-2.4.10//usr/local/apache [[email protected] ~]# ll /usr/local/apache lrwxrwxrwx 1 root root 25 May 3 11:27 /usr/local/apache ->/usr/local/apache-2.4.10/
5)提供服务脚本/etc/rc.d/init.d/httpd
修改httpd的配置文件中指定pid文件存放路径 PidFile"/var/run/httpd.pid" 服务脚本通过复制系统原有的httpd服务脚本,在此基础上进行简单的修改,修改的内容如下: [[email protected] ~]# cp/etc/rc.d/init.d/httpd /etc/rc.d/init.d/httpd24 apachectl=/usr/local/apache/bin/apachectl httpd=${HTTPD-/usr/local/apache/bin/httpd} 添加到开机自启动服务中: [[email protected] ~]# chkconfig --add httpd24 [[email protected] ~]# chkconfig httpd24 on
6)设置httpd环境变量
[[email protected] httpd-2.4.10]# vim/etc/profile.d/httpd.sh PATH=/usr/local/apache/bin/:$PATH [[email protected] httpd-2.4.10]# ./etc/profile.d/httpd.sh
2、安装通用二进制MariaDB
1)创建MariaDB运行的用户
[[email protected] ~]# groupadd -r mysql [[email protected] ~]# useradd -r -g mysql mysql
2)创建数据库存放目录并设置属主、属组
[[email protected] ~]# mkdir /data/mysql -p [[email protected] ~]# chown -R mysql.mysql /data/mysql/
3)解压MariaDB程序包到/usr/local目录下
[[email protected] tools]# tar xfmariadb-5.5.43-linux-x86_64.tar.gz -C /usr/local/
4)创建软链接
[[email protected] tools]# cd /usr/local/ [[email protected] local]# ln -smariadb-5.5.43-linux-x86_64/ mysql
5)初始化数据库
[[email protected] local]# cd mysql [[email protected] mysql]# chown -R root.mysql ./* [[email protected] mysql]#scripts/mysql_install_db --datadir=/data/mysql/ --user=mysql
6)提供MySQL的主配置文件
[[email protected] mysql]# mkdir /etc/mysql [[email protected] mysql]# cpsupport-files/my-large.cnf /etc/mysql/my.cnf
7)编辑/etc/mysql/my.cnf配置文件
在/etc/mysql/my.cnf配置文件中在[mysqld]标签中添加数据库存放目录。
datadir = /data/mysql
8)为MySQL提供服务脚本
[[email protected] mysql]# cpsupport-files/mysql.server /etc/rc.d/init.d/mysqld [[email protected] mysql]# chmod +x/etc/rc.d/init.d/mysqld [[email protected] mysql]# chkconfig --add mysqld [[email protected] mysql]# chkconfig mysqld on
9)设置mysql命令的环境变量
[[email protected] mysql]# vim/etc/profile.d/mysql.sh PATH=/usr/local/mysql/bin:$PATH [[email protected] mysql]# ./etc/profile.d/mysql.sh
10)设置mysql命令的man帮助手册
在/etc/man.cnf中添加如下一行
MANPATH/usr/local/mysql/man
11)导出mysql头文件至/usr/include
[[email protected] mysql]# ln -s /usr/local/mysql/include/mysql//usr/include/ 12)输出MySQL库文件 [[email protected] mysql]# echo‘/usr/local/mysql/lib‘ > /etc/ld.so.conf.d/mysql.conf [[email protected] mysql]# ldconfig
3、编译安装PHP
1)编译安装php
tar xf php-5.6.4.tar.xz cd php-5.6.4 ./configure --prefix=/usr/local/php--with-mysql=/usr/local/mysql --with-openssl--with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring--with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib--with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/apache/bin/apxs--with-mcrypt --with-config-file-path=/etc/php--with-config-file-scan-dir=/etc/php/php.d --with-bz2 --enable-maintainer-zts make && make install
2)提供php配置文件
[[email protected] php-5.6.4]# mkdir/etc/php/php.d -p [[email protected] php-5.6.4]# cpphp.ini-production /etc/php/php.ini
3)编辑apache配置文件httpd.conf,以apahce支持php
在/etc/apache24/httpd.conf添加如下两行:
AddType application/x-httpd-php .php AddType application/x-httpd-php-source.phps
定位至DirectoryIndex:
DirectoryIndex index.php index.html
三、配置LAMP
1、解压Discuz和phpMyadmin程序
[[email protected] tools]#mkdir /web [[email protected] tools]# unzipDiscuz_X3.2_SC_GBK.zip [[email protected] tools]# mv upload/ /web/discuz [[email protected] tools]# unzipphpMyAdmin-4.0.5-all-languages.zip [[email protected] tools]# mv phpMyAdmin-4.0.5-all-languages /web/pma
2、提供httpd虚拟机为www.blog.com和www.phpmysql.com
修改/etc/apache24/httpd.conf的配置文件,开启虚拟文件:
Include/etc/apache24/extra/httpd-vhosts.conf
在编辑/etc/apache24/extra/httpd-vhost.conf文件,内容如下:
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "/web/discuz" ServerName www.bbs.com ServerAlias bbs.com ErrorLog "logs/bbs.com-error_log" CustomLog "logs/bbs.com-access_log" combined <Directory "/web/discuz"> AllowOverride None Options None Require all granted </Directory> </VirtualHost> <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "/web/pma" ServerName www.phpmysql.com ServerAlias phpmysql.com ErrorLog "logs/phpmysql.com-error_log" CustomLog "logs/phpmysql.com-access_log" combined <Directory "/web/pma"> AllowOverride None Options None Require all granted </Directory> </VirtualHost>
3、重新加载httpd服务的配置文件
[[email protected] extra]# service httpd24 reload
4、添加用于BBS的数据库和设置管理MySQL的用户名和密码
MariaDB [(none)]> CREATE DATABASE bbs; Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> GRANT ALL ON bbs.* TO‘userbbs‘@‘localhost‘ IDENTIFIED BY ‘bbspass‘; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> GRANT ALL ON bbs.* TO‘userbbs‘@‘127.0.0.1‘ IDENTIFIED BY ‘bbspass‘; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> SET PASSWORD FOR‘root‘@‘localhost‘ =PASSWORD(‘mysql‘); Query OK, 0 rows affected (0.05 sec) MariaDB [(none)]> SET PASSWORD FOR‘root‘@‘127.0.0.1‘ =PASSWORD(‘mysql‘); Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)
四、浏览BBS和PHPMyAdmin
1、编辑客户端的hosts文件,添加如下内容
172.16.9.21 www.bbs.com 172.16.9.21 www.phpmysql.com
2、设置/web/discuz目录中相应目录的权限和属组
[[email protected]~]# cd /web/discuz/ [[email protected] discuz]# chown -R .daemon./config/ data/ uc_client/ uc_server/ [[email protected] discuz]# chmod g+w -R ./config/ data/ uc_client/ uc_server/
3、在输入浏览器中输入www.bbs.com就开始初始化BBS,输入相应的数据库名和密码后,点击安装。你就可以开始布置BBS了。
4、在浏览器输入www.phpmysql.com,使用root用户名登录,密码为mysql,登录后就可以管理MySQL数据库了。