Apache 2.4.6 and Apache Tomcat 7.0.42 on Port 80 - apache2

On my Ubuntu 13.10 I have installed Apache and Tomcat. I am trying to get tomcat to work on port 80 with no luck at all. I have looked at using mod_jk following several online tutorials with no success. What I am trying to achieve is I have a webapp on tomcat running as the root application. Therefore the current url is www.example.com:8080. I also have apache which is on the url www.example.com. I want to be able to access files on the apache webserver for e.g www.example.com/somefile but also have my webapp running at the sametime on www.example.com. Please can anyone help.

You need to add url redirection to apache and check for the path in apache httpd.conf.
Check the path of the incoming request is just example.com then you rewrite it to example.com:8080.
The mod_proxy of apache should be able to do this for you.
http://tomcat.apache.org/tomcat-4.1-doc/proxy-howto.html

Apache Tomcat by default runs on port 8080. Incase if you need to run it in port 80 you need to use JSVC which comes along with tomcat. If you have installed tomcat by downloading the binary version then jsvc will be available under
[tomcat_install_path]/bin/commons-daemon-native.tar.gz
you need to untar it and compile it. Compiling it is easy.
# ./configure
# make
once you have compiled it you will get the jsvc binary file which needs to be placed under the tomcat bin directory.
Then to start up tomcat with the help of jsvc follow the steps mentioned here
JSVC is the officially recommended way of starting Tomcat in port 80.

So I managed to solve this problem by Using Mod_Proxy. Editing the 000-Deafult.conf file in /etc/apache2/sites-enabled and adding the following lines:
ProxyPass /SomeUrl !
ProxyPass / http://localhost:8080/
The first line indicates what you don't want to proxy and the second one indicates what to proxy.In this case forward the ROOT app of Tomcat at port 8080 to the root of the Apache web server
Also edited the server.xml file in /etc/tomcat7 and added the following
<Connector port="8080" protocol="AJP/1.3" proxyName="www.mydomain.com" proxyPort="80"/>

Related

Project inside webapp tomcat8 does not run in webpage

I am trying to run my application using tomcat8 inside the Apache2 virtual machine, using MacOS.
The IP address is: http://143.167.11.2:8080
and this the view when I run the link on the browser:
I have installed tomcat8 inside this apache2 VM using: apt-get install tomcat8 by following this instruction: https://www.linode.com/docs/development/frameworks/apache-tomcat-on-ubuntu-16-04/
When I run this address http://143.167.11.2:8080 the result is the same, it just shows this same picture . It does not show the tomcat home page.
I have tried to run this: ./startup.sh and inside the terminal and it started.
But when I run the linked address http://143.167.11.2:8080 the result is same, it shows apache home page.
I tried to put my project inside /var/lib/tomcat8/webapps and then tried to run: http://143.167.11.2:8080/visualisation-dataproject.
But the result like below:
Any idea how can I run my project (that I put on the webapps folder) on the web browser?
Apache2 is usually use for PHP project. Tomcat is usually for java project. There are some possibility why you can not run tomcat on the web browser. One of the reason is you have not install tomcat8 properly. Even you have install it, you should check it really work or not. If it work on the VM, maybe the problem when you set the port for tomcat in server.xml.
To check server.xml, try : sudo nano /etc/tomcat8/server.xml, and find <Connector port="8080" protocol="HTTP/1.1 ... line.
And try to change the port 8080 to another port e.g: 8081. Why? to prevent tomcat8 server running with same port with another server such as apache2.
After that try the step on this link: https://askubuntu.com/a/434085/856656 it should work.

on which port does solr works on

I am new to solr i have just installed it with tomcat, and just after installing i opened http://localhost:8080/solr/#/ and i could see the solr admin page .
So the website i am refering,
it is given there that to start solr run bin/solr start ,and it can be seen at http://localhost:8983/solr/#/
So now solr admin page is visible at both 8080 and 8983.
So i just wanted to know on which port does solr actually works on ,8080 or 8983 ?
Well i am also new to Solr and i am running it with Jetty. and i think it actually works on 8983. although you can change it in the configuration xml file.
If you're using Solr 5 it will be hosted by jetty and listen on port 8983 by default; you can change the port from the solr command line using e.g. bin/solr start -p 9999
If you're using an older version of solr and you are hosting in tomcat as you say, then by default it will use the default tomcat port (8080) and you'll need to look at your maven/tomcat/whatever setup to change the port.
You can change the port from maven using -Djetty.port=9999 or -Dmaven.tomcat.port=9999 as appropriate.
From what you're describing it looks like you may have two copies of solr running on your machine, one with jetty and one with tomcat.

