分享

LAMP架构(RPM包)+Tomcat - linux网络服务 - 赢得江湖威望

 tcwl123 2010-10-22
LAMP架构(RPM包)+Tomcat
LAMP架构中的L、A、M、P四个字母的意思是:
L:linux
A:apache
M:mysql
P:php/perl等等
所需RPM包:
httpd
php
php-mysql
mysql-server + PHP 站点的安装  
[root@tea net]# yum -y install httpd php php-mysql mysql-server 注意:这四个包得同时安装,才可以看到模块
1 apache要支持PHP页面的解析,是要给它加载一个libphp5.so的模块
[root@tea conf.d]# ls /etc/httpd/modules/libphp5.so
/etc/httpd/modules/libphp5.so
2 在apache的配置文件中要添加如下两行:
LoadModule php5_module modules/libphp5.so
DirectoryIndex index.php
3 restart apache
到/var/www/html目录下创建名为index.php的网页文件
[root@tea html]# vim index.php
[root@tea html]# pwd
/var/www/html
[root@tea html]# cat index.php
<?
        phpinfo();
?>
[root@tea html]# service httpd restart
访问测试:
http://202.100.1.158会看到PHP的页面。

 
 
--------------搭一个PHP的论坛-------------------
[root@tea src]# tar zxvf phpBB.tar.gz
[root@tea src]# ls phpBB
admin          faq.php         modcp.php
cache          groupcp.php     posting.php
cnphpbb.txt    images          privmsg.php
common.php     includes        profile.php
config.php     index.php       search.php
contrib        install         templates
db             language        viewforum.php
docs           login.php       viewonline.php
extension.inc  memberlist.php  viewtopic.php
[root@tea src]# cp -r phpBB /var/www/html/phpbb
http://192.168.1.254/phpbb
会自动地跳转到论坛的安装界面(主要是要设置跟数据库进行连接,动态的页面需要把信息记录到数据库)
http://192.168.1.254/phpbb/install/install.php

---------MYSQL---------------

[root@tea Server]# rpm -ivh mysql-server.....rpm
[root@tea Server]# /etc/init.d/mysqld start
初始化 MySQL 数据库: Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h tea.uplooking.com password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.
Support MySQL by buying support/licenses at http://shop.
                                                  [确定]
启动 MySQL:                                      [确定]
[root@tea Server]# rpm -qf `which mysql `
mysql-5.0.45-7.el5
[root@tea Server]# rpm -qf `which mysqladmin `
mysql-5.0.45-7.el5
[root@tea Server]# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database phpbb;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on phpbb.* to
phpbbuser@'localhost'  identified by 'phpbbuser';
Query OK, 0 rows affected (0.00 sec)
[root@tea phpbb]# ls config.php  -l
-rwxr-xr-x 1 root root 0 01-06 11:53 config.php
[root@tea phpbb]# chmod o+w config.php
[root@tea Server]# ls /var/lib/mysql/
ibdata1      ib_logfile1  mysql.sock  test
ib_logfile0  mysql        phpbb
[root@tea Server]# ls /var/lib/mysql/phpbb/
db.opt

安装论坛:


填好信息后点击下面的“开始安装”将出现如下界面:

点击“完成安装”,出现如下界面:

然后我们到/var/www/html/phpbb目录下把install/contrib两个目录删除掉即可。

点击论坛首页:

-----------------TOMCAT--------------------

1 安装jdk
[root@tea tomcat_package]# pwd
/usr/local/src/tomcat_package
[root@tea tomcat_package]# ls jdk-1_5_0_16-linux-i586.bin
jdk-1_5_0_16-linux-i586.bin
[root@tea tomcat_package]# chmod +x jdk-1_5_0_16-linux-i586.bin
[root@tea tomcat_package]# ./jdk-1_5_0_16-linux-i586.bin
[root@tea tomcat_package]# mv jdk1.5.0_16/  /usr/local
2 安装tomcat
[root@tea tomcat_package]# tar zxvf apache-tomcat-6.0.16.tar.gz
[root@tea tomcat_package]# ls apache-tomcat-6.0.16
bin   LICENSE  RELEASE-NOTES  webapps
conf  logs     RUNNING.txt    work
lib   NOTICE   temp
[root@tea tomcat_package]# mv apache-tomcat-6.0.16 /usr/local/
[root@tea apache-tomcat-6.0.16]# ls /usr/local/apache-tomcat-6.0.16/bin/shutdown.sh
/usr/local/apache-tomcat-6.0.16/bin/shutdown.sh
[root@tea apache-tomcat-6.0.16]# ls /usr/local/apache-tomcat-6.0.16/bin/startup.sh
[root@tea apache-tomcat-6.0.16]# export JRE_HOME=/usr/jdk1.5.0_16/
[root@tea apache-tomcat-6.0.16]# /usr/local/apache-tomcat-6.0.16/bin/startup.sh
Using CATALINA_BASE:   /usr/local/apache-tomcat-6.0.16
Using CATALINA_HOME:   /usr/local/apache-tomcat-6.0.16
Using CATALINA_TMPDIR: /usr/local/apache-tomcat-6.0.16/temp
Using JRE_HOME:       /usr/jdk1.5.0_16/
[root@tea apache-tomcat-6.0.16]# netstat -ntlp | grep 8080
tcp        0      0 :::8080                     :::*                        LISTEN      7581/java   
[root@tea apache-tomcat-6.0.16]# ls /usr/jdk1.5.0_16/bin/java
/usr/jdk1.5.0_16/bin/java

http://202.100.1.158:8080/

