Why does mod_jk on Ubuntu 14.04 not connect to tomcat - tomcat7

I am running tomcat 7, Ubuntu 14.04, apache 2.4, Java 8. I am trying to hook up apache with mod_jk to use the tomcat application with only the static resources coming from apache.
Apache is running on port 80 and I can see the file structure and all my static resources. But when I go to the naked url, I only see the apache folder structure. In my understanding mod_jk should be forwarding to the ajp port of tomcat instead.
I installed apache2 and mod_jk (libapache2-mod-jk) by using apt-get. It basically did all the configuration for me (at least it looks like it did). I followed some tutorials to install it, but basically just checked and made sure the steps were taken. The main apache conf file is called apache2.conf and it includes all the .conf files from the folder called mods-enabled. Inside mods-enabled, there is a file called jk.conf. This is the mod-jk conf file and it includes a workers.properties file that is held in my /etc/libapache2-mod-jk folder. (I edited the workers.properties file to point to my tomcat home location and my java home)
The one thing that seemed different from most of the tutorials I read was that my mod jk conf file (jk.conf) had no reference to a file called module/mod_jk.so. I don't know what this file is, and why the folder doesn't have a slash in front of it, but that was what it looked like in all the tutorials.
What would really help is if someone has used the apt-get installation of mod_jk on Ubuntu 14.04 (all of the examples I found were for 12.04).
Is the reason it's not connecting because I don't have the .so file?
Am I mistaken about how ajp is suppossed to work, do I need to do any extra tomcat configuration other than have an ajp connector that looks like this <Connector port="8009" protocol="AJP/1.3" redirectPort="8080" />?

I had not added JkMount to apache2.conf. That solved this.

Related

Laravel ReST API URL 404 not found on AWS EC2 in Apache + mySQL environment - The request URL was not found on this server

This question is on AWS Laravel Implementation on Apache + mySQL AWS EC2 instance.
After copying the working Laravel folder from xampp/htdocs/my_project_name, migration to create tables in mySQL database and seeder are working.
However, I could not connect to my APIs using Postman. (404 not found)
I following these solution links
laravel the requested url was not found on this server
https://laracasts.com/discuss/channels/general-discussion/laravel-5-the-requested-url-was-not-found-on-this-server
I managed to modify the httpd.conf. However, I could not find file .htaccess
(
where .htacces i can find? Sorry for stupid question, but i can't find :) – MilanNz Mar 11 '15 at 12:30
#MilanNz The .htaccess can be found in the public directory of your application. However the code from this answer goes inside a vhost file. The location of that depends on your server. (e.g. for apache2 and unix it's usually at /etc/apache2/sites-available)
)
Also, I was not able to reboot my Apache using "service apache2 restart".
So I "sudo reboot"ed the EC2 instance and reconnected using Postman, the API urls were still not found.
There is a possibility that my URL is wrong. So I attach it here:
The URL used is http://ec2-??-??-???-??.us-east-2.compute.amazonaws.com/my_project_name/public/api/resultCRUD/list
The working xampp URL is http://localhost/my_project_name/public/api/resultCRUD/list
The Laravel project folder is located at /var/www/html/my_project_name on AWS EC2.
http://ec2-??-??-???-??.us-east-2.compute.amazonaws.com/phpinfo.php and
http://ec2-??-??-???-??.us-east-2.compute.amazonaws.com/phpMyAdmin/ are working.
Any help is greatly appreciated. Thanks!
It's finally working.
The reason I was stuck is because most of the answers are for ubuntu while I am using RedHat.
For RedHat EC2 instance, need first change the content of /etc/httpd/conf/httpd.conf following https://pinecode.io/article/setting-up-laravel-56-on-aws-linux,
In this step, I actually changed all "AllowOverride None"s to "AllowOverride All" instead of only line 151 of httpd.conf.
Then need to restart httpd using sudo service httpd restart
following https://gistpages.com/posts/enable_mod_rewrite_in_apache2_on_red_hat_linux
Then it is working all fine.
I didn't restart my apache service after saving changes to httpd.conf when I was asking this question.

Can Apache Configuration File (httpd.conf) Be Located Elsewhere?

I have been using Apache on Windows (+PHP +MySQL) for a long time now. Lately, I decided to have the configuration files of Apache, PHP and MySQL in one directory, outside of the installation folders of any of them.
With PHP it works by setting PHPIniDir in Apache's httpd.conf
With MySQL it works by setting the --defaults-file=<path/to/my.ini> option while installing on the command line as a Windows service.
With Apache itself, I haven't been able to find a way. Is it possible to choose an arbitrary location or name for the httpd.conf file? And how?
Thank you.
you could use "..-f httpd.conf" on startup. see http://httpd.apache.org/docs/current/de/invoking.html
Regards

ELF Header Error and Building Modules In Apache for Jelastic

