AWS EC2 and Tomcat startup.sh - linux

I installed Tomcat8 on my EC2 instance used following command:
sudo yum install tomcat8
I want to update startup.sh file but I can't find it.
/bin folder looks like showed on image:
How can I update startup.sh or reinstall tomcat with startup.sh and shutdown.sh files in bin folder? I don't have apt-get only yum

If you want to review the list of the files installed from the tomcat8 package, you can run
$ repoquery --list 'tomcat8'
You'll see that there's no startup.sh file, there are many blog and doc posts that will go through the installation, if you want better control on your installed tomcat and want to use the startup/shutdown script, it will be better to run a manual installation.
Manual installation
It's detailed here for example
Create a user called "tomcat" to own the Tomcat installation.
# useradd tomcat
Install the JDK from the tarball under the tomcat user.
# su - tomcat
$ tar xzf /tmp/jdk-8u77-linux-x64.gz
Install Tomcat from the tarball under the home directory of the "tomcat" user.
$ tar xzf /tmp/apache-tomcat-8.0.32.tar.gz
Set the following environment variables and append them to the /home/tomcat/.bash_profile so they are set for subsequent logins.
export JAVA_HOME=/home/tomcat/jdk1.8.0_77
export CATALINA_HOME=/home/tomcat/apache-tomcat-8.0.32
export CATALINA_BASE=$CATALINA_HOME
Start and stop Tomcat using the following scripts.
$ $CATALINA_HOME/bin/startup.sh
$ $CATALINA_HOME/bin/shutdown.sh
The Tomcat logs are written to the $CATALINA_HOME/logs/ directory by default.

Try at /usr/libexec/tomcat/server on AWS Linux 2

Related

Elastic Enterprise/App search installation problem on ubuntu

