trsgw 发表于 2015-5-7 08:28:30

基于编译安装LAMP架构---模块化

一、程序包和安装环境准备
1、程序版本:

1
2
3
4
5
6
7
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、准备安装开发环境

1
2
3
4
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程序包

1
2
3
4
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程序包

1
2
3
4
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程序包

1
2
3
4
5
6
# ./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
# make &&make install




4)创建apahce软链接

1
2
3
# ln -s /usr/local/apache-2.4.10//usr/local/apache
# ll /usr/local/apache
lrwxrwxrwx 1 root root 25 May3 11:27 /usr/local/apache ->/usr/local/apache-2.4.10/




5)提供服务脚本/etc/rc.d/init.d/httpd

1
2
3
4
5
6
7
8
9
修改httpd的配置文件中指定pid文件存放路径
         PidFile"/var/run/httpd.pid"
服务脚本通过复制系统原有的httpd服务脚本,在此基础上进行简单的修改,修改的内容如下:
# 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}
添加到开机自启动服务中:
# chkconfig --add httpd24
# chkconfig httpd24 on




6)设置httpd环境变量

1
2
3
# vim/etc/profile.d/httpd.sh
         PATH=/usr/local/apache/bin/:$PATH
# ./etc/profile.d/httpd.sh





2、安装通用二进制MariaDB
1)创建MariaDB运行的用户

1
2
# groupadd -r mysql
# useradd -r -g mysql mysql




2)创建数据库存放目录并设置属主、属组

1
2
# mkdir /data/mysql -p
# chown -Rmysql.mysql /data/mysql/




3)解压MariaDB程序包到/usr/local目录下

1
# tar xfmariadb-5.5.43-linux-x86_64.tar.gz -C /usr/local/




4)创建软链接

1
2
# cd /usr/local/
# ln -smariadb-5.5.43-linux-x86_64/ mysql




5)初始化数据库

1
2
3
# cd mysql
# chown -Rroot.mysql ./*
#scripts/mysql_install_db --datadir=/data/mysql/ --user=mysql




6)提供MySQL的主配置文件

1
2
# mkdir /etc/mysql
# cpsupport-files/my-large.cnf /etc/mysql/my.cnf




7)编辑/etc/mysql/my.cnf配置文件
在/etc/mysql/my.cnf配置文件中在标签中添加数据库存放目录。

1
datadir = /data/mysql




8)为MySQL提供服务脚本

1
2
3
4
# cpsupport-files/mysql.server /etc/rc.d/init.d/mysqld
# chmod +x/etc/rc.d/init.d/mysqld
# chkconfig --add mysqld
# chkconfig mysqld on




9)设置mysql命令的环境变量

1
2
3
# vim/etc/profile.d/mysql.sh
         PATH=/usr/local/mysql/bin:$PATH
# ./etc/profile.d/mysql.sh




10)设置mysql命令的man帮助手册
在/etc/man.cnf中添加如下一行

1
         MANPATH/usr/local/mysql/man




11)导出mysql头文件至/usr/include

1
2
3
4
# ln -s /usr/local/mysql/include/mysql//usr/include/
12)输出MySQL库文件
# echo'/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
# ldconfig




3、编译安装PHP
1)编译安装php

1
2
3
4
5
6
7
8
9
10
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配置文件

1
2
# mkdir/etc/php/php.d -p
# cpphp.ini-production /etc/php/php.ini




3)编辑apache配置文件httpd.conf,以apahce支持php
在/etc/apache24/httpd.conf添加如下两行:

1
2
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source.phps




定位至DirectoryIndex:

1
DirectoryIndex index.phpindex.html




三、配置LAMP
1、解压Discuz和phpMyadmin程序

1
2
3
4
5
#mkdir /web
# unzipDiscuz_X3.2_SC_GBK.zip
# mv upload/ /web/discuz
# unzipphpMyAdmin-4.0.5-all-languages.zip
# mv phpMyAdmin-4.0.5-all-languages/web/pma




2、提供httpd虚拟机为www.blog.com和www.phpmysql.com
修改/etc/apache24/httpd.conf的配置文件,开启虚拟文件:

1
Include/etc/apache24/extra/httpd-vhosts.conf




在编辑/etc/apache24/extra/httpd-vhost.conf文件,内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<VirtualHost *:80>
   ServerAdmin admin@bbs.com
   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 admin@phpmysql.com
   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服务的配置文件

1
# service httpd24 reload




4、添加用于BBS的数据库和设置管理MySQL的用户名和密码

1
2
3
4
5
6
7
8
9
10
11
12
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文件,添加如下内容

1
2
172.16.9.21 www.bbs.com
172.16.9.21 www.phpmysql.com




2、设置/web/discuz目录中相应目录的权限和属组


1
2
3
# cd /web/discuz/
# chown -R .daemon./config/ data/ uc_client/ uc_server/
# chmod g+w -R./config/ data/ uc_client/ uc_server/




3、在输入浏览器中输入www.bbs.com就开始初始化BBS,输入相应的数据库名和密码后,点击安装。你就可以开始布置BBS了。

4、在浏览器输入www.phpmysql.com,使用root用户名登录,密码为mysql,登录后就可以管理MySQL数据库了。


页: [1]
查看完整版本: 基于编译安装LAMP架构---模块化