jordanthompson's picture

I am trying to figure out how to access my web pages in /var/www via a URL.  When I browse to my vm,  I get the page that showes "web apps", "virtual hosts", "web shell", and "webmin".  I have tried to change the port from 80 to something else (in ports.conf) but that only changes the port for the aforementioned web page.

I'm sure this is very simple, but I am at a loss and very tired :-(

 

thanks for any help you may be able to give me.

 

Jordan

Forum: 
greybeard's picture

I have the same problem with all web servers based on TurnKey. We must not be doing something that "any idiot would know" to install and configure this properly. You didn't mention but I'm running my TurnKey solutions inside of VirtualBoxes and not native.

Alon Swartz's picture

You can remove the default page from the LAMP stack by deleting/replacing /var/www/index.php

As for tomcat, you can remove/replace /var/lib/tomcat6/webapps/ROOT

I hope the above helps.

greybeard's picture

Actually I don't want to remove anything?? I believe our specific problem is as follows:

1. When I run the installed Linux with web server, it tells me my IP address is 192.168.1.44 let's say.

2. I launch a browser and type 192.168.1.44 in the address bar and I go to the TurnKey webmin page.

3. I launch a browser and type 192.168.1.44:80 in the address bar and I go to the TurnKey webmin page.

4. I believe we think we should go to /var/www/index.php or whatever is there and serve it out instead.

5. Therefore, we must be missing some basic configuration steps to even get the web server to serve a page.

Alon Swartz's picture

The page you are referring is the default Turnkey example page. Its not webmin. Webmin is listening on port 12321.

You can delete the default page as I mentioned above, so your index.XYZ will take precedence. Or you can rename it to something like turnkey.html if you want to keep it around, in which case you can access it as http://192.168.1.44/turnkey.html

greybeard's picture

Thanks for the update. I tried to add a virtual host and got a message that it failed to add it. Whatever. I don't have a myhost or mydomain...only the IP address in the TurnKey Linux configuration panel on my server. Perhaps we really aren't talking about the same problem. Sorry, but it sounds like I'm not even as far as you are in getting this to work. I thought this would sorta work outta the box but that has proven to be wrong. I just haven't been able to gather enough evidence to figger it out, yet. Trial and Error. It takes longer but sometimes it's the only path.

jordanthompson's picture

You should be able to add a server without having a domain.  You would then navigate to the server using the IP address and path as I mentioned earlier.

greybeard's picture

Yeah, I thought you probably could do it that way but I still can't get it to work. I tend to push the envelope on what environments I try to run this stuff in. I just want to test a Java Application I wrote. I want to test it by deploying it to a Linux Web Server before going out to a public server. I selected LampStack TurnKey Appliance running inside an Oracle Virtual Box as described in TurnKey's tutorial. I then want to open a browser window on the same Windows machine hosting Virtual Box and type in the appropriate IP address to get web pages served from var/www. I can type in the IP address and get the TurnKey webmin page. I believed since the Apache Server was listening an ANY address on port 80 that I could get it to serve my web pages using port 80 on the back of my IP address. All I get is the webmin page. I don't have something configured properly or I am using it with incorrect expectations. Or...I don't know what I'm doing.

jordanthompson's picture

Actually, it doesn't seem to do anything.  If you add a directory under /var/www:

/var/www/mypage

then browse to my_ip/mypage

You will get what you are looking for.

greybeard's picture

For me, the solution was quite simple and I will categorize it as incorrect expectations on my part. I followed your suggestion, which is what deploying my .war file will get done by Apache, and that is to create a directory under var/www which is accessed using the directory name. Thanks for your help and my current problem is resolved thanks to jordanthompson.

jordanthompson's picture

Well thanks for the cudos, but I am still looking for some help...  I want MY web page to appear when I browse to my url (without having to add a subdirectory.)  There has to be an easy answer....

greybeard's picture

My only experience is with GoDaddy and the way they are apparently configured. If I address my domain name I get served what's in the home web directory configured by GoDaddy. That seems to be your top level web page. When I deployed a Java web application to GoDaddy, the next time Apache was configured to unarchive and deploy .war files, a directory was created under the home web directory that I needed to use to access my Java Web Application. That sort of made sense so I absorbed it. That is why I was expecting the same result as you in serving pages from the home web directory with just a domain name. The difference is the two Apache configurations. TurnKey and a commercial web hosting service.

Alon Swartz's picture

The lamp stack and tomcat appliances serve content differently, for the lamp stack see my reply above. As for tomcat, you can replace or use the default ROOT app as I mentioned in original post - there is no need in creating apache virtual hosts - that just complicates stuff...

jordanthompson's picture

Alon, thanks for the reply...

I have completely replaced /var/www with my web pages (/var/www/index.php does not exist.)  I have my own /var/www/index.html and several stand-alone directories under /var/www with their own index.html.

When I navigate to my machine, I still get the aforementioned web page, and not /var/www/index.html.  If I navigate to my machine/dir1 (which has its own index.html), this directory is servered as I would expect.

The problem is the top-level (/var/www/index.html) web page does not work (I get the default one.)

Jordan

Alon Swartz's picture

The default page is most probably cached in your browser - try doing a forced-refresh, or clear your cache. Also, you shouldn't need to restart apache but it wouldn't hurt...

jordanthompson's picture

That was the first thing I did - in fact, I used internet explorer (a browser I never use) to make sure it wasn't being cached.  I have restarted apache as well as the machine (for other reasons.)

Here's something else:

if I navigate to my_machine/index.html I get my web page as expected!

Jeremy Davis's picture

