How to send war file from local to aws server using putty? - amazon-ec2

I am trying to send war file built in Java Web application to AWS EC2 instance. Here is the command which I have far used for sending war file.
cd/ usr/share/tomcat8/webapps/
As I have my previous war file in this folder. After that I have use command ls from which something like this come
com.metokart com.metokart.war host-manager manager ROOT ROOT-OLD-1
At this .war is the previous one, First I have rename the folder ROOT to another name using this command-
sudo mv ROOT ROOT-OLD-6
After that I have deleted both the .war file and com.metokart folder from the webapps
sudo rm -rf com.metokart.war
sudo rm -rf com.metokart
Then I have gone to default directory to upload the new war file
sudo cp -i com.metokart.war /usr/share/tomcat8/webapps/
After that I have change the ROOT folder name back to ROOT.
sudo mv ROOT-OLD-6 ROOT
At last I have restarted my tomcat
sudo services tomcat8 restart
But still I don't know where I am doing the mistake. Hope anyone can help.

You should use pscp from within putty. Here is a helpful link that should guide you https://it.cornell.edu/managed-servers/transfer-files-using-putty.

Related

how to overwrite property files in a docker container?

I have a docker container inside which I have jar file that is of my springBoot application . How can I overwrite the application.property file of my app. Suppose if I want to change datasource url ,how can I do that through commandline?
Run docker ps and note the initials of id of your container.
Run docker exec -it <id> <bash or sh>, you will be inside your running container.
Go to your jar directory. Place your properties file in config/ as application.properties.
Rerun your app, but make sure to do it in background, so you can exit docker.
You can't restart the primary process (PID 1). For that usecase you'll need external volume and restart the container on property file change.
Create a volume: docker volume create vol1, you will get /var/lib/docker/volumes/vol1/
Change group of directory sudo chgrp 1001 /var/lib/docker/volumes/vol1/_data
Add write access to group: sudo chmod g+w /var/lib/docker/volumes/vol1/_data
Check the permissions of the directory: sudo ls -al /var/lib/docker/volumes/vol1/. They should be: drwxrwxr-x
Next time you run your container, mount the folder containing jar file to your volume as: docker run -d --name=webApp1 --mount source=vol1,destination=/path/to/app -p port:port name
You can change the property file in /var/lib/docker/volumes/vol1/_data/ and restart container: docker restart container_name
Disclaimer: Replacing properties file outside jar is not considered a good practice and is highly discouraged. So, these steps are only recommended for testing.

Laravel on ElasticBeanstalk 'log file permission denied' error keeps coming up even the permission is set in the .ebextensions config file

I am deploying my Laravel application to the ElasticBeanstalk environment. But I am having issue with laravel.log file permissions.
I deployed my application using "eb deploy" command. After I deployed, I access my application. But it is throwing the following error.
The stream or file "/var/app/current/storage/logs/laravel.log" could not be opened: failed to open stream: Permission denied
To solve the issue, I ssh into the server and run the following command.
sudo -u root chmod 777 -R /var/app/current/storage/logs
The problem is solved. Now my application is working. But I deploy my application again running "be deploy" command. After the deployment, the issue popped up again. To solve the issue in a consistent way. I tried to run the command in the .ebextensions config file as follow.
container_commands:
01-migrations:
command: "php artisan migrate --force"
02-log-storage-permissions:
command: "sudo -u root chmod -R 777 /var/app/current/storage/logs/"
I could deploy my application. But the issue still persists. It seems like the command is not working. What is wrong with my configuration and how can I fix it?
I believe that this is because container_commands run when your application is in the staging folder. Thus, after you run 02-log-storage-permissions, your /var/app/current will be replaced anyway with the staging folder. So your chmod wont persist.
To rectify the issue, you can try one of the two options:
Use
02-log-storage-permissions:
command: "sudo -u chmod -R 777 ./storage/logs/"
to change the logs in staging folder.
use postdeploy hook to run your script:
after the Elastic Beanstalk platform engine deploys the application and proxy server.

how to delete created server WebSphere Application Server Liberty Profile

