Payara Domain configuration - glassfish

We are using the PAYARA(Glassfish) server for our application deployment and it has two domain like domain1 and parayaDomain. As on when we need to update payara server version, it has effect on it's domains because domains are present inside the payara/glassfish/domains/domain.
Now, my question is, is it possible to take domains outside the server? I mean completely outside the Payara directory. If it is possible, where all the configurations we have to change(specify the location of the domains which are placed outside).
So that, as on when we have upgrade the server, there will be no effect on domains. Any help will be appreciate.
Thanks,

This is absolutely possible. The asadmin subcommands start-domain, stop-domain, restart-domain, start-local-instance etc all have lots of other options which allow you to specify the location of the directory which holds all the domains or nodes. The path you mentioned is simply the default.
The official documentation has an example of upgrading Payara Server in this way (Method 2) where you may have multiple versions installed in directories alongside separate domain and node directories:
/opt/payara/154/payara41/....
/opt/payara/161/payara41/....
/opt/payara/162/payara41/....
/opt/payara/domains/myDomain
/opt/payara/nodes/myLocalNode
Considering this set up, you could start the domain myDomain with the Payara 154 instance as follows:
/opt/payara/154/payara41/bin/asadmin start-domain --domaindir /opt/payara/domains myDomain
https://docs.payara.fish/documentation/user-guides/upgrade-payara.html
Do note that the command in the example has a space in between domains and myDomain, not a forward slash (/). This is because you need to specify the domainDir, which is the directory which may hold several domain folders, and then specify the name of the domain which you want to start as a separate argument.

Related

Set root directory on shared hosting for multiple projects

Locally, I can change the root directory of apache following these instructions. What I really want is to set up a way to have multiple projects with a different root directory for each project. I did this with help from this question.
I have a shared hosting plan (Apache running on Linux Ubuntu) where I would like to test these projects in a more production-like environment. The problem I run into, is that I cannot configure a different root directory for each project because I cannot configure Apache on this shared hosting.
My question is, is there any way to 'tell' Apache I have different projects with different document roots? I'm hoping there is a solution like having a .htaccess file per project with this setting, but I am not sure if this is possible.
There are a few of "it depends", so I will address the most common setups.
1) How do you define "multiple projects"? Usually that means 1 project == 1 domain.
Your provider should allow you to setup multiple domains on your web space. Each domain is then linked to 1 directory in your web space. This incurs fees, to pay for each domain.
Ex. for 1and1 (not a publicity, it just happens have a sites on their setup): www.example1.com points to /example1, www.example2.com points to /example2, and so on. This is setup in their administration interface.
Doing it like this is equivalent to setting up multiple VirtualHost sections.
2) 1 project == 1 domain prefix
Depending how your hoster does it, you could setup prefix1.example.com points to /site1 and prefix2.example.com points to /site2.
The user never sees /site1 or /site2 in their address bar.
Again that is done in the administration interface of your provider.
3) 1 project == 1 sub-directory of one domain, you cannot edit .htaccess
If you do not mind that, each project could be a sub-directory to the 1 domain you have.
www.example.com/project1, www.example.com/project2, ...
The user of your site must type in www.example.com/projectX to get access to the project. It is not hidden in the configuration, the user must explicitly input the project he wants in the browser address bar.
This does not require any configuration in Apache, or at the hoster level. Simply put the different directories under the DocumentRoot directory of the entire domain.
This does not provide a "clean" separation of the sites, but it might be enough for your needs.
4) like 3), but you can edit .htaccess files
In the DocumentRoot directory create a .htaccess file
In there, use Alias to tell Apache that requests to a sub-directory in the URL corresponds to another directory on disk, somewhere OTHER than under DocumentRoot like in 3)
This scenario might be less probable since your hoster will probably only allow you to put content under the DocumentRoot anyway.
See https://httpd.apache.org/docs/2.4/mod/mod_alias.html
Have fun!

Rewrite with multiple symfony projects under same directory

