Can PhpStorm transform .htaccess files on deploy? - deployment

I am currently developing a PHP application using JetBrains PhpStorm. This applications contains several .htaccess files.
As there is right now no automated deployment process for this application I am using the "Upload to..." feature in PhpStorm. Using this feature the application is deployed to several servers.
The .htaccess files in my application need to have different content on different servers (staging systems vs production etc.). Unfortunately, so far I have not found a way to manage this reliably and have repeatedly overwritten .htaccess files with versions which are not suitable for the server I am deploying to.
Is there a way to make PhpStorm transform my .htaccess file before it is deployed? Or could I maybe define different versions of the same file for different servers?

The .htaccess files on each server are symlinks to the specified htaccess file in a folder. In this folder you have all your htaccess files from all servers. You skip the upload of the .htaccess files in PhpStorm, but you can change and deploy the files in the htaccess folder.
If you are able to create symlinks for htaccess files on your server, then this solution should work. It's not a clean solution, but better then wrong htaccess files on a server.

Related

JBoss EAP 6 - How to deploy huge exploded folder

We run JBoss 6 in standalone mode. We do have a folder (content.war/) in deployments that contains a symlink to a different folder (let's call it docs). Symlinking is enabled in jboss-web.xml with <symbolic-linking-enabled>true</symbolic-linking-enabled>. Our scenario is to use this to serve static files via this app context.
We do deploy the folder using touch content.war.dodeploy. It all works fine when the docs folder contains just few files. When the docs folder points to actual folder that has around 30GB the deployment seems to be stuck (the folder is not deployed and no other deployment works afterwards).
I believe that JBoss tries to somehow traverse or scan the whole folder. Is it possible to somehow disable this behaviour?
One workaround seems to do the trick. I can deploy an empty exploded war folder and once it is deployed I create the symlink to the huge folder.
Disadvantage: When JBoss is restarted it gets stuck again. I'd need to remove the link and create it again after deployment.
Another option is to use welcome-content that JBoss uses to serve static content. I can remove the original welcome-content folder and create a symlink to my folder instead.
ln ‐sv /home/mypath/my-static-content ${JBOSS_HOME}/welcome‐content
Disadvantage: This doesn't allow you to use any symlinks inside your folder or subfolders.

TYPO3 deployment with SURF, issue with LocalConfiguration.php

I am using TYPO3 SURF to deploy my application. I added "LocalConfiguration.php" to my .gitignore. So everytime I push and deploy, the config file is missing from the live server and I have to go through the install tool again.
What is the best way to fix this ?
Include your LocalConfiguration.php in your versioning and deployment. Use a configuration switch to have different configuration values on different systems (e.g. development vs production). Here are some ways how to do it: Good practices in TYPO3 projects #3 Use a configuration switch mechanism
You might want to copy the LocalConfiguration.php file into your shared folder and create a symlink from your release folder to that file.
https://docs.typo3.org/other/typo3/surf/2.0/en-us/Examples/TYPO3/Index.html

How to Copy Files on War Start

I have a number for Word Docs and PDFs that need to be copied to a file storage on start of my Grails app.
I figured I can just leverage BootStrap.groovy to check for existing files then copy if none found. However, I don't know the best practice of including the files into the WAR file.
How can I copy these files?
I don't know if it is a best practice, however we have all our external files into web-app directory. i.e. We have directories reports and pdf besides css and images directories. All that files are package and deploy into war file.

Deploy war file with modifiable properties files

I am building a web service and am packaging it into a war file for deployment. Right now all of my config files (.properties and .xml) are being packaged into my .war file. This isn't going to work as some of these files will need to be modified for each individual installation. I know that some servlet containers will leave the .war files intact which would mean the config files would never be easily modified. My question is this: what is the best practice for deploying a .war file with these external config files? I'm thinking that the config files will need to be shipped separate from the .war file and placed into a directory that is in the classpath. Is there a default directory setup like this in Tomcat that these files can just be dropped into and my web service will be able to find without much trouble?
Maybe I shouldn't be using a war file for this setup? Maybe I should just be providing a zip file (with the same contents as the war file) and the deployment will simply be to extract the zip into the webapps directory?
I do not know any default directory in Tomcat to store configuration, my
attempts to solve the same issue have been :
1 - Move configuration to the DB and provide scripts or webpages to modify values.
2 - Have a script to deploy the war. The script would merge configuration from a user directory into web.xml or other deployed config files.
3 - Have webapps look first in a user directory for configuration and
if not found then look for configuration files deployed by the war.
Least favorite is 3 - it require all webapps to check two places for configuration and
you end up with two different xml files on the server with different values and it is not always clear which one is used.
Next favorite is 2 - the webapps can be written without knowledge of multiple config files, but you run into issue when someone does a deploy from Tomcat manager instead of using your script.
Favorite is 1. This just works in most cases. Problem is when you don't have a DB or
want to configure how you connect to the DB.
If having the file visible from all webapps is not an issue, you could put it $CATALINA_HOME/lib.
One solution is to modify property file after deployment of war file is to use ServletContext.getRealpath() method to get the real path means path of file in the server where it is deployed and then modify that file it will modify file in container only not the original file. So you need to backup it if it is important modification for you. So by this you do not need to redeploy war file as it is already modifying file from deployed container.
This solution can edit a file that is in webpages folder also from the java class.
If you want more description or how to do it then let me know i have did it.

Good Ways to Use Source Control and an IDE for Plugin Code?

What are good ways of dealing with the issues surrounding plugin code that interacts with outside system?
To give a concrete and representative example, suppose I would like to use Subversion and Eclipse to develop plugins for WordPress. The main code body of WordPress is installed on the webserver, and the plugin code needs to be available in a subdirectory of that server.
I could see how you could simply checkout a copy of your code directly under the web directory on a development machine, but how would you also then integrate this with the IDE?
I am making the assumption here that all the code for the plugin is located under a single directory.
Do most people just add the plugin as a project in an IDE and then place the working folder for the project wherever the 'main' software system wants it to be? Or do people use some kind of symlinks to their home directory?
Short answer - I do have my development and production servers check out the appropriate directories directly from SVN.
For your example:
Develop on the IDE as you would normally, then, when you're ready to test, check in to your local repository. Your development webserver can then have that directory checked out and you can easily test.
Once you're ready for production, merge the change into the production branch, and do an svn update on the production webserver.
Where I work some folks like to use the FileSync Plugin for Eclipse for this purpose, though I have seen some oddities with that plugin where files in the target directory occasionally go missing. The whole structure is:
Ant task to create target directory at desired location (via copy commands, mostly)
FileSync Plugin configured to keep files in sync between development location and target location as you code (sync the Eclipse output folder to a location in the Web server's classpath, etc.)
Of course, symlinks may work better on systems that have good support for symlinks :-)
To me, adding a symlink pointing to your development folder seems like a tidy solution to the problem.
If the main project is on a different machine/webserver, you could use something like sshfs to mount your development directory into the right place on the webserver.