Setup Solr for ezPublish

I am using eZPublis(4.6.0). I have set solr folder folder in my xampp folder and activated the eZFind extension in \settings\override\site.ini.append.php.
My solr is runing on port 8080 ("http://127.0.0.1:8080/solr/"). when I run "http://127.0.0.1:8080/solr/", it loads fine.
However, when I try to run command : php extension/ezfind/bin/php/updatesearchindexsolr.php -s
it shows following error “Please, ensure the server is started and the configuration of eZ Find is correct”. I am following http://harmssite.com/post/86#comment-113.
Can anyone suggest what wrong I may be doing or any other solution?
If you are sure that solr is running then you might need to edit solr.ini (or one of its overrides) and use 127.0.0.1 instead of localhost. I've faced this issue sometimes.
The default Solr port is 8983, so eZ Find out of the box is set up to look at that port. If you are sure that Solr is up and running on port 8080 then look in your solr.ini to verify you have eZ Find pointed at the right Solr port.

how do i use apache2 server for hosting a website?

I am using ubuntu and I have some html pages. I want to host a website from my PC at my home. How can I do this using apache2? I am new to Apache2 if any one knows how to do this, please let me know.
The easiest way to publish HTML files with apache is by putting them in /home/your-user-name-please-do-replace-me/public_html, making sure that your apache is installed and then start apache. How to make apache start after a reboot, see this forum post on Ubuntu Forums.
When you have apache up and running, find out your servers IP-address (http://whatismyipaddress.com/ is pretty handy for this) and then your files will be accessible from: http://you-ip-address-whatever/~your-user-name-please-do-replace-me
You could always use services like http://www.dyndns.com/ so that you don't have to use your IP-address all the time.
Once apache is installed you should find that you can place content in a directory silimar to /usr/www or /usr/share/www and apache will serve it. You may also need to start apache, I don't know the ubuntu command but on fedora 12 it is:
service httpd start

mod_jk problems with connecting apache2 and tomcat6

I am trying to configure mod_jk to forward requests to my webapp running in tomcat. ( I read else where that mod_proxy_ajp is the way to go but want to get this figured out first). I am new to tomcat and mod_jk.
I try to access -- http://www.example.com/test/index.jsp
I get a 400 error in my apache logs after I configured mod_jk. The webapp is working fine when I test it directly in tomcat. In the mod_jk log file I see that it is trying to map the A/index.jsp but its failing with a 400. So I see that the mod_jk is getting invoked but somehow modjk is not seeing the webapp.
Any help is greatly appreciated
I am on a SuSe Linux 11 and am running apache and tomcat on the same box.
My httpd.conf is a monolithic file. In it I added the following --
<IfModule jk_module>
Alias /test/ "/srv/tomcat6/webapps/A"
JkWorkersFile /usr/local/apache2/conf/workers.properties
JkShmFile /usr/local/apache2/logs/mod_jk.shm
JkLogFile /usr/local/apache2/logs/mod_jk.log
JkLogLevel debug
JkLogStampFormat "[%a %b %d %H:%M:%S %Y] "
JKMount /test/ A1
JkMount /test/* A1
JkOptions +ForwardSSLCertChain
</IfModule>
I have the following in the workers.properties --
#Define 1 real worker using ajp13
worker.list=A
#Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.ajp13.lbfactor=50
worker.ajp13.cachesize=10
worker.ajp13.cache_timeout=600
worker.ajp13.socket_keepalive=1
worker.ajp13.socket_timeout=300
Thanks,
- Vas
Your worker is called A but your JkMount maps to A1. You should have one entry like this,
JkMount /test/* A
I used both mod_jk and mod_proxy_ajp. Under heavy load, mod_jk performs better because the mod_jk connection is more persistent. mod_proxy is indeed much easier to setup.
EDIT: The worker configuration is not correct either. It should be something like this,
#Define 1 real worker using ajp13
worker.list=A
#Set properties for worker1 (ajp13)
worker.A.type=ajp13
worker.A.host=localhost
worker.A.port=8009
worker.A.lbfactor=50
worker.A.cachesize=10
worker.A.cache_timeout=600
worker.A.socket_keepalive=1
worker.A.socket_timeout=300
Did you load the module?
LoadModule jk_module [path to it]
The directive will be true if it is loaded already or compiled in I believe.

Resources