I'm trying to make some personal projects in my development server, like some sort of intranet.
If I divide each project in a different virtualhost, I set in each computer the host file to each server name and I don't have problems with the rewrite rule and the app.php. But the problem is that I can't modify the host file in an android device so I can't access those webs.
What I have in mind is something like this:
I have three symfony projects under my home folder
/home/user/projects/project1
/home/user/projects/project2
/home/user/projects/project3
Then, under the default folder of apache I make soft links to the web folder to every project:
ln -s /home/user/projects/project1/web /var/www/html/project1
ln -s /home/user/projects/project2/web /var/www/html/project2
ln -s /home/user/projects/project3/web /var/www/html/project3
So I can access them this way:
http://server-ip/project1
http://server-ip/project2
http://server-ip/project3
The problem is that I use those url I need to add the default app.php. I've been trying to modify the .htaccess file of each project, but I don't what to modify. I'm using the default virtualhost configuration and the default .htaccess file of each project.
I think that I need to modify the RewriteCond line, but I don't know what to do.
Thanks
I've got a local development environment (it's actually running on a linux server, under my desk, but the same setup would apply to any other configuration of server).
The webserver has a local IP address, reachable from elsewhere on the local network, including from my phone over WiFi.
All the development sites have their own Vhost configured on the server, with a common DNS prefix - something like *.devserver.domain.com.
The DNS is configured so that devserver.domain.com and the wildcard *.devserver.domain.com return 192.168.1.75 (or whatever the internal, static IP address is). This is a public domain name that has an A record to a local-range IP address, but it's entirely valid.
If you don't have a domain name that you can add wildcard DNSs to, you can use a service such as http://nip.io/ - and so the vhost Servername would be something like:
project1.192.168.1.75.nip.io
project2.192.168.1.75.nip.io
... etc
You may end up regularly editing the apache vhost if you internal IP changes at all, and maybe finding alternate wildcard DNS servers (my go-to was xip.io, but that isn't diffcult to do).
You may also be able to use an internal wildcard for an Apache ServerName/serverAlias: ServerAlias mysite.*.xip.io.

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

Apache2 virtualhost configuration trouble

This is my situation:
I have Redmine and Gitlab in my server which does not have a domain associated, because I will use the server IP address.
I want to configure two virtualhosts in apache2 with SSL in order to serve the above web applications, so I can access them like this:
https://x.y.z/redmine
which is located in /var/www/
https://x.y.z/gitlab
located in /home/git/github/public
I have configured apache by enabling two files in site-enabled: github.vhost and gitlab.vhost. The problem is that I cannot set gitlab to be accessible with
https://x.y.z/github
but only in
https://x.y.z
probably beacuse I do not use a domain but only the IP address of the server, and I don't know exactly how to manage it.
I would need some suggestion on how to correctly set the two vhost files.
Any suggestion?

Unable to find httpd.conf

I'm running tomcat and I want to change the default webroot so that it points to another location. Is there a way to find out what's running tomcat or where the default webroot is set as I can't find httpd.conf which is where I believe it's usually set?
Cheers,
Alexei Blue.
**UPDATE:**
It's been a long time since I looked at this question that I forgot about it. In the end it turned out that we were using Apache HTTPD to accept requests from port 80. From there we had the webroot and ProxyPass rules set in the /etc/httpd/conf/virtual-hosts/default.conf file (these can also be set in /etc/httpd/conf/httpd.conf). From there we had several tomcat instances running, all hosted on different ports which are setup in apache-tomcat-x/conf/server.xml.
When I wrote this question I was trying to setup a new tomcat instance to run an application in development and was told I would need to change the webroot to access my application, which was incorrect. Instead what I needed was to include a ProxyPass rule so that when my application name was recognised in the URL, HTTPD would send the request to the correct tomcat instance to be processed.
E.g.
www.domain.com/myApplication
In /etc/httpd/conf/virtual-hosts/default.conf
ProxyPass /myApplication/ ajp://127.0.0.1:<ajp_port>/myApplication/
ProxyPassReverse /myApplication/ ajp://127.0.0.1:<ajp_port>/myApplication/
Where the ajp_port is setup in apache-tomcat-x/conf/server.xml. I needed to ensure that non of the ports conflicted with other tomcat instances so remember to check all ports i.e. Shutdown, HTTP, HTTP with SSL, AJP etc.
Tomcat doesn't use httpd.conf, that is an apache file. The location of the individual webapps are kept in their individual web.xml files, but the location of all the configs are in ../tomcat6/conf/server.xml and web.xml
Is it where the files come from you want to move, or where it compiles and executes them from?
As #Woody says, Tomcat does not use httpd.conf files: that's an Apache httpd thing (httpd is a web server, Tomcat is a Java application server).
You didn't mention what OS you are using or what package management software you are using (e.g. yum, apt, etc.) so I'll give you generic information as if you had downloaded and installed Tomcat directly from apache.org (which I usually recommend people do for a number of reasons).
Tomcat keeps its server-wide configuration in the conf/server.xml file in the Tomcat base installation directory (often called $CATALINA_BASE for convenience): here, you configure things like what types of connectors (e.g. HTTP, HTTPS, AJP, etc.) to use and which ports they should listen to, clustering configuration, session persistence, global JNDI and realm resources. There are also conf/web.xml and conf/context.xml files that define defaults for all webapps deployed on that instance of Tomcat, but it's best to leave those files alone unless you have a really good reason to modify them.
When you want to deploy a webapp (under the default configuration), all you need to do is drop a .WAR file into the $CATALINA_BASE/webapps/ directory and the webapp will be deployed into a "context path" (aka URL prefix) that matches the name of the file minus the ".WAR" suffix. So, if you have a WAR file called mygreatwebapp.war, then it will be deployed such that your clients can reach it at http://yourhost/mygreatwebapp/. There is a special name you can give a WAR file so that it has an empty context path: if you name your WAR file ROOT.war (case matters), then your webapp can be reached at http://yourhost/. (If you would rather use exploded-WAR directories instead of WAR files, everything above still applies except the directories simply don't have the .war extension).
Given your original question, it sounds like all you want to do is drop a ROOT.war file into $CATALINA_BASE/webapps (or replace the one that is already there): this will deploy whatever webapp you want into the URL space that you might call the "default webroot".
Update
If you want to change the directory where all the webapps live for a host, you can modify $CATALINA_BASE/conf/server.xml and change the <Host>'s appBase attribute to point to, say, /cfusion/main/www/. That will deploy all the WAR files and directories in /cfusion/main/www/ as separate webapps.
If you just want to serve a single webapp from an arbitrary location, you may create a deployment file under $CATALINA_BASE/conf/[EngineName]/[HostName]/[appname].xml. This is a standard file like META-INF/context.xml and contains a <Context> element except that you will have to specify a docBase which points to your webapp (e.g. /cfusion/main/www/mywebapp).