apache2: subdirectory won't work if I enable app at / - apache

I built a personal server at home which is hosted at, let's say, example.org and I installed GitLab as a subdirectory so I can access to it at example.org/gitlab. As GitLab is the only one application I have so far, everything works smoothly.
Now I want to have a blog at root, so I enabled Apache default site to do some tests. I can see apache2 default page at example.org (which is where I want my blog) but GitLab won't work anymore at example.org/gitlab. All I have is a "page not found". GitLab will only work if I disable the default page at /.
I tried using Alias, I also read something about redirections but I haven't managed to make example.org and example.org/gitlab work together so far.
Any advice about where to look, please?

If you generate two virtualhosts both must have different ServerName, otherwise first match receives all requests and second virtualhost will be ignored.

Related

Domain Name cannot be changed in Apache on CentOS 7

I have set up a server with a wiki and Wordpress and Nextcloud on a new Domain, let's say it's testing.com. When I was finished, I wanted to change the Domain from testing.com to realdomain.com.
The server is running CentOS 7 with httpd (apache), so I changed the ServerName in /etc/httpd/conf/ to "realdomain.com". Then I changed the VirtualHosts in all the files in /etc/httpd/conf.d.
I added the new Domain to the trusted Domains of the Wordpress, Nextcloud and wiki. I restarted the httpd service and the server itself.
Yet, when I open realdomain.com in browser, it shows me my websites, but it puts testing.com in the address field.
I tried using mod_rewrite to change the URL, but then my webbrowser tells me that the site doesnt redirect correctly and that the redirects never stop.
I tried those rewrite rules in the .conf files and in the .htaccess (not simultaneously)- no success.
I removed all my files in conf.d and created a new DocumentRoot with a simple helloWorld.html - The Url still gets rewritten to testing.com.
Are there any other locations that could have rewrite rules? Did I miss anything?
Thank you so much in advance, this is killing me!

Changing hostname of VPS - ZPanel Issue

Basically I've got a VPS setup but I incorrectly set the hostname. I left it for a while and it was fine, installed zpanel etc and now it's a 'web host' and everything was fine. Now I want to change the hostname so I logged into the hosting companies control panel for the server and changed the hostname.
The original and the new hostname are in the format of xxx.yyy.com. So nothing happend and I could still reach the zpanel login page via the 'old' host name even though in the hosting companies control panel it said it had changed.
For ease of explanation, we shall say my old hostname was xyz.example-domain.com and my new is server.another-domain.com. Both domains are controlled within this installation of zpanel.
Anyway. I deleted the dns entry for "xyz" on example-domain and, as you would expect, if you go to xyz.example-domain.com you get nothing. I created a dns A record for server.another-domain.com but now all you get is the default apache 'welcome to your server' page. To get to zpanel login, you need the IP address.
SO my question is, do I need to do something else? It seems that I need to change where this zpanel login page is getting displayed so that it can be server.another-domain.com. I'm guessing there is some file somewhere that I need to edit but I don't know what one and "the internet" isn't really helping as all I find is 'change the host name in the hosting companies control panel' which I've done.
PS It is an apache 2 server running CentOS 6
Take a look at your Apache configuration located in /etc/httpd/conf/httpd.conf. If you intend on running multiple domains off the same host, you'll need to setup Virtual Hosts. You'll see a detailed explanation of those settings toward the bottom of your configuration file.
Depending on where you've located your files, you'll want to set your DocumentRoot accordingly for each of your Virtual Hosts, and that will instruct Apache to look for the files in the proper places. By default, I believe it looks in /var/www.
NOTE: You will need to restart Apache or reload configurations whenever you alter your configuration file. You can do this by running either one of the following commands (as root):
/etc/init.d/httpd restart
/etc/init.d/httpd reload
Go to /etc/zpanel/panel/
rename: index.php -->panel.php (or any other name).
Then create index.php and let it in blank (or write a welcome message)
Finally enter to your zpanel like this: http://www.yourIP/panel.php
Works fine!
Is not necessary change any port

Multiple Virtual Hosts Subdomain 404s?

I have an Apache Server running on a CentOS box running 3 websites using VirtualHosts.
The problem is, is when I go to a non-existent subdomain on the websites it always shows the files from Website #1. How do I fix this?
Thanks!
Here's my httpd.conf: http://pastebin.com/5bDgrR2W (I've replaced my email and domain names)
You have a default host configured, so whenever an unknown domain is called, the default config will be used.

