📄 398.html
字号:
then I did:<br><br> chmod 775 $APACHE_HOME/bin/do_env<br><br> and whenever I wanted to reset my environment, I did:<br><br> APACHE_HOME=/usr/local/apache_1.3.14<br> . $APACHE_HOME/bin/do_env<br><br><br>22) Now, let us create the mod_jk module. This is a DSO object<br> which you load into Apache. It is called "server plug-in"<br> sometimes. What it does, it allows Apache to talk to Tomcat.<br> Note that in this communication Apache (The web server) is a<br> client of Tomcat. Tomcat is started, and it listens for requests<br> from Apache (usually on port 8007, but since I have several <br> things running on this machine, I use different port, as you see).<br> Compiling mod_jk:<br><br> cd $JAKARTA_HOME/jakarta-tomcat-3.2-src/src/native <br> cd apache1.3<br> $APACHE_HOME/bin/apxs -o mod_jk.so -DSOLARIS \<br> -I${JAVA_HOME}/include/solaris \<br> -I../jk -I${JAVA_HOME}/include \<br> -l posix4 -c *.c ../jk/*.c <br> cp mod_jk.so ${APACHE_HOME}/libexec<br><br> While I provide here the binary:<br> mod_jk.so -- press right mouse button here and choose: Save Link as<br> which you can just copy to ${APACHE_HOME}/libexec directory I strongly<br> suggest that you build the one yourself, since there are many options<br> to apache, and it simply will not work, if your apache is different<br> than my apache.<br><br>23) When I tested standalone Tomcat in 20),, it created automatically<br> a config file for mod_jk for Apache which is available as:<br> $TOMCAT_HOME/conf/mod_jk.conf-auto<br> I did the following:<br> cd $TOMCAT_HOME/conf<br> mv mod_jk.conf mod_jk.conf.original<br> mv mod_jk.conf-auto mod_jk.conf<br> i.e., I saved the original and copied the automatic version to<br> mod_jk.conf. <br> For the time being, I edited the Apache config file to include<br> the mod_jk.conf (more needs to be done for sensible install,<br> though). I edited file;<br> $APACHE_HOME/conf/httpd.conf and at the last line I put:<br> Include /usr/local/tomcat_3.2/tomcat-3.2/conf/mod_jk.conf<br> The actual initial httpd.conf is here.<br><br> Replaced all occurances of ajp12 with ajp13 and made few other<br> changes. You can find the copy of it here.<br> Made several changes to workers.properties. Namely:<br> changed workers.tomcat_home, workers.java_home, ps, worker.ajp12.port,<br> worker.ajp13.port, <br> You can look up them here.<br> Note, my ajp12 port is 5006 and ajp13 is 5007.<br> <br>24) changed the $TOMCAT_HOME/conf/server.xml<br> to activate the ajp13 connector<br> <!-- Apache AJP13 support. --><br> <Connector className="org.apache.tomcat.service.PoolTcpConnector"><br> <Parameter name="handler"<br> value="org.apache.tomcat.service.connector.Ajp13ConnectionHandler"/><br> <Parameter name="port" value="5007"/><br> </Connector><br> Left apj12 support at port 5006 since it is needed for shutdown.<br> Also changed other ports.<br> Look here for initial server.xml.<br><br>25) Heavily edited the $TOMCAT_HOME/bin/startup.sh, <br> $TOMCAT_HOME/bin/startup.sh and $TOMCAT_HOME/bin/jspc.sh <br> to include necessary environmental<br> variables. These initial files can be found here:<br> startup.sh <br> shutdown.sh <br> jspc.sh <br><br><br>26) Started tomat<br> cd $TOMCAT_HOME/bin<br> ./startup.sh<br><br> (if you have errors, check if tomcat or something else is not running<br> and using the same TCP ports. Do, for exampl:<br> ps -ef | grep tomcat<br> and kill if needed. Also check if any ports from above: 5006, 5007,<br> 5180, 5280, 5143, are used by using: <br> netstat -a | more<br> They would be listed in the first column, e.g., *.5143<br> )<br><br>27) Started Apache<br><br> $APACHE_HOME/bin/apachectl startssl<br><br> Things worked on port 5180(http) and 5143(https). I checked<br> <a href="http://heechee.osc.edu:5180/examples" target=_blank>http://heechee.osc.edu:5180/examples</a> and<br> <a href="https://heechee.osc.edu:5143/examples" target=_blank>https://heechee.osc.edu:5143/examples</a> <br><br><br>28) Stopped Tomcat<br> cd $TOMCAT_HOME/bin<br> ./shutdown.sh<br><br>29) Stopped Apache<br> <br> $APACHE_HOME/bin/apachectl stop<br><br>32) Reconfigured Tomcat and Apache to do things I want them to do.<br><br> a) In $APACHE_HOME/conf/httpd.conf made sure mod_jk is before mod_rewrite<br><br> LoadModule jk_module libexec/mod_jk.so<br> LoadModule rewrite_module libexec/mod_rewrite.so<br><br> and<br><br> AddModule mod_jk.c<br> AddModule mod_rewrite.c<br><br> and commented out the line<br> # LoadModule jk_module libexec/mod_jserv.so<br><br> in $TOMCAT_HOME/conf/mod_jk.conf<br><br>33) In the $APACHE_HOME/conf/httpd.conf I added some rewrite<br> rules:<br> <IfModule mod_rewrite.c><br> RewriteEngine On<br> RewriteLog /usr/local/apache_1.3.14/logs/rewrite_log<br> RewriteLogLevel 2<br> RewriteRule ^/ROOT/examples /examples [R]<br> RewriteRule ^/ROOT/test /test [R]<br> RewriteRule ^/ROOT/admin /admin [R]<br> RewriteRule ^/ROOT/ROOT /ROOT [R]<br> RewriteRule ^/tomcat.gif /ROOT/tomcat.gif [R]<br> RewriteRule ^/examples/servlets$ /examples/servlets/ [R]<br> RewriteRule ^/examples/jsp$ /examples/jsp/ [R]<br> RewriteRule ^/examples$ /examples/ [R]<br> RewriteRule ^/admin$ /admin/ [R]<br> RewriteRule ^/ROOT$ /ROOT/ [R]<br> RewriteRule ^/test$ /test/ [R]<br> </IfModule><br><br> for the HTTP (port 5180) and HTTPS (virtual host at 5143). It was needed<br> to cure a problem that $TOMCAT_HOME/webapps/ROOT<br> is a Document Root for Tomcat, but for Apache, the <br> $APACHE_HOME/htdocs is the Document Root. <br><br>34) Created new users, in my case webinst3, and webrun3, and groups for<br> them, home directories, and regular login environment. <br> The webrun3 was assigned /bin/ksh and webinst3 had tcsh as primary<br> shell (yes, I know that t/csh is brain dead, but people want it,<br> and people will have it -- it sucks, e.g., with its limitations:<br> "Word too long" when your environment variable is longer than 1024 --<br> it happens to me all the time with longer CLASSPATHs).<br> Note, that when you execute the script as<br> su - uid -c script<br> the script will be executed with the default shell (i.e., the shell<br> the user uid has assigned in /etc/passwd) of the uid user, and it does not<br> matter what you put in #!/bin/someshell on the top of your script.<br> The script is sourced with default shell, not forked with a new shell. <br> The webinst3 will own most of the files in the web site, while the<br> webrun3 will be the user who runs the Apache server and the tomcat.<br> It will own log files and other files which the apache/tomcat/ needs<br> to write. In $APACHE_HOME/conf/httpd.conf I did:<br> User webrun3<br> Group webrun3<br> Final version of httpd.conf is given here.<br> Also chown_ed to webrun3 the log directories:<br> chown -R webrun3 $APACHE_HOME/logs<br> chgrp -R webrun3 $APACHE_HOME/logs<br> And for tomcat:<br> chown -R webrun3 $TOMCAT_HOME/conf<br> chgrp -R webrun3 $TOMCAT_HOME/conf<br> chown -R webrun3 $TOMCAT_HOME/logs<br> chgrp -R webrun3 $TOMCAT_HOME/logs<br> chown -R webrun3 $TOMCAT_HOME/work<br> chgrp -R webrun3 $TOMCAT_HOME/work<br><br><br>35) In $APACHE_HOME/bin<br> cp apachectl apache-tomcat<br> and edited apache-tomcat to have a script to start/stop<br> tomcat/apache <br><br> $APACHE_HOME/bin/apache-tomcat<br><br> chmoded apache-tomcat to be executable :<br> chmod 755 $APACHE_HOME/bin/apache-tomcat<br><br>36) Started the apache/tomcat as:<br> $APACHE_HOME/bin/apache-tomcat startssl<br><br> and checked if <a href="http://heechee.osc.edu:5180/examples" target=_blank>http://heechee.osc.edu:5180/examples</a> and<br> <a href="https://heechee.osc.edu:5143/examples" target=_blank>https://heechee.osc.edu:5143/examples</a> worked. <br> They did, so I killed the server with:<br> $APACHE_HOME/bin/apache-tomcat stop<br><br><br>37) changed permissions/ownership on the example directories<br> cd $TOMCAT_HOME/webapps<br> chown -R webinst3 .<br> chgrp -R webinst3 .<br> cd $TOMCAT_HOME/logs<br> chown -R webrun3 .<br><br>38) After all these changes, the ports should be the following:<br><br> Orig New Files affected<br> http(apache) --> 80 --> 5180 conf/httpd.conf<br><br> https --> 443 --> 5143 conf/httpd.conf<br><br> http(tomcat) --> 8080 --> 5280 tomcat/conf/server.xml<br> (disabled)<br> tomcat/apj13<br> --> 8009 --> 5007 tomcat/conf/workers.properties<br> tomcat/conf/server.xml<br> tomcat/apj12<br> --> 8007 --> 5006 tomcat/conf/workers.properties<br> tomcat/conf/server.xml<br><br><br><br><br><br>40) Since starting/stopping apache+tomcat in this environment requires<br> one to be a root, I created C. wrappers to start and stop the whole zoo.<br> $APACHE_HOME/bin/apache_start.c<br><br> and compiled it with<br> gcc -o apache_start apache_start.c<br> as a root, and then added suid permissions to the resulting<br> apache_start executable file as:<br> chmod ug+s apache_start<br><br> I did exactly the same with apache_stop.c<br> gcc -o apache_stop apache_stop.c <br> chmod ug+s apache_stop <br> $APACHE_HOME/bin/apache_stop.c<br><br> Now, people do not have to have root access to start/stop Web Server/Tomcat<br><br> I also added a C program killme.c which kills the processes which are<br> running by user webrun3. It is indentded to be used after "apache_stop"<br> to kill some runaway processes started by apache, Tomcat, or JServ.<br> After compiling the program:<br> gcc -o killme killme.c<br> changed its user and group ownership to webrun3 and added<br> SETUID permission bits<br> chown webrun3 killme<br> chgrp webrun3 killme<br> chmod ug+s killme<br> To learn which processes need to be killed, the user does<br> ps -ef | grep webrun3 | grep -v grep<br> (I actually saved this line as a shell script "killwhich" so they can<br> just type: killwhich).<br> and the user can kill the processes listed by previous command as:<br> killme pid1 pid2 ....<br> where pidn is the process id number in the second column.<br> $APACHE_HOME/bin/killme.c<br>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -