Linux下apache+Tomcat6通过ajp无缝整合(部署至网站根目录)

  [转,题目]  Linux下apache+Tomcat6通过ajp无缝整合
(部署到网站根目录的配置)


    针对 apache 的配置目录 /etc/httpd/conf 下的 httpd.conf 修改,加入下面几项支持 ajp 协议对接

<VirtualHost *:80>
DocumentRoot /
ServerName www.langos.cn
ProxyPass / ajp://127.0.0.1:8009/
ProxyPassReverse / ajp://127.0.0.1:8009/
<Directory "/">
allow from all
Options +Indexes
</Directory>
</VirtualHost>

  上面是直接接管根目录, 不大常用这样做。 如果只接管某目录,可这样配置(多个):


<VirtualHost *:80>
DocumentRoot /liftweb
ServerName www.langos.cn
ProxyPass / ajp://127.0.0.1:8009/
ProxyPassReverse / ajp://127.0.0.1:8009/
<Directory "/liftweb">
allow from all
Options +Indexes
</Directory>
</VirtualHost>


 当然,更简单的可以这样配置(接管liftweb目录,但不完美,某些链接会另外指向:8080端口,链接里也不能直书 127.0.0.1 )
ProxyPass /liftweb http://114.215.186.34:8080/liftweb
ProxyPassReverse /liftweb http://114.215.186.34:8080/liftweb

(除直接外网IP地址,也可以用域名代替,不过同样存在不完美的问题)
ProxyPass /liftweb http://example.com:8080/liftweb
ProxyPassReverse /liftweb http://example.com:8080/liftweb

针对 tomcat6 的 server.xml 进行配置, 加在 <Host> 节里面
<Context path="" docBase="/var/lib/tomcat6/webapps/liftweb" reloadable="true" workDir="/var/cache/tomcat6/work" debug="0"/>



 现在应该  Okay 了,,  感谢网络上诸多大侠共享的配置参考资源, 由于太多,这里就不一一列出了,总之,非常感谢!


 ------------------------------------------------------

   网上百度了一下 yum 用法

   

1) yum -y install httpd php mysql mysql-server php-mysql
2) 为mysql设置密码:
mysqladmin -u root password 'ENTER-PASSWORD-HERE'
3) 使用mysql
mysql -u root -p 
输入密码后,即可在终端中使用mysql服务。
4) 设置开启启动mysql,httpd
/sbin/chkconfig httpd on 
/sbin/chkconfig --add mysqld 
/sbin/chkconfig mysqld on 
/sbin/service httpd start 
/sbin/service mysqld start
5) 测试 php是否安装成功。
在目录/var/www/html下,建立test.php,内容如下:
<?php
echo phpinfo(); 
?>

浏览器中输入:http://localhost/ 及 http://localhost/test.php  有内容,说明安装完成

 


  ●.设置 mysql数据库root帐号密码。
  mysqladmin -u root password 'newpassword' [引号内填密码]
  
  ●. 让mysql数据库更安全
  mysql -u root -p [此时会要求你输入刚刚设置的密码,输入后回车即可]
  
  mysql> DROP DATABASE test; [删除test数据库]
  mysql> DELETE FROM mysql.user WHERE user = ''; [删除匿名帐户]
  mysql> FLUSH PRIVILEGES; [重载权限]
  
  ●. 按照以上的安装方式, 配置出来的默认站点目录为/var/www/html/新建一个php脚本:
   phpinfo();
  ?>
  
   ●. 新建一个数据库,添加一个数据库用户,设置用户权限。写个php脚本测试一下数据库连接吧。
  mysql> CREATE DATABASE my_db; 
  mysql> GRANT ALL PRIVILEGES ON my_db.* TO 'user'@'localhost' IDENTIFIED BY 'password'; 
  
  
  
  //安 装apache扩展
  yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
  //安装php的扩展
  yum install php-gd
  yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
  // 安装mysql扩展
  yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

●, 如果命令行没有phpize,运行以下命令 
yum -y install php-devel

●,安装pdo
pecl install pdo
PHP_PDO_SHARED=1 pecl install pdo_mysql

pecl install PDO_SQLITE


●, 安装memcache
yum -y install php-pecl-memcache

●, 安装php-eaccelerator
yum install php-eaccelerator.i686



CentOS 5.x 系统下使用yum 升级php到5.2.x 最方便方法 
近期使用testlink 1.82 ,提及php需要升级到5.2以上,而centos 5.x目前提供php版本为5.1.6,
通过以下方法升级PHP到5.2比较方便,现推荐给大家。

