search
HomeBackend DevelopmentPHP TutorialThe host runs both JSP and PHP

The host runs both JSP and PHP

Nov 22, 2016 pm 04:26 PM
tomcat

The unit needs a php project, but there is only one domain name. The server operating system is redhat 4.7 and tomcat has been deployed. It is impossible to redo or merge it, but it must share the same host. I thought of using apache http server. jk connected to tomcat, installed php and mysql, it took a lot of time, and finally succeeded, the records are as follows:
1. Redhat4.7 installs yum
Redhat4.7 does not have yum installed by default. It is indeed better to install software with yum than rpm. It’s convenient and you don’t have to worry about dependencies, but sometimes the package can’t be found.
Redhat5 has yum installed by default, just configure it directly
Download yum wget http://www.parallels.com.cn/downloads/Prima/Tools/yum_forAS4.tar.gz
Unzip tar xzvf yum_forAS4.tar. gz
Enter the directory cd yum_forAS4 #
Installation rpm -ivh *.rpm
cd /etc/yum.repos.d/
vi CentOS-Base.repo

# CentOS-Base.repo
[base]
name=CentOS-4.7 - Base - mirrors.ustc.edu.cn
baseurl=http://vault.centos.org/4.7/os/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-4
#released updates
[updates]
name=CentOS-4.7 - Updates - mirrors.ustc.edu.cn
baseurl=http://vault.centos.org/4.7/updates/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-4
#additional packages that may be useful
[extras]
name=CentOS-4.7 - Extras - mirrors.ustc.edu.cn
baseurl=http://vault.centos.org/4.7/extras/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-4
#packages used/produced in the build but not released
[addons]
name=CentOS-4.7 - Addons - mirrors.ustc.edu.cn
baseurl=http://vault.centos.org/4.7/addons/$basearch/
gpgcheck=1
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-4
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-4.7 - Plus - mirrors.ustc.edu.cn
baseurl=http://vault.centos.org/4.7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-4
#contrib - packages by Centos Users
[contrib]
name=CentOS-4.7 - Contrib - mirrors.ustc.edu.cn
baseurl=http://vault.centos.org/4.7/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://vault.centos.org/RPM-GPG-KEY-CentOS-4

yum makecache
yum is installed, you can use yum -y in the future install command to install software, which is very convenient.

2. Install apache, php, mysql
yum -y install httpd httpd-devel php mysql mysql-server php-mysql httpd-manual mod_ssl mod_perl mod_auth_mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php- pear php-xmlrpc mysql-connector-odbc mysql-devel libdbi-dbd-mysql
Install them all with one command. The php-mcrypt package is not installed. There will be a warning in phpMyAdmin, so install it.
Look for the following packages at http://rpm.pbone.net/:
libmcrypt-2.5.7-5.el4.i386.rpm
php-common-5.3.10-2.el4.remi.i386.rpm
php-mcrypt-4.3.9-1.el4.i386.rpm
Install the above package.
The apache configuration file is installed in /etc/httpd/conf, and the WEB directory is installed in /var/www/
Start: service httpd start
Stop: service httpd stop
mysql Start service mysqld start Stop service mysql stop
Set mysql account and password (omitted)

3. Compile and install tomcat connectors
wget tomcat-connectors-1.2.37-src.tar.gz
cd tomcat-connectors-1.2.37-src
cd native
Read the BUILDING.txt file carefully, as mentioned in the article If you need apxs, this program is installed in the httpd-devel package. To find the location of apxs, use
rpm -ql httpd-devel
...
/usr/sbin/apxs
...
In fact, apache http server can The executable files are placed in the /usr/sbin/ directory, which is in the PATH environment variable.
./configure --with-apxs=/usr/sbin/apxs
make
generated two directories, apache-1.3 and apache-2.0, in the current directory. We are using apache2.0
cd apache-2.0
cp mod_jk.so /etc/httpd/modules/

4. Configure jk.
(1) Create workers.properties configuration file
cd /etc/httpd/conf
vi workers.properties

# Define 1 real worker using ajp13
worker.list=worker1
# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009

(2) Edit httpd.conf

Add the following line under the loading module paragraph