I'm running a vagrant box which runs ubuntu inside a vm (using Laravel Homestead box)
I'm trying to install the Elastic App-search product.
The first requirement is to install Elastic search, which i have done multiple times. I did the following steps:
https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
sudo apt-get install apt-transport-https
echo "deb https://artifacts.elastic.co/packages/7.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-7.x.list
sudo apt-get update && sudo apt-get install elasticsearch
I'm using the systemd configuration:
sudo /bin/systemctl daemon-reload
sudo /bin/systemctl enable elasticsearch.service
I'm running curl localhost:9200 and everything is working.
Next I try to install elastic app search.
https://www.elastic.co/guide/en/app-search/current/installation.html#installation-self-managed.
Which doesn't have instructions for debian systems. But it does have a .deb install file. I downloaded the file and put it in my project route.
I ran dpkg -i on the file and it seems to have installed. When I run the command to check the file location it shows this:
dpkg -L enterprise-search
/.
/etc
/etc/init.d
/etc/init.d/enterprise-search
/var
/var/log
/var/log/enterprise-search
/usr
/usr/share
/usr/share/enterprise-search
/usr/share/enterprise-search/README.md
/usr/share/enterprise-search/bin
/usr/share/enterprise-search/bin/vendor
/usr/share/enterprise-search/bin/vendor/filebeat
/usr/share/enterprise-search/bin/vendor/filebeat/filebeat-linux-x86_64
/usr/share/enterprise-search/bin/enterprise-search
/usr/share/enterprise-search/filebeat
/usr/share/enterprise-search/filebeat/ecs-template.json
/usr/share/enterprise-search/filebeat/filebeat-ecs.yml
/usr/share/enterprise-search/lib
/usr/share/enterprise-search/lib/require_java_version.sh
/usr/share/enterprise-search/lib/enterprise-search.war
/usr/share/enterprise-search/jetty
/usr/share/enterprise-search/jetty/webserver-ssl.xml
/usr/share/enterprise-search/jetty/webserver-ssl-with-redirect.xml
/usr/share/enterprise-search/jetty/webserver.xml
/usr/share/enterprise-search/LICENSE
/usr/share/enterprise-search/config
/usr/share/enterprise-search/config/env.sh
/usr/share/enterprise-search/config/enterprise-search.yml
/usr/share/enterprise-search/NOTICE.txt
/usr/share/doc
/usr/share/doc/enterprise-search
/usr/share/doc/enterprise-search/changelog.gz
/usr/lib
/usr/lib/systemd
/usr/lib/systemd/system
/usr/lib/systemd/system/enterprise-search.service
I'm not really sure if this is the correct location? I want it to live in the same place as my elasticsearch install, but I'm actually not sure. I did all the next steps for the install process and ran:
./usr/share/enterprise-search/bin/elasticsearch
But this gives me the error:
Could not find java in PATH
I'm very confused by this since the main elasticsearch installation works and that also needs java? Also i want it also to run with systemd auto-enable and i want it to be available with enterprise-search start / stop. Not sure how to handle that.
Looks like it's Debian package, so it's installable on ubuntu, but some things may differ.
I would say you can:
Just switch to using debian VM for this (here you can get vagrant for one: https://app.vagrantup.com/debian/boxes/stretch64 )
Debug. From what I see that package runs elasticsearch-env before it runs itself. Java is looked for like this:
if [ ! -z "$JAVA_HOME" ]; then
JAVA="$JAVA_HOME/bin/java"
JAVA_TYPE="JAVA_HOME"
else
if [ "$(uname -s)" = "Darwin" ]; then
# macOS has a different structure
JAVA="$ES_HOME/jdk.app/Contents/Home/bin/java"
else
JAVA="$ES_HOME/jdk/bin/java"
fi
JAVA_TYPE="bundled jdk"
fi
if [ ! -x "$JAVA" ]; then
echo "could not find java in $JAVA_TYPE at $JAVA" >&2
exit 1
fi
So I would advise to set JAVA_HOME in start script (or before running the binary), and see if that helps.
I solved it by adding another version of Java, Elastichsearch has a java install build-in and not separate, so the app-search install can't reach that version. Feels very dirty but got it working!

sudo: command not found when I ssh into server

I am a newbie with server handling and Linux. I am trying to install composer on my server so that i can host my Laravel project onto it as mentioned in the tutorial in Ultimate Guide: Deploy Laravel 5.3 App on LEMP Stack. I ssh into the server and after installation of composer when I run sudo mv composer.phar /usr/local/bin/composer I am getting a message in the terminal:
-bash: sudo: command not found
I desperately need some deliberate help
Sudo is probably not installed or not in your path
check to see if you are root in this case sudo is not needed unless you are trying to impersonate another user. just run your command without sudo mv composer.phar /usr/local/bin/composer
See if sudo is your path by running which sudo or echo $PATH. If sudo is not in your path, your path variable might be broken. You can try testing this by executing a common location for sudo /usr/bin/sudo or running locate sudo | grep bin to attempt to find its location.
If you know that sudo was installed, or your path looks broken, try fixing your path. Check your distribution's env file (/etc/environment in ubuntu) to make sure that it is formatted correctly (script commands are illegal in this file)
If you are not root and you want to run a command with root prvileges then you must install sudo. But if you don't have sudo and you are not root then you can't install it. In this case I recommend switching to the root user with su
If you do not have the root password and you own the machine, you can reset the root password with a tutorial such as https://askubuntu.com/questions/24006/how-do-i-reset-a-lost-administrative-password
After you manage to login as root install sudo with apt-get update; apt-get install sudosince you are using Ubuntu.
Verify the the name of your sudoers group with visudo and modify your sudoers file if you need to. https://www.digitalocean.com/community/tutorials/how-to-edit-the-sudoers-file-on-ubuntu-and-centos
if you have an existing sudoers group or you create one you can add yourself to the group. For example if your sudoers group is called sudo run usermod -aG sudo myuser. The sudoers group by default in Ubuntu based Linux is sudo. A sudoers group entry looks like this: %sudo ALL=(ALL:ALL) ALL
If you are trying to impersonate another user and cannot install sudo, you can still use su if it is installed and you have permission / password for the other user.
e.g. su someuser
As suggested in this post, you may have to install sudo in your server.
To do that, log in as root with the following command: su -. Then install sudo with your package manager (if you're in Ubuntu: apt-get install sudo).
Then add your user to the sudo group: usermod -aG sudo <username>.
Finally type exit to log out of the root account and go back to your user.
try to install your sudo using by first logging in as a root(su - ) and then try to install **apt-get or yum sudo **. Make sure your path variable is set so that you would be able to get binary.
which sudo
echo $PATH

Install Jenkins in specific folder in RHEL

When we install jenkins, by default it installs at /var/lib directory in the RHEL machine. But I want to install jenkins in other folder or filesystem. for example /jenkins.
Before installing jenkins I changed JENKINS_HOME=/jenkins and tried installing jenkins but it wont work.
These are the steps which I followed to install Jenkins
sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install jenkins
But the result is same it installs in /var/lib.
How can I install in /jenkins directory this?
Edit the /etc/sysconfig/jenkins file and change:
JENKINS_HOME = /var/lib/jenkins
to
JENKINS_HOME = /jenkins
and restart Jenkins.

Problems installing Pycharm

I am trying to install pycharm on my linux OS.
following the instructions pycharm/dowload.
Since I run a linux machine I made sure the pychrarm files in the current directory:
ietX220:~$ ls
Desktop pycharm-community-4.0.1
Documents Music
pycharm-community- 4.0.1.tar.gz
Downloads New Folder Templates
Dropbox octave-workspace Videos
examples.desktop Pictures VirtualBox VMs
jdk1.8.0_25 Public Win7-PV2hh-6c3HY-
QJHM9-8RJJH-P86W8.iso
ietX220:~$ pycharm-*.tar.gz
pycharm-community-4.0.1.tar.gz: command not found
As you can see the pycharm file is in the current(home) directory but is not found.
Then I opened the tar file made pycharm.sh executable:
chmod +x pycharm.sh
And then ran:
~/pycharm-community-4.0.1/bin$ ./pycharm.sh
Startup Error: Application cannot start in headless mode
What am I doing wrong?
I am having the same issue. It looks like maybe you and I both have a minimal (headless) Java install on our systems. Use your system's method for finding installed packages and search for Java, and i'll bet you find only openjdk-headless
yum list installed | grep openjdk
# or on debian-based systems
# dpkg --get-selections | grep openjdk
# =>java-1.7.0-openjdk-headless
Solution then is to install the same package without the "-headless" suffix.
Here's where I am getting my information for the solution: https://bugzilla.redhat.com/show_bug.cgi?id=1177379
I had the same problem and as mentioned before the error was that openjdk was headless. What i did is i installed from the begining openjdk using the command apt-get install default-jdk (for ubuntu). I know it's not the best way to do it, however it is rather quick and simple.
If you have already all the prerequisites (such as Java) installed, try out charmy (PyCharm installer for Linux).
virtualenv charmy-env
source charmy-env/bin/activate
pip install charmy
charmy install
That will install PyCharm into your home directory. It will also simplify your feature PyCharm upgrades. To upgrade you would just have to type
charmy install
instead of downloading distribution manually, unpacking it, etc.
See https://pypi.python.org/pypi/charmy for more.
PYcharm is now available as a snap. Can be easily installed as below
sudo apt update && sudo apt install snapd
Then the community edition can be installed by
sudo snap install pycharm-community --classic
The classic escape is to get snaps that have been published with classic confinements
220:~$ pycharm-*.tar.gz
pycharm-community-4.0.1.tar.gz: command not found
gz files are not executable files. I think the current directory is not in your PATH variable. To get around that you would do "./pycharm-community-3.0.1.tar.gz" and you should see the message "Permission denied" as the gz file would not have execute permission. And if you gave it execute permission it would say "cannot execute binary file: Exec format error".
These are the instructions from the JetBrains website:
Copy the pycharm-*.tar.gz to the desired installation location
(make sure you have rw permissions for that directory)
Unpack the pycharm-*.tar.gz using the following command:
tar xfz pycharm-*.tar.gz
Remove the pycharm-*.tar.gz to save disk space (optional)
Run pycharm.sh from the bin subdirectory
NOTE: PyCharm on Linux doesn't need special installation or running
any installation script. It runs out of the pycharm-*.tar.gz
If you run the command "tar xfz pycharm-*.tar.gz" you should end up with a directory in your current directory named "pycharm-community-4.0.3".
If you cd pycharm-community-4.0.3/bin, "ls -al" should show that pycharm.sh is already executable. Run pycharm.sh and you should be done. The script will prompt for a password at the end so it can put a startup script in a system directory. You must have admin privileges for that part to work. But if you don't, you can still start PyCharm by executing "[path to pycharm directory]/bin/pycharm.sh &" at the command prompt.
I am not sure what the "NOTE:" is saying, but I would ignore it as you get a working PyCharm by doing what it says above the NOTE: .
Setup the newest stable jdk(like jdk1.7 or jdk 1.8) in your system, and set it is the default jdk.
1.download JDK8
2.SET JAVA HOME
sudo gedit /etc/environment
export JAVA_HOME=/home/username/Java/jdk1.8
export JRE_HOME=/home/username/Java/jdk1.8
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
sudo gedit /etc/profile
//before umask xxx adde
export JAVA_HOME=/home/username/Java/jdk1.8
export CLASSPATH=$CLASSPATH:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export PATH=$JAVA_HOME/bin:$JAVA_HOME/jre/bin:$PATH:$JAVA_HOME/bin
3. run pycharm
./pycharm.sh

Nginx - Building from source - not working

I was using this code to install Nginx
aptitude -y install nginx
aptitude -y full-upgrade
This was working fine. However, I want to install my apps from source to give me more control. I then used this code:
cd /opt/
wget http://nginx.org/download/nginx-1.2.3.tar.gz
tar xvfz nginx-1.2.3.tar.gz
cd nginx-1.2.3
./configure
make
make install
However, it seems to have extracted and installed fine on the server, but I cant see anything on my site. The command used to restart my Nginx also no longer works:
/etc/init.d/nginx restart
Is anyone able to give me a bit more information on what might be going wrong?
You need to check, where the server was installed. Probably it was installed to the /usr/local/bin directory. And the binary, that it specified in /etc/init.d/nginx is in /usr/bin.
Also, you can add set -x as the second line in the /etc/init.d/nginx to see what happens when you start it.

Resources