先将以下地址导入。

# rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

# vi /etc/yum.repos.d/CentOS-Base.repo 增加下面信息

[utterramblings]
name=Jason's Utter Ramblings Repo
baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka

执行命令,自动升级。

yum update php -y
yum install libmcrypt -y


  下面是更换 yum [base] 源为更快的 163源的配置文件[vi  /etc/yum.repos.d/CentOS-Base.repo]:

[base]
name=CentOS-$releasever - Base - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6


#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6


#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6


#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6


#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - 163.com
baseurl=http://mirrors.163.com/centos/$releasever/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirror.centos.org/centos/RPM-GPG-KEY-CentOS-6

 

====================================================================================

我们首先介绍如何安装Ubuntu Apache。具体安装命令如下所示:

  $ sudo apt-get install apache2然后运行Ubuntu Apache,命令如下所示:

  $ sudo /etc/inIT.d/apache2 restartApache在安装期间将会新建一个目录:/var/www,该目录是该服务器中存放文档的根目录。只要在浏览器的地址栏输入http://localhost/或机器的IP地址就能访问放置在此目录中的所有文档。

  安装PHP

  PHP是一种流行的服务器端脚本语言,一般与MySQL或 Postgres结合起来用于管理Web内容、blog和论坛。下面介绍其安装方法,其实它的安装也很简单,命令如下所示:

 

$ sudo apt-get install libapache2-mod-php5重新启动 Ubuntu Apache 以加载上面安装的模块:

  $ sudo /etc/inIT.d/apache2 restart为了验证PHP模块是否正确加载,我们可以建立一个PHP文件,然后尝试通过Web服务器访问该文件。此外,我们知道PHP内建了一个phpinfo函数,该函数能够给出它的环境的详细信息。所以我们还可以利用下面的命令来检查PHP的工作情况:

  sudo sh -c "echo '''' > /var/www/info.php"之后,在浏览器地址栏键入http://localhost/info.php,然后回车,这时应该能看到一个颜面,给出刚才安装的PHP的详细信息。需要注意的是,如果在此过程中浏览器不显示页面,而是提示你下载文件,这就说明Ubuntu Apache没有正确加载PHP模块。解决问题的办法是,在/etc/apache2/apache2.conf 或 /etc/apache2/mods-enabled/php5.conf文件中加入下面一行命令:

  Ubuntu Apache application/x-httpd-php .php .phtml .php3加入上面的命令行后,为了保证Ubuntu Apache重新读取配置文件关闭,我们可以通过下面的命令将其关闭,然后再加以启动:

  $ sudo /etc/inIT.d/apache2 stop

  $ sudo /etc/inIT.d/apache2 start


 

1、sudo apt-get remove apache2
2、sudo apt-get remove apache2.2-common
3、sudo apt-get autoremove (此命令会自动卸载PHP)
卸载完成

 

 

 

==================================================

  如果在 Ubuntu Server 下,更换国内更快的指向163网站的 apt源

       [编辑   /etc/apt/sources.list ]

#deb cdrom:[Ubuntu-Server 13.04 _Raring Ringtail_ - Alpha amd64+mac (20130402)]/ raring main restricted

deb file:/media/iso/ raring main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.163.com/ubuntu/ raring main restricted
deb-src http://mirrors.163.com/ubuntu/ raring main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.163.com/ubuntu/ raring-updates main restricted
deb-src http://mirrors.163.com/ubuntu/ raring-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.163.com/ubuntu/ raring universe
deb-src http://mirrors.163.com/ubuntu/ raring universe
deb http://mirrors.163.com/ubuntu/ raring-updates universe
deb-src http://mirrors.163.com/ubuntu/ raring-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.163.com/ubuntu/ raring multiverse
deb-src http://mirrors.163.com/ubuntu/ raring multiverse
deb http://mirrors.163.com/ubuntu/ raring-updates multiverse
deb-src http://mirrors.163.com/ubuntu/ raring-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.163.com/ubuntu/ raring-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ raring-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu raring-security main restricted
deb-src http://security.ubuntu.com/ubuntu raring-security main restricted
deb http://security.ubuntu.com/ubuntu raring-security universe
deb-src http://security.ubuntu.com/ubuntu raring-security universe
deb http://security.ubuntu.com/ubuntu raring-security multiverse
deb-src http://security.ubuntu.com/ubuntu raring-security multiverse


 

`

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值