Ubuntu server12.04 Installation Jdk+tomcat+mysql

Source: Internet
Author: User
Tags aliyun

First, install the JDK

1, first to the official web download jdk-7u79-linux-x64.tar.gz.

2, copy the jdk-7u79-linux-x64.tar.gz to the/usr/lib/jdk/directory below, if there is no JDK folder, create the folder, command:

1 cd/usr/lib2

My JDK is a U-disk copy, the first to be mounted, and then copied:

1 sudo mount/dev/sdc4/mnt/            // mount USB 2 sudo cp-a/mnt/jdk-7u79-linux-x64.tar.gz /usr/lib/jdk/     // Copy the downloaded file to the directory created  by the heart 3 sudo tar-zxvf jdk-7u79-linux-x64.tar.gz            // unzip files                  

3. Set environment variables, open/etc/profile file with vim

1 sudo vim/etc/profile

Add at the end of the file:

1 Export java_home=/usr/lib/jdk/jdk1.7. 0_792 export jre_home=/usr/lib/jdk/jdk1.7.0_79/ JRE 3 Export path= $JAVA _home/bin: $JAVA _home/jre/4 export classpath= $CLASSPATH:.: $JAVA _home/ Lib: $JAVA _home/jre/lib

Save exit.

4, modify the system default JDK

1 2 3 sudo update-alternatives--4 sudo update-alternatives--config javac

5, testing, verify that the JDK installation is successful

1 [email protected]:/$ java-version2 java Version "1.7.0_79"3 java (TM) SE Runtime En Vironment (Build 1.7.0_79-B15)4 Java HotSpot (TM) 64-bit Server VM (build 24.79-b02, Mixed mode)

Ii. installation of Tomcat

1, download apache-tomcat-7.0.67.tar.gz.

2, copy the apache-tomcat-7.0.67.tar.gz to the/usr/local/tomcat/directory below, if there is no Tomcat folder, create the folder, command:

1 cd/usr/local2sudo mkdir tomcat3  4 sudo mount/dev/sdc4/ mnt/      // Mount USB 5 sudo cp-a/mnt/apache-tomcat-7.0.67.tar.gz/usr/local/tomcat/    // Copy the downloaded file to the directory  created by the heart 6 sudo tar-zxvf apache-tomcat-7.0.67.tar.gz // unzip files                    

3. Start Tomcat

1 cd/usr/local/tomcat/apache-tomcat-7.0.67/bin/2

4. Open the browser and enter http://192.168.1.3:8080/to verify that the Tomcat installation is successful.

5, under Ubuntu Server, realize tomcat boot from boot (optional).

There are two ways to boot the Tomcat on Linux, one is simple, one is complex and professional, and we generally recommend the shell script startup method to implement using Shell script.

Setting up the boot-up service in Linux requires a/ETC/RCX.D under the load. In addition, you need to/etc/init.d some startup scripts. Export the required environment variables first, for example: Java_home,jre_home, Catalina_home, Catalina_base, and then call $catalina_home/bin/directly. Startup.sh will be able to start successfully.

The first step: we create a new file under/ETC/INIT.D Tomcat (need to operate under root privileges)

1 sudo vi/etc/init.d/tomcat

Write down the following code, Tomcat self-launching script:

1#!/bin/SH2# chkconfig:345 99 103# description:auto-starts Tomcat4#/etc/init.d/tomcatd5# Tomcat auto-Start6 # Source function library. 7#. /etc/init.d/functions8 # source Networking configuration. 9#. /etc/sysconfig/NetworkTenRetval=0 OneExport java_home=/usr/lib/jdk/jdk1.7. 0_79 AExport jre_home=/usr/lib/jdk/jdk1.7.0_79/JRE -Export catalina_home=/usr/local/tomcat/apache-tomcat-7.0.67 -Export catalina_base=/usr/local/tomcat/apache-tomcat-7.0.67 the Start () - {   -         if[-F $CATALINA _home/bin/startup.sh];  -  Then +echo $ "Starting Tomcat" -$CATALINA _home/bin/shutdown.sh +$CATALINA _home/bin/startup.sh ARetval=$? atecho "OK" -             return$RETVAL - fi - }   - Stop () - {   in         if[-F $CATALINA _home/bin/shutdown.sh];  -  Then toecho $ "Stopping Tomcat" +$CATALINA _home/bin/shutdown.sh -Retval=$? theSleep 1 *PS-FWWU Root | grep tomcat|grep-v grep | Grep-v PID | awk ' {print $} ' |xargs kill-9 $echo "OK"Panax Notoginseng# [$RETVAL-eq 0] && rm-f/var/lock/...   -             return$RETVAL the fi + }   A    the  Case"$"inch + start) - Stop $Sleep 1 $ Start -         ;;  - stop) the Stop -         ;; Wuyi                                                    the restart) -echo $ "restaring Tomcat" Wu$Stop -Sleep 1 About$Start $          ;;  -*)   -echo $ "Usage: $ {Start|stop|restart}" -Exit 1 A         ;;  + Esac theExit $RETVAL