So I'm building a web app and I decided to move it from my localhost to Jelastic. The app requires one custom module: mod_auth_cas. I followed the instructions on the Jelastic website for adding a module.
The only step I didn't follow was compiling the module against 2.2.15. I tried configuring that version, but I couldn't figure out how to run it concurrently with the 2.2.24 version my Mac runs natively. I figured that a module that worked with 2.2.24 should work with 2.2.15.
I uploaded the .so file to the Jelastic server and added the following LoadModule command to the httpd.conf file:
LoadModule auth_cas_module /usr/lib64/php/modules/mod_auth_cas.so
and restarted Apache. I got the following error:
Failed to start
Stopping httpd [ OK ] Starting httpd
Jelastic autoconfiguration mark httpd
Syntax error on line 161 of /etc/httpd/conf/httpd.conf
Cannot load /usr/lib64/php/modules/mod_auth_cas.so into server
/usr/lib64/php/modules/mod_auth_cas.so invalid ELF header [FAILED]
From the research I did, it seemed as though this error comes when "the installation is
'corrupted' or someone installed something for the wrong processor/binary type."
So I'm trying to figure out what to do. I either need to figure out how to install Apache 2.2.15 and compile a module against that, or I need to figure out what I'm doing wrong on the Jelastic side, or I need to figure out why the .so file is getting corrupted. Which one is it, and how do I do it?
Indeed the problem is the different platforms.
The module was compiled for the correct platform and installed for you.
FYI: To use this module we created a cas.conf file in conf.d please open this file and modify accordingly.
I recommend that you contact your hosting provider and ask them to compile that module for you. The problem is most likely caused by that (compilation on a different system / system that is too dissimilar), or else it's at least the first thing to rule out.

Ruby app only works when Passenger is "disabled"

I have deployed a Sinatra application on an Ubuntu server using Apache and Passenger. Through some trial and error, I realize the app only works when the passenger module is disabled.
$ a2dismod passenger
After an Apache restart, the app runs as expected.
If I re-enable the module...
$ a2enmod passenger
...I see this warning upon Apache restart:
[warn] module passenger_module is already loaded, skipping
and the app stops working. Apache responds, serving the contents of the vhost's document root, but is not recognized by Passenger.
I'm glad my app works, but I'm not sure how to explain the reversed effect of enabling/disabling the passenger module.
I ran into the same problem: if you follow passenger installing instruction with this version of Apache you may actually tell Apache to load passenger twice.
Before adding the 3 famous lines to your Apache configuration file:
LoadModule passenger_module /usr/…/ext/apache2/mod_passenger.so
PassengerRoot /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.11
PassengerRuby /usr/local/rvm/wrappers/ruby-1.9.2-p290/ruby
Check the configuration file apache2.conf for lines like these:
# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf
If these lines do exists it means that on start your Apache server will include every *.conf and *.load file from /mods-available to /mods-enabled and than load them.
So if you run in the concerning warning message it means you are loading passenger module twice!
You can take advantage of this Apache feature going to /mods-available, looking for passenger.conf and passenger.load files and edit them instead of apache2.conf.
The ‘LoadModule passenger_module’ line goes into passenger.load, while the other 2 ‘PassengerRoot’ and ‘PassengerRuby’ lines go into passenger.conf.
Then restart your server and you’ll be fine.
More about this issue here: http://www.duccioarmenise.net/ruby-on-rails/warn-module-passenger_module-is-already-loaded/
This most likely means you've specified 'LoadModule passenger_module ...' twice. The first entry is somewhere not in passenger.conf, the second entry is in passenger.conf.

Has anyone setup tomcat to run virtual hosts using mod_jk

I work in OSX primarily with mostly PHP. Normally I work locally using MAMP and virtual hosts setup in my httpd.conf so that I can point a browser to http://some-project and have as many projects as I need setup.
We have a project coming up where we need to serve JSP pages and I would like to set up my local apache server to serve only JSP files to Tomcat and everything else to MAMP using the same virtual hosts setup in:
~/applications/MAMP/conf/apache/httpd.conf
So far I have:
Successfully installed Tomcat
Placed mod_jd.so in
~/applications/MAMP/Library/modules/mod_jk.so
Added the module by placing:
LoadModule jk_module modules/mod_jk.so
in
~/applications/MAMP/conf/apache/httpd.conf
Created /Library/Tomcat/Home/conf/jk/workers.properties
and added the following lines:
workers.tomcat_home=/Library/Tomcat
workers.java_home=/System/Library/Frameworks/JavaVM.framework/Versions/1.5.0/Home
ps=/
worker.list=ajp12, ajp13
worker.ajp13.port=8009
worker.ajp13.host=localhost
worker.ajp12.type=ajp13
worker.ajp13.mount=/*.jsp
added the following lines:
JkWorkersFile /Library/Tomcat/Home/conf/workers.properties
JkLogFile /Library/Tomcat/Home/logs/mod_jk.log JkLogLevel debug
to
~/applications/MAMP/conf/apache/httpd.conf
I cannot start my MAMP however when these last two lines are present in my httpd.conf.
Does anyone work like this?
Any tips?
Any clear ideas of what I'm doing wrong?
I've found with MAMP that it won't start unless the log files already exist. I create the path to the log file and put in an empty text document named the same as the expected log file and it starts right up.

Resources