Hosting not loading pages

i am new to web hosting, but i purchased a domain from namecheap.com and i purchased web hosting from ramnode.com to host my domain, i am using centOS 32bit as my server, and i have pointed my domain to ramnode nameservers that were provided to me.
The problem i am having here is that everytime i load my website, it just says
Index Of/
cgi-bin/
even though i have placed my web page files in var/www, and var/www/html like ramnode support told me too, it still does not want to work. Any suggestions?
It all depends on how your server is setup but here are a few things to check.
What are the permission levels for your files, who owns them and what group are they in? If you don't have proper permissions set they may not show. If the wrong person owns them they may not show.
Read over your httpd.conf (centos should have it in /etc/httpd/conf) see how your server is setup. It may not have a default setup, perhaps your using a virtual host?
In a nutshell we need more information to help you out.
You should have an
.htaccess or htaccess.txt file in your WWW root, whithin that file you need the following line:
DirectoryIndex index.htm index.html index.php
That is the priority order of your index page. (Your web project needs an index page)
So in otherwords your webserver will serve the first matching file that it finds in that list.
A quick fix if you cant find the htaccess file, is just make sure you have an index.html file in your var/www
I just reset my nameservers to point to ramnode's last night and am experiencing the same issue as the OP this morning.
I previously had no FQDN for the ramnode server and simply used my /etc/hosts file locally to point to the ramnode server. Through that method, I was able to make sure everything was setup just so - apache virtualhosts, .htaccess files, apache.conf, and httpd.conf files all operating as desired.
It seems to have something to do with the installation of the cpanel, which auto-fills DNS A records with a different IP than the one I was provided. changing it to ramnode's original IP simply leads to the same cgi-bin directory index. But going going to the original ip in the browser leads to my site, as I have the apache virtualhost set for the IP.
Ramnode sets subdomain a records such as cpanel.mydomain.com all set to the same new IP and those do function, so it leads me to believe a ramnode server is capturing the trafic elsewhere and should be sending it on but isn't.
It's a bit confusing where cpanel is taking me and why redirecting to my the domain.com. A record to the original IP seems to have no effect.

Tomcat serving URLs wrong with mod_proxy and apache

I've set up a host with apache to serve static pages and to use Tomcat to serve my web application (See this question). The static pages are server from
"http://myhost.com"
and the dynamic (tomcat) pages are server from
"http://myhost.com/myapp"
The mod_proxy makes sure the "http://myhost.com/myapp" are forwarded to tomcat server running on "http://myhost.com:8080".
The problem is that now you get the standard Tomcat introduction page on "http://myhost.com/myapp" but if you click on a local link (e.g. 'Status') on the left, it generates an URL
"http://myhost.com/manager/status" while it should generate: "http://myhost.com/myapp/manager/status"
(The same is true for webapps installed under tomcat)
What should be changed in my configuration (apache, tomcat?) to redirect my tomcat links to the right place?
Have you set the ProxyPassReverse setting in your httpd.conf. This will overwrite the HTTP Header an you'll get to the correct request on the side of tomcat.
Your URLs are mapped from:
http://myhost.com/myapp -> http://myhost.com:8080
This means that accessing the above URL will be mapped to the ROOT application in Tomcat. The ROOT application will generate pages that contain links from Tomcat's root context.
In other words, if you go to:
http://myhost.com:8080
you will get a page that contains links to
http://myhost.com:8080/manager/status
This link will work. However when that page is given back to a browser that requested it via Apache, the full URL then looks like: http://myhost.com/manager/status
I assume that you intend to deploy an application called 'myapp' to Tomcat? If that is the case the Tomcat URL for this app will be
http://myhost.com:8080/myapp
Which will also work be mapped correctly when accessed via Apache.
If you absolutely must access Tomcats root application in this way you'll have to rewrite the URLs it outputs in the pages it returns.
I've had the most success with mod_proxy_ajp. It requires mod_proxy, but works over ajp. Using it instead, your conf file looks similar
ProxyPass / ajp://localhost:8009/
See my similar question and also the answer to this question. The only fault in mod_proxy_ajp that I've found is that if I need to restart tomcat I have to force an apache restart too.