# Load mod_jk module
# Update this path to match your modules location
LoadModule    jk_module  modules/mod_jk.so
# Where to find workers.properties
# Update this path to match your conf directory location (put workers.properties next to httpd.conf)
JkWorkersFile /etc/httpd/conf/workers.properties
# Where to put jk shared memory
# Update this path to match your local state directory or logs directory
JkShmFile     /var/log/httpd/mod_jk.shm
# Where to put jk logs
# Update this path to match your logs directory location (put mod_jk.log next to access_log)
JkLogFile     /var/log/httpd/mod_jk.log
# Set the jk log level [debug/error/info]
JkLogLevel    info
# Select the timestamp log format
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
# Send everything for context /examples to worker named worker1 (ajp13)
JkMount  /examples/* worker1

Restart apache


Test:
It can be accessed through the tomcat port, and the same content can also be accessed through the apache port.
If you use a firewall, remember to open port 8009 of lo
-A INPUT -i lo -p tcp -m tcp --dport 8009 -j ACCEPT
Okay, put it here, and you won’t be unable to find it next time you configure it .

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
What is the difference between unset() and session_destroy()?What is the difference between unset() and session_destroy()?May 04, 2025 am 12:19 AM

Thedifferencebetweenunset()andsession_destroy()isthatunset()clearsspecificsessionvariableswhilekeepingthesessionactive,whereassession_destroy()terminatestheentiresession.1)Useunset()toremovespecificsessionvariableswithoutaffectingthesession'soveralls

What is sticky sessions (session affinity) in the context of load balancing?What is sticky sessions (session affinity) in the context of load balancing?May 04, 2025 am 12:16 AM

Stickysessionsensureuserrequestsareroutedtothesameserverforsessiondataconsistency.1)SessionIdentificationassignsuserstoserversusingcookiesorURLmodifications.2)ConsistentRoutingdirectssubsequentrequeststothesameserver.3)LoadBalancingdistributesnewuser

What are the different session save handlers available in PHP?What are the different session save handlers available in PHP?May 04, 2025 am 12:14 AM

PHPoffersvarioussessionsavehandlers:1)Files:Default,simplebutmaybottleneckonhigh-trafficsites.2)Memcached:High-performance,idealforspeed-criticalapplications.3)Redis:SimilartoMemcached,withaddedpersistence.4)Databases:Offerscontrol,usefulforintegrati

What is a session in PHP, and why are they used?What is a session in PHP, and why are they used?May 04, 2025 am 12:12 AM

Session in PHP is a mechanism for saving user data on the server side to maintain state between multiple requests. Specifically, 1) the session is started by the session_start() function, and data is stored and read through the $_SESSION super global array; 2) the session data is stored in the server's temporary files by default, but can be optimized through database or memory storage; 3) the session can be used to realize user login status tracking and shopping cart management functions; 4) Pay attention to the secure transmission and performance optimization of the session to ensure the security and efficiency of the application.

Explain the lifecycle of a PHP session.Explain the lifecycle of a PHP session.May 04, 2025 am 12:04 AM

PHPsessionsstartwithsession_start(),whichgeneratesauniqueIDandcreatesaserverfile;theypersistacrossrequestsandcanbemanuallyendedwithsession_destroy().1)Sessionsbeginwhensession_start()iscalled,creatingauniqueIDandserverfile.2)Theycontinueasdataisloade

What is the difference between absolute and idle session timeouts?What is the difference between absolute and idle session timeouts?May 03, 2025 am 12:21 AM

Absolute session timeout starts at the time of session creation, while an idle session timeout starts at the time of user's no operation. Absolute session timeout is suitable for scenarios where strict control of the session life cycle is required, such as financial applications; idle session timeout is suitable for applications that want users to keep their session active for a long time, such as social media.

What steps would you take if sessions aren't working on your server?What steps would you take if sessions aren't working on your server?May 03, 2025 am 12:19 AM

The server session failure can be solved through the following steps: 1. Check the server configuration to ensure that the session is set correctly. 2. Verify client cookies, confirm that the browser supports it and send it correctly. 3. Check session storage services, such as Redis, to ensure that they are running normally. 4. Review the application code to ensure the correct session logic. Through these steps, conversation problems can be effectively diagnosed and repaired and user experience can be improved.

What is the significance of the session_start() function?What is the significance of the session_start() function?May 03, 2025 am 12:18 AM

session_start()iscrucialinPHPformanagingusersessions.1)Itinitiatesanewsessionifnoneexists,2)resumesanexistingsession,and3)setsasessioncookieforcontinuityacrossrequests,enablingapplicationslikeuserauthenticationandpersonalizedcontent.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.