Apache + resin + pureftp virtual host and load balancing

Source: Internet
Author: User
Article Title: apache + resin + pureftp virtual host and Server Load balancer. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   1. Preface
  
You are familiar with apache + resin and general configurations. I have read some articles on the Forum, which is more convenient. Here, I only need to write apache + resin to implement independent virtual hosts and load balancing of resin.
  
   2. system and environment:
  
Redhat9 and solaris9
Httpd-2.50
Resin-1, 3.06
Pure-ftpd-1.0.17a.tar.gz
  
   3. Install software:
  
3.1 install apache:
  
# Tar zxvf httpd-2.49.tar.gz
# Cd httpd-2.49
#./Configure -- prefix =/usr/local/apache2 -- enable-so -- with-mpm = worker
# Make
# Make install
  
3.2 install resin:
  
# Tar zxvf resin-3.06.tar.gz
# Cd resin03.06
#./Configure -- prefix =/usr/local/resin -- with-apxs =/usr/local/apache2/bin/apxs
# Make
# Make install
  
3.3 install pureftp
  
# Tar zxvf pure-ftpd-1.0.17a.tar.gz
# Cd pure-ftpd-1.0.17a
#./Configure -- prefix =/usr/local/pureftpd
-- Without-inetd -- with-puredb
-- With-cookie -- with-throttling
-- With-ratios -- with-quotas
-- With-ftpwho -- with-largefile
-- With-welcomemsg
# Make
# Make install
# Mkdir/usr/local/pureftpd/etc
  
   4. Configuration Software:
  
Objective: To use apache and resin as domain name-based virtual hosts and enable the Server Load balancer engine of resin. The resin Server Load balancer engine can actually start multiple java response processes and conduct Load Balancing through internal mechanisms.
  
4.1 configure apache:
  
# Vi/usr/local/apache2/conf/httpd. conf
---------------------------------------
DirctoryIndex index.html index. jsp
Adddefacharcharset Off
User nobody
Group nobody
NamevirtualHost 211.11.11.11
  
ServerAdmin peng.zhang@bj.china.com
DocumentRoot/data/web/xcity
ServerName xcity.chinaunix.com
ErrorLog logs/xcity.chinaunix.com-error_log
CustomLog logs/xcity.chinaunix.com-access_log common
  
ServerAdmin peng.zhang@bj.china.com
DocumentRoot/data/web/sports
ServerName sports.chinaunix.com
ErrorLog logs/sports.chinaunix.com-error_log
CustomLog logs/sports.chinaunix.com-access_log common
  
........
....
# Mod_caucho Resin Configuration
#
  
LoadModule caucho_module/usr/local/apache2/modules/mod_caucho.so
  
ResinConfigServer 127.0.0.1
---------------------------------------
  
4.2 configure resin:
  
# Vi/usr/local/resin/conf/resin. conf
----------------------------------------
  
--- Annotation:
(In this case, I used 127.0.0.1 of the system, and bound four ports to achieve the balance. You can also use different ip addresses and the same port. For example:
  
Some people prefer to set a virtual machine for every java Process service in apache. We do not recommend it here. Doing so will lose the meaning of the engine itself .)
  
/Data/web/xcity
  
/Opt/web/sports
  
........
....
  
--------------------------------------------------
  
--- Note: This is a domain name-based VM. If it is an ip-based Vm, it should be the ip address of the VM. That is to say, apache and resin should be consistent about the VM. Also, in resin, the web-app directory used by each virtual host is actually relative to the/directory under her home directory.
  
4.3 configure pureftp
1. Add a user:
# Pure-pw useradd xcityr-f/usr/local/pureftp/etc/ftppasswd-u nobody-g nobody-d/data/web/xcity-m
  
# Pure-pw useradd sports-f/usr/local/pureftp/etc/ftppasswd-u nobody-g nobody-d/data/web/sports-m
  
--- Note: xcity: ftp user
-F ftppasswd: file for storing user password information
-U user uid is generally a system user, which is the user of your ftp user's home directory.
-G user group id
-D. Lock the user's home directory
-M writes pureftp. d. passwd into pureftpd. pdb for the change to take effect.
  
* Modify a user:
# Pure-pw usermod -- help
  
* Delete A User:
# Pure-pw userdel [-f] [-m]
  
* Change the password:
  
# Pure-pw passwd [-f] [-m]
  
* View User details:
  
# Pure-pw show [-f]
  
* Generate a db file for the password to take effect:
# Pure-pw mkdb [[-f]
  
* List all users:
# Pure-pw list [-f]
  
   5. STARTUP script:
  
When the system is under solaris:
  
Apache and resin startup scripts:
# Vi/etc/rc2.d/S99webapp
-------------------------------
/Usr/local/resin/bin/httpd. sh-pid srun1.pid-server a start
/Usr/local/resin/bin/httpd. sh-pid srun2.pid-server B start
/Usr/local/resin/bin/httpd. sh-pid srun3.pid-server c start
/Usr/local/resin/bin/httpd. sh-pid srun4.pid-server d start
/Usr/local/apache2/bin/apachectl start
--------------------------------
  
Pureftp STARTUP script:
--------------------------------
#! /Bin/sh
  
/Usr/local/pureftpd/sbin/pure-ftpd-j-lpuredb:/usr/local/pureftpd/etc/pureftpd. pdb &
-----------------------------------
  
In linux, it is OK to directly put it under the boot level directory of the response.
  
   6. Summary
  
Apache + resin should be a good java application platform. In practice, there are still many skills. I read some materials from the resin official forum, saying that resin3.x and later versions support image and html, which is faster than apache. I have tested this and I still feel a little lacking. Therefore, it is better to combine apache and resin on a large-scale release platform.
For the number of processes started on resin server Load balancer, I think it is still necessary to consider it based on the actual situation of your machine. If it is less than the effect, the machine system is also a load. In my opinion, four can be considered as a default choice.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.