I am working on docker images
setting up in docker file ...
# - Liberty installation of required features
RUN /opt/wlp/bin/featureManager install adminCenter-1.0 localConnector-1.0 jaxrs-1.1 jsp-2.2 jdbc-4.0 jndi-1.0 cdi-1.0 servlet-3.0 beanValidation-1.0 --when-file-exists=ignore --acceptLicense
RUN /opt/wlp/bin/server create my-server
...
but getting error
CWWKE0005E: The runtime environment could not be launched.
CWWKE0045E: It was not possible to create the server called cca-dist-d because the server directory /srv/www/servers/my-server already exists.
ERROR: Service 'appserver' failed to build: The command '/bin/sh -c /opt/wlp/bin/server create my-server' returned a non-zero code: 1
Is there way to remove such server before creation or any suggestions?
just for notice that rm -R does not work :-(
RUN /bin/bash -c 'rm -R /opt/wlp/bin/server/my-server'
---> Running in 83f*****bd
rm: cannot remove '/opt/wlp/bin/server/my-server': Not a directory
Regarding Liberty profile server deletion, it is as simple as to delete the entire directory. For example
rm -R WLP_HOME/usr/servers/my-server
Now about your error message, you should check why the server exist. Sounds like you have a problem in your setup.
And if you want to delete the my-server anyway, then you should remove the right directory. In your case:
rm -R /srv/www/servers/my-server
The servers are created into servers directory from WLP_USER_DIR environment. And the variable can be used to specify an alternate location for ${wlp.user.dir}. If this is specified, the runtime will look for shared resources and server definitions in the specified directory. Check server start script or README file for more information about the different environment variables.
In your case it seems that the WLP_USER_DIR is /srv/www/

IntelliJ needs to copy tomcat/conf directory to project directory

I have a freshly installed Tomcat 7 server, and I'm trying to make IntelliJ deploy a HelloWorld Spring MVC app to Tomcat.
My Tomcat home is /usr/share/tomcat7 and Tomcat base is /var/lib/tomcat7
However, when I try to run the project, IntelliJ throws an error saying:
Error running Tomcat : Error copying configuration files from /var/lib/tomcat7/conf to /home/adonis/.IntelliJIdea12/system/tomcat/Tomcat__SpringMVCApp/conf : /var/lib/tomcat7/conf/tomcat-users.xml (Permission denied)
Here is a screenshot - http://i.imgur.com/CQ3z0e1.png
Any permissions I need to set up?
Try chmod -R 777 /var/lib/tomcat7/conf/, it works to me.
Make sure that files under /var/lib/tomcat7/conf/ directory have read permission for the user IntelliJ IDEA is running from.
chmod -R 644 /var/lib/tomcat7/conf/
should help.
Also check that /home/adonis/.IntelliJIdea12/system/tomcat/ has correct permissions and owner. Could be that it was created from a different user and your current user doesn't have the rights to write into it.
If it doesn't help, download and unpack a new Tomcat installation from .tar.gz file, configure IDEA to use this installation instead.
Note that Tomcat installed using the package manager on some Linux systems has non-standard layout and permissions, and therefore will not work with IDEA.
I had the same problem and these steps helped me to Start my tomcat7 from Intellij :
I have Linux Mint 17,and Tomcat 7 which is installed using apt-get
CATALINA_HOME in /usr/share/tomcat7 and CATALINA_BASE in /var/lib/tomcat7
1- First I created a soft link which references /etc/tomcat7
cd /usr/share/tomcat7
ln -s /etc/tomcat7 conf
2- Then you have to change the access permissions of /etc/tomcat7
sudo chmod -R 655 /etc/tomcat7/
That's it.
For me, this worked for Tomcat 8 on Manjaro Linux:
sudo chmod -R 755 /usr/share/tomcat8/
I added my own user account to the tomcat7 group.
And chmod g+r /var/lib/tomcat7/conf/tomcat-users.xml
Had the same error with usr/share, dont just blindly run a command to act as magic-wand as many just tell you you run this and that on a mother-directory.
this is Linux, always some stupid thing with the permissions.
all you garra do is using chmod 666 or chmod 777 on files that are causing the error, but you need to look at those files first using ll and ls to make sure you are not decreasing some access, you may have a directory with 77x and when you do 666 you mess things up.
just gradually and one by one increase the chmod level and check whether problem goes away or not.
Sorry I didn't give you some code to fix all the problems.
This also happens to me, and I managed to solve it for Tomcat version 9, this problem is related to the configuration of Tomcat and you just need to give it permissions to be deployed.
You can use this link for more instructions.

Mac Lion Apache can't view files in document root

Apache is running, localhost is working, if I put an index.html that works as well. However I can't access any folders (my websites) within the document root, which is /Users/Me/Sites
I get a forbidden error when I try to access these.
What's going wrong?
You should check the permissions of your home folder and your sites directory to make sure that they allow Apache access.
You could check the permissions, or just run (in a Terminal)
chmod o+x $HOME
chmod -R o+rX $HOME/Sites

Resources