I can confirm that it should all work as Alon has described (that's how my LAMP appliance works). Perhaps doublecheck that there is only one file named index.<extension> in /var/www/

Perhaps if there is also an index.htm that is the one that is displaying? Only guessing though...

[update] Ooops just realised that you're on Tomcat/Apache appliance, not LAMP... Sorry for my irrelevant comment.

greybeard's picture

I've actually tried sample war file deployments in Tomcat/Apache and LampStack. I don't know where the apps are served for Lamp but for Apache it's apparently var/lib/tomcat6/webapps. I place my sample war file there...it gets automatically unarchived and deployed. When I try to access it, I get the same results as everyone else. I get the control panel. As I said in one of MY previous emails, trial and error seems to be the necessary path to take when most results are "huh, it should work".

jordanthompson's picture

I stumbled on this also just now (the same time as greybeard.)  under /var/lib/tomcat6/webapps there are two folders ROOT and cp(!)  I tried renaming cp and sure enough, when I browse to my hostname (with no additonal path) I get a broken link.

I think I need to put my web page under ROOT, but just removing or renaming cp is not enough.  There is a mod_jk.conf under /var/lib/tomcat6/conf that has the line "jkMount /cp ajp13_worker", but I don't know what I am looking at.

jordanthompson's picture

I removed all of the files from the /www/var (except my index.html and icon file my site uses) and when I navigate to http://hostname it goes to http://hostname/cp.  There is no cp in /var/www!

If I navigate to hostname/index.html, I get my web site.

There is something simple I am completely missing!

Jeremy Davis's picture

You are using the Tomcat/Apache TKL appliance?

If so, unless you have a virtual host set up, then /var/www is not where pages are being served from! As Alon wrote above, they are in an alternate location.

Like Alon also said, there shouldn't be any need to use virtual hosts to display your page (if you have done it already I would remove the customisations you've made). An incorrectly configured virtual host may explain your weird results?

greybeard's picture

Yes, jordanthompson...that is exactly my behavior except replace hostname with an IP address and I can make exactly the same statement.

Jeremy Davis's picture

I've just downloaded and tested the Tomcat/Apache appliance and you guys are completely correct. By default browsing to http://<appliance-ip>/ auto redirects to http://<appliance-ip>/cp/ - whereas typing in http://<appliance-ip>/index.html will display what's in /var/www/index.html

With a bit of digging around I have found how you can change that behaviour. If you edit the first line of /etc/tomcat6/mod_jk.conf from:

RedirectMatch ^/$ /cp

to

RedirectMatch ^/$ /index.html

now just typing http://<appliance-ip>/ will display http://<appliance-ip>/index.html (ie /var/www/index.html).

I only discovered this by hunting around and a bit of trial and error. I'm not convinced that what I've done is necesarily the best way to go but it does appear to work.

BTW all the orginal stuff still works too, but you have to specify it, eg http://<appliance-ip>/cp

Alon Swartz's picture

Doh! I completely forgot I set that up - kuddo's Jeremy! It should be documented in http://www.turnkeylinux.org/docs/appliances

[edit] Although it should point to a tomcat app (with the appropriate mod_jk settings), not to a specific file...

Jeremy Davis's picture

Perhaps there needs to be an example app or something? Although I guess that the TKL landing page is an example of sorts...

Correct me if I'm wrong, but it seems that if you change that first line to anything that's not included further down in that config file, then it points to /var/www whereas if it is configured in that file it will point to /var/lib/tomcat6/webapps

Eric's picture

Just what I needed. Thanks!


greybeard's picture

Good Job by everyone to follow up on the problem. I can confirm the edit works for index.html. Can I make this redirect more complex by pointing to the suggested tomcat app (with the appropriate mod_jk settings)?But you lost this old newbie when you talk pointing to a tomcat app. I want to deploy Java Web Applications so my edit will be to point to a file...index.jsp.

jordanthompson's picture

Thanks very much for the solution!  It works for me also.

greybeard's picture

I'm tryin to figure that out Jeremy. Redirecting to index.jsp got me a page not found...I guess because my app is in var/lib/tomcat6/webapps instead of var/www. This is all very confusing to me. If I unarchive my app in var/www I just get served the directory contents when I try to access the directory name in a browser. I guess because Apache doesn't serve apps out of var/www so it doesn't recognize it I guess. I suppose I'm changing the subject from "how to serve web pages" to "how to serve web applications" in turnkey apache tomcat.

Jeremy Davis's picture

Then you are better off with the standalone Tomcat appliance. AFAIK Tomcat includes it's own server (but only servers apps, not html too). If you want to persevere with Tomcat on Apache, then I suspect that you will need to add the other details as found in that config file for your app.

greybeard's picture

Thanks, Jeremy. I will try that. This is really only a test bed for deployment of a Java Web Application. I was not aware the standalone appliance had it's own server that would do what I need it to do. Don't need to serve html pages, just Java Server pages. However, I do need support for MySQL if the standalone applicance supports that I'm on my way.

greybeard's picture

Thanks again to everyone for their excellent help. I acquired and installed the standalone Tomcat appliance. I ftp'd my sample war file to var/lib/tomcat6/webapps. Apache took it and unarchived it and deployed it. I launched my browser and pointed to <ip address>/sample and the sample web application launched and served jsp pages and servlets. I'm good to go with my testing. Thanks again. I'm happy. Uhh...I may have inadvertently solved my problem by getting rid of the ROOT application unaware that it was the control panel. So, I need to start over again to ensure I don't need to edit any config files and still able to get at the control panel if no subdirectory is provided in the ip address.

Jeremy Davis's picture

So to get php to work you'll need to install it and make it a LAMP. It should install with:

apt-get install php5 libapache2-mod-php5

I don't know much about setting up or using php but I think an alternative to the Apache module, is the CGI one php5-cgi. You may also want the MySQL module php5-mysql.

Add new comment