LAMP+Tomcat+Discuz+WordPress整合
linux版本:
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise LinuxServer release 5.5 (Tikanga)
Release: 5.5
Codename: Tikang
Linux version 2.6.18-194.el5(mockbuild@x86-007.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat4.1.2-48)) #1 SMP Tue Mar 16 21:52:43 EDT 2010
Apache版本:Server version: Apache/2.2.19 (Unix)
安装包名称:httpd-2.2.19.tar.gz
Mysql版本: mysql Ver 14.14 Distrib 5.5.13, for Linux (i686) using EditLine wrapper
安装包名称:mysql-5.5.13.tar.gz
Php版本: PHP Version 5.3.6
安装包名称:php-5.3.6.tar.gz
Tomcat版本:Apache Tomcat/5.5.9
安装包名称:jakarta-tomcat-5.5.9.tar.gz
Discuz版本:Discuz! X2 正式版[20110629]
安装包名称:Discuz_X2_SC_UTF8.zip
WordPress版本:WordPress 3.2
安装包名称:wordpress-3.2.tar.gz
JDK版本: java version "1.6.0_25"
安装包名称: jdk-6u26-linux-i586-rpm.bin
其他下载:
1.Zlib2.Freetype3.Libpng4.Jpeg-6b5.GD Library6.cmake7.libmcrypt8.jakarta-tomcat-connectors9.apr10.apruti11.libtool等
安装确保以下系统相关库文件
gcc|gcc-c++|autoconf|automake|zlib*|libxml*|ncurses-devel|libmcrypt*|libtool*(libtool-ltdl-devel*)
rpm –qa |grep name【查询】
所有软件安装目录:/usr/local/ 源代码目录:/LAMP/
Mysql安装目录: /software/mysql/ 数据库目录: /storage/db/mysql_data
JDK安装
JDK版本: java version"1.6.0_25"
安装包名称: jdk-6u26-linux-i586-rpm.bin
[root@localhost LAMP]# ls
jdk-6u25-linux-i586-rpm.bin
[root@localhost LAMP]# chmod 755 jdk-6u26-linux-i586-rpm.bin
[root@localhost LAMP]# ./jdk-6u26-linux-i586-rpm.bin
Unpacking...
Checksumming...
Extracting...
……
Press Enter tocontinue.....
Done
[root@localhost LAMP]# ls
jdk-6u25-linux-i586.rpm jdk-6u25-linux-i586-rpm.bin
sun-javadb-client-10.6.2-1.1.i386.rpm sun-javadb-javadoc-10.6.2-1.1.i386.rpm
sun-javadb-core-10.6.2-1.1.i386.rpm sun-javadb-common-10.6.2-1.1.i386.rpm
sun-javadb-docs-10.6.2-1.1.i386.rpm sun-javadb-demo-10.6.2-1.1.i386.rpm
[root@localhostLAMP]# rpm -ivh jdk-6u26-linux-i586.rpm
Preparing... ########################################### [100%]
package jdk-1.6.0_25-fcs.i586 isalready installed
查看/usr/local/目录下是否有java目录
接下来编辑/etc/profile文件加入JDK环境变量,在文件末尾处加入以下内容:
[root@localhostLAMP]#vim /etc/profile
exportJAVA_HOME=/usr/java/jdk1.6.0_25
exportPATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin
exportCLASSPATH=:/usr/java/jdk1.6.0_25/lib:/usr/java/jdk1.6.0_25/jre/lib:$CLASSPATH
[root@localhost LAMP]# source /etc/profile
这样可以使配置文件的内容立刻生效;
如果JDK配置正确的话,运行上面的命令将会出现JDK的相应版本。
[root@localhost~]# java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) Client VM (build 20.0-b11, mixed mode, sharing)
参考:http://www.0817home.com/?post=168
Apache安装
Apache版本:Server version: Apache/2.2.19 (Unix)
安装包名称:httpd-2.2.19.tar.gz
[root@localhostLAMP]#tar -zxvfhttpd-2.2.19.tar.gz
[root@localhost LAMP]#cd httpd-2.2.19
[root@localhostLAMP]#./configure --prefix=/usr/local/apache--enable-shared=max --enable-module=rewrite --enable-module=so
[root@localhost LAMP]#make
[root@localhost LAMP]#make install
修改配置文件
[root@localhost LAMP]#vim /usr/local/apache/conf/httpd.conf
ServerName127.0.0.1:80
<IfModuledir_module>
DirectoryIndexindex.html index.html.var index.htm index.php
</IfModule>
# If the AddEncodingdirectives above are commented-out, then you
# probably shoulddefine those extensions to indicate media types:
AddTypeapplication/x-compress .Z
AddTypeapplication/x-gzip .gz .tgz
AddTypeapplication/x-httpd-php .php
AddTypeapplication/x-httpd-php-source .phps
到此结束,启动参数
/usr/local/apache/bin/apachectlstart
/usr/local/apache/bin/apachectlstop
/usr/local/apache/bin/apachectlrestart
后面参考[可能有错误]:
[root@localhost LAMP]# cp /usr/local/apache/bin/apachectl /etc/init.d/apachectl
[root@localhost LAMP]# ln -s /usr/local/apache/bin/apachectl /usr/bin/apachectl
进入/etc目录下的rc2.d rc3.d rc4.d rc5.d 目录建立开机自启动服务的软链接文件;
[root@localhost etc]# ln -s ../init.d/apachectlS20apache
进入/etc目录下的rc0.d rc1.d rc6.d 目录建立关机自停止服务的软链接文件;
[root@localhost etc]# ln -s ../init.d/apachectlK20apache
Mysql安装
Mysql版本:
mysql Ver 14.14 Distrib 5.5.13, for Linux (i686)using EditLine wrapper
安装包名称:mysql-5.5.13.tar.gz
tar -zxvf cmake-2.8.5.tar.gz
cd cmake-2.8.5
./bootstrap
make
make install
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --prefix=/usr/local/libmcrypt
make
make install
安装Mysql
[root@mail ~]# groupadd mysql
[root@mail ~]# useradd -g mysql -s /sbin/nologin mysql
[root@mail ~]# mkdir -p /storage/db/mysql_data
[root@mail ~]# mkdir -p /software/mysql
[root@mail ~]# mkdir -p /etc/mysql
[root@mail opt]# tar zxvf mysql-5.5.13.tar.gz
[root@mail opt]# cd mysql-5.5.13
[root@mailmysql-5.5.13]# cmake . -DCMAKE_INSTALL_PREFIX=/software/mysql/ -DMYSQL_DATADIR=/storage/db/mysql_data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all -DWITH_SSL=system -DWITH_ZLIB=system-DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1-DWITH_MYISAM_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc/mysql -DMYSQL_TCP_PORT=7454 -DWITH_DEBUG=0 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1-DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1
【openssl未安装成功】
[root@mailmysql-5.5.13]# make &&make install
[root@mailmysql-5.5.13]# cp./support-files/my-innodb-heavy-4G.cnf /etc/mysql/my.cnf
[root@mailmysql-5.5.13]# chown -R mysql/storage/db/mysql_data/
[root@mailmysql-5.5.13]# chgrp -R mysql/storage/db/mysql_data/
[root@mailmysql-5.5.13]#/software/mysql/scripts/mysql_install_db --basedir=/software/mysql/--user=mysql --datadir=/storage/db/mysql_data/
[root@mailmysql-5.5.13]# cp./support-files/mysql.server /etc/init.d/mysqld【注意路径】
[root@mailmysql-5.5.13]# chmod 755/etc/init.d/mysqld
[root@mailmysql-5.5.13]# vim/etc/init.d/mysqld
basedir=/software/mysql
datadir=/storage/db/mysql_data
[root@mailmysql_data]# /etc/init.d/mysqldstart
StartingMySQL[ OK ]
[root@mail bin]# vim /etc/profile
exportPATH=$PATH:/software/mysql/bin
[root@mail bin]# source /etc/profile
[root@mail bin]# mysql
Welcome to theMySQL monitor. Commands end with ; or\g.
Your MySQLconnection id is 2
Server version:5.5.13-log Source distribution
Copyright (c)2000, 2010, Oracle and/or its affiliates. All rights reserved.
Oracle is aregistered trademark of Oracle Corporation and/or its
affiliates. Othernames may be trademarks of their respective
owners.
Type 'help;' or'\h' for help. Type '\c' to clear the current input statement.
mysql>
[root@mail ~]# chkconfig mysqld on
[root@mail ~]# chkconfig --level 24 mysqld off
[root@mail ~]# chkconfig --list mysqld
mysqld 0:off 1:off 2:off 3:on 4:off 5:on 6:off
[root@mail lib]# vim /etc/ld.so.conf
/software/mysql/lib
[root@mail ~]# ldconfig -v |grep mysql
/software/mysql/lib:
libmysqlclient.so.18 ->libmysqlclient_r.so.18.0.0
参考:
http://heylinux.com/archives/993.html
http://blog.sina.com.cn/s/blog_48f9c0840100oi8k.html
Php安装
Php版本:
PHP Version 5.3.6
安装包名称:php-5.3.6.tar.gz
编译PHP前安装GD库相关套件【点此下载】
[root@localhost LAMP]# tar zxvf zlib-1.2.5.tar.gz
[root@localhost zlib-1.2.5]#cd zlib-1.2.5
[root@localhost zlib-1.2.5]#./configure --prefix=/usr/local/zlib/
[root@localhost zlib-1.2.5]#make
[root@localhost zlib-1.2.5]#make install
[root@localhost LAMP]#tar zxvf freetype-2.4.3.tar.gz
[root@localhost freetype-2.4.3]#cd freetype-2.4.3
[root@localhost freetype-2.4.3]#./configure --prefix=/usr/local/freetype
[root@localhost freetype-2.4.3]#make
[root@localhost freetype-2.4.3]#make install
[root@localhost LAMP]#tar zxvf libpng-1.5.2.tar.gz
[root@localhost LAMP]#cd libpng-1.5.2
[root@localhost libpng-1.5.2]#./configure –prefix=/usr/local/libpng
[root@localhost libpng-1.5.2]#make
[root@localhost libpng-1.5.2]#make install
[root@localhost LAMP]#tar -zxvf jpegsrc.v8c.tar.gz
[root@localhost LAMP]#cd jpeg-8c/
[root@localhost jpeg-8c]#mkdir -p /usr/local/jpeg/bin
[root@localhost jpeg-8c]#mkdir -p /usr/local/jpeg/lib
[root@localhost jpeg-8c]#mkdir -p /usr/local/jpeg/include
[root@localhost jpeg-8c]#mkdir -p /usr/local/jpeg/man/man1
[root@localhost jpeg-8c]#./configure --prefix=/usr/local/jpeg--enable-shared --enable-static
[root@localhost jpeg-8c]#make
[root@localhost jpeg-8c]#make install
[root@localhost LAMP]#tar zxvf gd-2.0.33.tar.gz
[root@localhost LAMP]#cd gd-2.0.33
[root@localhostgd-2.0.33] 修改当前目录下的gd_png.c
vigd_png.c
进入该文件,找到“png.h”改成“/usr/local/libpng/include/png.h”)
[root@localhost gd-2.0.33]#./configure --prefix=/usr/local/gd--with-jpeg=/usr/local/jpeg --with-freetype=/usr/local/freetype --with-png=/usr/local/libpng
[root@localhost gd-2.0.33]#make
[root@localhost gd-2.0.33]#make install
安装libxml2
[root@localhost LAMP]# tar –zxvf libxml2-2.7.2.tar.gz
[root@localhost LAMP]#cd libxml2-2.7.2
[root@localhost libxml2-2.7.2]# ./configure –prefix=/usr/local/libxml
[root@localhost libxml2-2.7.2]# make
[root@localhost libxml2-2.7.2]# make install
安装PHP
[root@localhost LAMP]#tar zxvfphp-5.3.6.tar.gz
[root@localhost LAMP]#cd php-5.3.6
[root@localhost php-5.3.6]#cd /root/LAMP/php-5.3.6/ext/gd/libgd
[root@localhost libgd]#vi gd_compat.c
[root@localhost libgd]# cd /root/LAMP/php-5.3.6
[root@localhost php-5.3.6]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs--with-gd=/usr/local/gd --enable-gd-native-ttf --with-jpeg-dir=/usr/local/jpeg --with-zlib --with-freetype-dir=/usr/local/freetype--enable-magic-quotes --with-mysql=/software/mysql--with-mysql-sock=/tmp/mysql.sock --with-iconv --enable-mbstring --enable-ftp--with-config-file-path=/usr/local/php/etc --with-pear=/usr/local/php/pear--enable-sockets --with-libxml-dir=/usr/local/libxml/
[root@localhost php-5.3.6]#cd/LAMP/php-5.3.6/
[root@localhost php-5.3.6]#make
[root@localhost php-5.3.6]#make install
[root@localhost php-5.3.6]#cpphp.ini-development /usr/local/php/etc/php.ini 【cp php-x.x.x/php.ini-dist /opt/php/etc/php.ini 新版的 php.ini-development相当于旧版本的php.ini-dist】
[root@localhost LAMP]#vimphp.ini
修改配置文件vim /usr/local/php/etc/php.ini:
register_globals = On
然后编写php测试页info.php:内容如下:
<?php
phpinfo();
?>
查看/usr/local/apache/conf/httpd.conf文件,看是否存在语句(如果安装的Php5):
LoadModule php5_module modules/libphp5.so
如果存在,即说明apache已经成功加载了php模块;
【重启apache服务】
# apachectl restart
将info.php放置到/usr/local/apache/htdocs 目录下;
# chmod 755 info.php
在浏览器中能在该页面中看到php的信息则说明安装成功!
注:启用了SELinux的FC或RedHat会提示权限问题并导致Php无法正常工作,禁用SELinux后重启系统即可解决问题。
Tomcat安装
tomcat版本:
ApacheTomcat/5.5.9
安装包名称:jakarta-tomcat-5.5.9.tar.gz
点此下载:【apr、aprutil、libtool、jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz】
安装tomcat
[root@localhost LAMP]#tar zxvf jakarta-tomcat-5.5.9.tar.gz
[root@localhost LAMP]#cd jakarta-tomcat-5.5.9
[root@localhost LAMP]#mkdir -p/usr/local/tomcat/
[root@localhost LAMP]#cp -rf * /usr/local/tomcat/【拷贝所有解压出来的文件到/usr/local/tomcat/】
[root@localhost LAMP]#cd /usr/local/tomcat/bin
[root@localhost bin]#./startup.sh 【启动tomcat】
[root@localhost bin]#./shutdown.sh 【停止tomcat】
安装apr、aprutil、libtool
安装apr
[root@localhost LAMP]#tar zxvf apr-1.4.5.tar.gz
[root@localhost LAMP]#cd apr-1.4.5
[root@localhost apr-1.4.5]#./configure --prefix=/usr/local/apr【最好指定安装目录】
[root@localhost apr-1.4.5]#make
[root@localhost apr-1.4.5]#make install
安装aprutil
[root@localhost LAMP]# tar zxvf apr-util-1.3.12.tar.gz
[root@localhost LAMP]#cd apr-util-1.3.12
[root@localhost apr-util-1.3.12]# ./configure --prefix=/usr/local/aprutil--with-apr=/usr/local/apr【最好指定安装目录】
[root@localhost apr-util-1.3.12]# make
[root@localhost apr-util-1.3.12]# make install
安装完apr和aprutil后
[root@localhost apr-util-1.3.12]# ln-s/usr/local/apr/lib/libapr-1.so.0.4.5 /usr/local/apache/lib/libapr-1.so
[root@localhost apr-util-1.3.12]# ln-s/usr/local/apr/lib/libapr-1.so.0.4.5 /usr/local/apache/lib/libapr-1.so.0
[root@localhost apr-util-1.3.12]# ln-s/usr/local/aprutil/lib/libaprutil-1.so.0.3.12/usr/local/apache/lib/libaprutil-1.so
[root@localhost apr-util-1.3.12]# ln-s/usr/local/aprutil/lib/libaprutil-1.so.0.3.12/usr/local/apache/lib/libaprutil-1.so.0
安装libtool
[root@localhost LAMP]#tar zxvf libtool-2.4.tar.gz
[root@localhost LAMP]#cd libtool-2.4
[root@localhost libtool-2.4]#./configure --prefix=/usr/local/libtool
[root@localhost libtool-2.4]#make
[root@localhost libtool-2.4]#make install
[root@localhost libtool-2.4]#cd /usr/local/apache/build/
[root@localhost build]# rm -rf libtool【删除旧版本的libtool】
[root@localhost build]# ln-s /usr/local/libtool/bin/libtool /usr/local/apache/build/libtool
安装jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz
[root@localhost LAMP]#tar zxvfjakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz
[root@localhost LAMP]#cd jakarta-tomcat-connectors-jk2-2.0.4-src/jk/native2/
[root@localhost native2]#./configure--with-apxs2=/usr/local/apache/bin/apxs 【注意apxs的路径】
[root@localhost native2]# make【一定记得make,否则找不到build/jk2/mod_jk2.so囧 我当时就忘了。】
[root@localhost native2]cd../build/jk2/apache2/
[root@localhost native2]/usr/local/apache/bin/apxs-n jk2 -i mod_jk2.so 【将mod_jk2.so添加到apache2的modules中】
[root@localhost native2]cd /usr/local/apache/modules/
[root@localhost modules]chmod755 mod_jk2.so
上面就完成了Tomcat和Connectors的安装.
接下来进行与Apache的整合
[root@localhost LAMP]#cd /usr/local/apache/conf/
[root@localhost conf]#vimhttpd.conf
加入LoadModulejk2_modulemodules/mod_jk2.so
然后在这个目录新建一文件workers2.properties
[root@localhost conf]#vim workers2.properties
[channel.socket:localhost:8009]
port=8009
host=localhost
[ajp13:localhost:8009]
channel=channel.socket:localhost:8009
[uri:/*.jsp]
worker=ajp13:localhost:8009
[uri:/examples/*jsp]
worker=ajp13:localhost:8009
[root@localhost conf]#cd /usr/local/tomcat/conf/
[root@localhost conf]#vim server.xml
找到其中的<Host>中的<Contest>项,修改相关参数如下,保存退出;
<Context path=""docBase="/usr/local/apache/htdocs" debug="0" reloadable="true" crossContext="true"/>
[root@localhost conf]# /usr/local/tomcat/bin/startup.sh 【启动tomcat】
[root@localhost conf]# /usr/local/apache/bin/apachectl restart【重启apache】
[root@localhost conf]# /etc/init.d/mysqld start 【启动mysql】
整合完毕
以下内容参考:
Mysql 设置数据库密码
[root@localhost conf]#/etc/init.d/mysqld start
[root@localhost conf]#mysqladmin -u rootpassword"7710405"
[root@localhost conf]#mysql –u root –p
输入密码回车进入mysql
mysql 新建数据库
CREATE DATABASE databasename;
Mysql 继承权限
GRANT ALL PRIVILEGES ON databasename.* TO wordpressusername@hostnameIDENTIFIED BY password;
删除数据库
Drop database databasename
遇到了 SQLException:accessdenied for @'localhost' (using password:no)
grant all privileges on *.* tojoe@localhost identified by '1';
grant all privileges on databasename.* to beimingluntan@identified by '1';
GRANT ALL PRIVILEGES ON beimingluntan.* TO 'beimingluntan'@'localhost' IDENTIFIED BY 'beiminglunadmin##'WITH GRANT OPTION
flush privileges;【刷新数据库】
附:
mysql> grant 权限1,权限2,…权限n on 数据库名称.表名称 to 用户名@用户地址 identified by ‘连接口令’;
权限1,权限2,…权限n对应
select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file等14个权限。
当权限1,权限2,…权限n被all privileges或者all代替,表示赋予用户全部权限。
当数据库名称.表名称被*.*代替,表示赋予用户操作服务器上所有数据库所有表的权限。
用户地址可以是localhost,也可以是ip地址、机器名字、域名。也可以用’%'表示从任何地址连接。
连接口令’不能为空,否则创建失败。
mysql>grantselect,insert,update,delete,create,drop onvtdc.employee to joe@10.163.225.87identified by ‘123′;
给来自10.163.225.87的用户joe分配可对数据库vtdc的employee表进行select,insert,update,delete,create,drop等操作的权限,并设定口令为123。
mysql>grant all privilegeson vtdc.* to joe@10.163.225.87identified by ‘123′;
给来自10.163.225.87的用户joe分配可对数据库vtdc所有表进行所有操作的权限,并设定口令为123。
mysql>grant allprivileges on *.* to joe@10.163.225.87identified by ‘123′;
给来自10.163.225.87的用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。
mysql>grant allprivileges on *.* to joe@localhost identified by‘123′;
给本机用户joe分配可对所有数据库的所有表进行所有操作的权限,并设定口令为123。
安装discuz【安装过程可参考discuz论坛】
把安装包上传上去【upload文件夹然后改权限chmod 777 使文件可以访问,访问install目录开始安装】
[root@localhost conf]#cd /usr/local/apache/htdocs/luntan/upload
[root@localhost upload]#chmod –R 777 *
[root@localhost upload]#cp config_global_default.php config_global.php【提示找不到config_global.php和config_ucenter.php】
[root@localhost upload]#cp config_ucenter_default.php config_ucenter.php
安装WordPress【安装过程可参考WP论坛】
注意需要手动建立数据库【参考mysql命令】