Here is a special reminder to note that this sentence Ps-fwwu root | grep tomcat|grep-v grep | Grep-v PID | awk ' {print $} ' |xargs kill-9, the person familiar with the Linux command should be aware of the meaning of this sentence, here simply say the first half, query the root user tomcat process PID, personal changes according to the actual situation.

Step two: After you save the exit, add executable permissions to it

1 chmod +x/etc/init.d/tomcat

Step Three: Mount

Connect the shell file link to the/etc/rc2.d/directory. The numbers in the/etc/rcx.d/directory for Linux represent different run level when booting up, that is, the order of startup, there are 0-5 six level under Ubuntu, maybe some of the libraries that Tomcat needs are not loaded when the program in that directory starts. Use the LN command to link the links of Tomcat to the past: sudo ln-s/etc/init.d/tomcat/etc/rc2.d/s16tomcat. The naming rules under the RCX.D directory are very specific, more different needs may be the beginning of s, may also be the beginning of K, after the numbers represent their starting order, detailed look at the Readme file in their respective directories.

1 sudo ln-s/etc/init.d/tomcat/etc/rc2.d/s16tomcat

Fourth step: Set the script to boot from

Set this script to automatically execute when the system starts, and stop automatically when the system shuts down, using the following command:

1 chkconfig--add Tomcat

Without the Chkconfig command installed, you can:

1 sudo apt-get install chkconfig

Fifth Step: Verify

Execute sudo reboot. After rebooting, you will find that Tomcat has run successfully.

Digression: After adding this script we start, stop, restart Tomcat to use the command directly:

1 sudo service tomcat start   2 sudo service tomcat stop   3

third, install MySQL

  1, first update the source:

1 sudo apt-get update2 sudo apt-get upgrade

2. Install MySQL

1 sudo apt-get install mysql-server Mysql-common mysql-client

At this point, if the error, similar to the following errors, it means that MySQL depends on something is not updated:

1 The following packages has unmet dependencies: 2  mysql-client:depends:mysql-client-5.5 but it isn't going to being installed3  mysql-server:depends : mysql-server-5.5 But it isn't going to being installed4 e:unable to correct problems and you have held bro Ken Packages.

Solution Ideas:

Because the system comes with an installation source that does not resolve the installation package dependency problem, replace it with a new installation source, resolve the package dependency problem, and install the software.

Workaround:

First step: Modify APT Source

1 sudo cp-a/etc/apt/source.list/etc/apt/source.list.bak    // backup/etc/apt/source.list file  2 sudo vim/etc/apt/source.list

Part Two: Add the following to the front:

1Deb http://mirrors.aliyun.com/ubuntu/precise main restricted universe multiverse2Deb http://mirrors.aliyun.com/ubuntu/precise-security main restricted universe multiverse3Deb http://mirrors.aliyun.com/ubuntu/precise-updates main restricted universe multiverse4Deb http://mirrors.aliyun.com/ubuntu/precise-proposed main restricted universe multiverse5Deb http://mirrors.aliyun.com/ubuntu/precise-backports main restricted universe multiverse6DEB-SRC http://mirrors.aliyun.com/ubuntu/precise main restricted universe multiverse7DEB-SRC http://mirrors.aliyun.com/ubuntu/precise-security main restricted universe multiverse8DEB-SRC http://mirrors.aliyun.com/ubuntu/precise-updates main restricted universe multiverse9DEB-SRC http://mirrors.aliyun.com/ubuntu/precise-proposed main restricted universe multiverseTenDEB-SRC http://mirrors.aliyun.com/ubuntu/precise-backports main restricted universe multiverse

Part III:

1 apt-get Update

Although there are still some dependent packages that cannot be downloaded, installing MySQL has no effect.

3. Re-execution:

1 sudo apt-get install mysql-server Mysql-common mysql-client

At this point, you will be asked to enter the password for the "root" user, such as:

Enter the password, which means the installation was successful.

4. Verify that MySQL is installed successfully:

1 mysql-u root-p

Enter the password, which means the connection is successful.

1 mysql> show databases; 2 +--------------------+ 3 | Database           | 4 +--------------------+ 5 | information_schema | 6 | mysql              | 7 | p Erformance_schema | 8 +--------------------+ 9 3 rows in Set (0.01 sec)

A list of useful blogs to use for your own study:

1http//blog.csdn.net/ichsonx/article/details/40076149//JDK Install2http//blog.csdn.net/gyming/article/details/36060843//Tomcat Install3http//blog.csdn.net/wangli61289/article/details/37924785//Tomcat Startup4http//www.cyberciti.biz/faq/install-mysql-server-5-on-ubuntu-linux///MySQL Install5Https//help.aliyun.com/knowledge_detail/6702486.html//MySQL depends

Thanks for the above article, also hope this article can help some people.

Ubuntu server12.04 Installation Jdk+tomcat+mysql

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.