如果你在没有注册用户的情况下点击“Tomcat Manager”将报如下错误:
You are not authorized to view this page. If you have not changed any configuration files, please examine the file conf/tomcat-users.xml in your installation. That file will contain the credentials to let you use this webapp.
You will need to add manager role to the config file listed above. For example:
<role rolename="manager"/>
<user username="tomcat" password="s3cret" roles="manager"/>

注册用户:
[root@tea apache-tomcat-6.0.16]# vim conf/tomcat-users.xml
[root@tea apache-tomcat-6.0.16]# cat conf/tomcat-users.xml
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
<role rolename="manager"/>
<user username="tomcat" password="123" roles="manager"/>
</tomcat-users>
重新启动tomcat:

访问测试:点击“Tomcat Manager”,输入用户名和密码,将出现如下界面:

tomcat可以运行起来了,下面我们去部署一个Jive的jsp的站点
[root@tea tomcat_package]# tar zxvf JiveForumsPro4_crack.tar.gz
[root@tea tomcat_package]# ls -ld jive
drwxr-xr-x 16 root root 4096 2009-04-08 jive
[root@tea tomcat_package]# cd jive
[root@tea tomcat_package]# jar cvf jive1.war  .
cp -r jive  /usr/local/apache-tomcat-6.0.16/webapps
再重新启动tomcat,再登录tomcat manager将会看到如下部分:

点击其进入,并输入如下内容:

再点击下面的按钮:set jive home,出现如下画面,要确保没有报错:

在下面的方框里随意的输入一些内容,再点击下面的按钮并进入下一步:
然后再点击右下角的continue
继续点击右下角的continue

下面的工作就不能再做了,如果还想再做就得把jive连接到mysql数据库了

---------------配置jive连接Mysql数据库--------------
1 安装jdbc driver
[root@tea tomcat_package]# ls mysql-connector-java-3.1.14.tar.gz
[root@tea tomcat_package]# tar zxvf mysql-connector-java-3.1.14.tar.gz
[root@tea tomcat_package]# ls mysql-connector-java-3.1.14 -d
mysql-connector-java-3.1.14
[root@tea mysql-connector-java-3.1.14]# pwd
/usr/local/src/tomcat_package/mysql-connector-java-3.1.14
[root@tea mysql-connector-java-3.1.14]# cp mysql-connector-java-3.1.14-bin.jar /usr/local/apache-tomcat-6.0.16/webapps/jive/WEB-INF/lib/
2 创建一个数据库,并且建立一个用户让Jive可以连接数据库
[root@tea ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 265
Server version: 5.0.45 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database jivedb;
mysql> grant all on jivedb.* to  jiveuser@'localhost' identified by '123';
Query OK, 0 rows affected (0.06 sec)
[root@tea lib]# cd /usr/local/apache-tomcat-6.0.16/webapps/jive1/database/
[root@tea database]# ls jive_forums_mysql.sql
jive_forums_mysql.sql
[root@tea jive1]# mysql -u jiveuser -p  jivedb < database/jive_forums_mysql.sql
Enter password:

呵呵!继续上面截图的步骤:

继续点击右下角的continue,将出现如下界面:

我们继续点击右下角的continue,出现如下界面,我们输入email地址:

继续点击右下角的continue,出现如下界面:

此步骤我们跳过,点击skip this step,将出现如下界面,直接点击进入:

点击login to admin tool进入:

输入用户名和密码登录,默认情况下用户名和密码都是admin,进入后出现如下画面:

在这里我们可以对jive进行设置,呵呵!具体的设置步骤我就不说了啊!告诉你们一个秘密,具体怎么设置我也不怎么会,都他妈鸟文,谁懂啊!

我们都知道apache启用的是80端口,这里我们可以实现:
html格式的网页用apahce来解析
jsp格式的网页用tomcat来解析
这里apache需要调用一个模块
[root@tea tomcat_package]# tar zxvf jakarta-tomcat-connectors-jk2-2.0.4-src.tar.gz
解压得到:jakarta-tomcat-connectors-jk2-2.0.4-src目录,将该目录移到/usr/local目录下面并改名为tomcat-con
[root@tea native2]# pwd
/usr/local/tomcat-con/jk/native2
[root@tea native2]# ls
aclocal.m4      CHANGES.txt   Makefile.in
apr             common        README.txt
autom4te.cache  configure     scripts
buildconf.sh    configure.in  server
BUILD.txt       include       STATUS.txt
build.xml       INSTALL.txt   tomcat
CHANGES.html    jni
[root@tea native2]# yum -y install httpd-devel
[root@tea native2]# which apxs
/usr/sbin/apxs
[root@tea native2]# ./configure --with-apxs2=/usr/sbin/apxs
[root@tea native2]# make
12   $ ./configure --with-apxs2=PREFIX/bin/apxs
13   $ make
14   $ cd ../build/jk2/apache2
15   $ PREFIX/bin/apxs -n jk2 -i mod_jk2.so
[root@tea conf.d]# cp /usr/local/src/tomcat_package/tomcat-con/jk/build/jk2/apache2/mod_jk2.so /etc/httpd/modules/
cp:是否覆盖“/etc/httpd/modules/mod_jk2.so”? y
[root@tea conf]# grep jk2 /etc/httpd/conf/httpd.conf
LoadModule      jk2_module      modules/mod_jk2.so
[root@tea conf]# cp /usr/local/src/tomcat_package/tomcat-con/jk/conf/workers2.properties  /etc/httpd/conf
[root@tea conf.d]# vim /etc/httpd/conf/workers2.properties
127 [uri:/jive1/*]
128 info=Map the whole webapp
[root@tea conf.d]# service httpd restart
停止 httpd:                              [失败]
启动 httpd:                              [确定]

访问测试:http://202.100.1.158/jive/index.jsp

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多